A question about which is correct ...

 
I have tried to find a definitive answer to this query from codebase and e-books I have and am still uncertain about whether these two are functionally identical or if there is an important difference.

High[1]  or iHigh(NULL,0,1)
I am using High[1] because this is what Forex EA Generator writes but in the reference books I see the other (same applies to Low[1] or iLow(NULL,0,1)
 

I have been wondering the same thing and could not find an answer either. If someone could explain the difference,
it would be greatly appreciated. Thanks.

 

Yes there is an important difference. iHigh() is a function. High[i] is simply an array value, therefore iHigh() is slower.

You should only use iHigh() when the chart you need the value from may not be the one the EA/indicator is attached to, if you know it is to be aquired from the one your EA/indicator is attached to, use High[i] for its faster access.

 
SDC:

Yes there is an important difference. iHigh() is a function. High[i] is simply an array value, therefore iHigh() is slower.

You should only use iHigh() when the chart you need the value from may not be the one the EA/indicator is attached to, if you know it is to be aquired from the one your EA/indicator is attached to, use High[i] for its faster access.


Many thanks SDC for this informative reply. I now understand the difference and will retain the High[1] format with confidence.
 

I personally use always the something like: iHigh("EURUSD",PERIOD_H1,1).

Why? This allow user erros. If you switch by accident Timeframe, or even Symbol, the iHigh() variant will still work as intended, while the use uf High[] does not.

 
zzuegg:
I personally use always the something like: iHigh("EURUSD",PERIOD_H1,1).

Why? This allow user erros. If you switch by accident Timeframe, or even Symbol, the iHigh() variant will still work as intended, while the use uf High[] does not.

High[x] equals iHigh(NULL,0, x) always (except for RefreshRates() issues. When you switch timeframes or symbols, the EA goes through a deinit/init cycle and the next Start call High[]... will be the new values.

Zzuegg is using explicit pair/timeframe (not NULL,0.) So

  1. That means ALL variables must be changed Bid, Ask, Symbol(), Period(), Point, etc. must use the function call equivalents. Miss one and the bug will be hard to find.
  2. The EA will only trade the specified pair/tf even if put on others. This better be explicitly documented.
  3. String must be changed for different brokers (EURUSD, EURUSDm, EUR/USD, ...)
  4. Function call is slower.
  5. Unnecessary. The EA could detect the chart change and if it had open trades, change the chart back or alert the user or put up a confirmation message box.