Novice MQL5 programmer here.
Is there a way to check the price of a previous tick?
MqlTick's "last" variable is not available in the forex market :(
save each new MqlTick in a static variable in OnTick()
static MqlTick Last_Tick;
OnTick()
{
...
if (Last_Tick = ..) // access last tick
Last_Tick = MqlTick() // save the tick
}
I like the idea of keeping a local copy of ticks, but lets say my EA just gets gets turned on. It needs to have access to the previous tick in the market to do some calculations, but it can't have a copy of the previous tick because my EA was not running at the time the previous tick came in. Is there any way that my EA could still get information from the previous tick by say, querying the existing market data somehow?
No. You just have to check if it is the first tick the EA encounters, then let it just copy the tick and return. The next tick you will have the data for calculation.
P.S. If you just turned on your EA, it will not matter a great deal to wait one more tick.
No. You just have to check if it is the first tick the EA encounters, then let it just copy the tick and return. The next tick you will have the data for calculation.
P.S. If you just turned on your EA, it will not matter a great deal to wait one more tick.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Novice MQL5 programmer here.
Is there a way to check the price of a previous tick?
MqlTick's "last" variable is not available in the forex market :(