Download MetaTrader 5

[Solved] Why does OnCalculate get called every tick, yet prices are only per bar (1M minimal)

To add comments, please log in or register
enjoysmath
64
enjoysmath  

A tick seems to occur every second or several times a second in MetaTrader 4.  And every tick OnCalculate() is called.  However, OnCalculate's parameters such as high[i] are such that each index in high represents one minute of data minimally (by setting time frame to 1M).

So what is the deal?  How can you get the highest res tick information?  What am I not understanding?

Keith Watford
Moderator
10644
Keith Watford  
What does "highest res tick information" mean?
enjoysmath
64
enjoysmath  
GumRai:
What does "highest res tick information" mean?
If the information changes every second, then I would expect to have a price or currency pair ratio every second, is that possible with MT4, why / why not?
whroeder1
15725
whroeder1  
enjoysmath:

A tick seems to occur every second or several times a second in MetaTrader 4.  And every tick OnCalculate() is called.  However, OnCalculate's parameters such as high[i] are such that each index in high represents one minute of data minimally (by setting time frame to 1M).

  1. There is the parameters high[] and the The predefined Variables - MQL4 Documentation High[]. Don't get them confused. high[] can be ordered either direction; High[0] is the current bar always.
    Ignore the parameters and just use
    int counted = IndicatorCounted();
    int lookback = ... // iMA(period) has look back of period.
                       // buffer[i+2] has look back of 2
                       // use maximum of all.
    for(int iBar = Bars - MathMax(lookback, counted); iBar >= 0; --iBar) ...
    
    the buffers and The predefined Variables - MQL4 Documentation
  2. It is called every tick because Close[0] and possibly the High or Low have changed.
To add comments, please log in or register