Download MetaTrader 5

Previous Ticks

To add comments, please log in or register
Steven Sroka
25
Steven Sroka 2011.09.10 06:33 

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 :(

Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Structure for Current Prices
  • www.mql5.com
Standard Constants, Enumerations and Structures / Data Structures / Structure for Current Prices - Documentation on MQL5
Alexander Piechotta
6973
Alexander Piechotta 2011.09.10 10:24  

 

Steven Sroka
25
Steven Sroka 2011.09.11 03:51  
FinGeR:

 

Unfortunately, I am in the Forex market so, MqlTick's "last" variable is *not* available in the Forex market. 

Any other ideas? 

Jimmy
490
Jimmy 2011.09.11 08:36  
lin-unix:

Unfortunately, I am in the Forex market so, MqlTick's "last" variable is *not* available in the Forex market. 

Any other ideas? 

SymbolInfoTick()?


Amir Yacoby
1195
Amir Yacoby 2011.09.11 17:56  
lin-unix:

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

}




Steven Sroka
25
Steven Sroka 2011.09.12 00:09  
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?
Amir Yacoby
1195
Amir Yacoby 2011.09.12 10:47  
lin-unix:
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. 

Jimmy
490
Jimmy 2011.09.12 13:45  
amir_avatar:

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. 

Agree, or if you really can't wait, you can copy the same last tick value as the preivious tick, so you still can do the calculation.
Steven Sroka
25
Steven Sroka 2011.09.12 16:45  
Thanks guys, I will wait for the second tick before I begin my calculations.
To add comments, please log in or register