Download MetaTrader 5

TimeCurrent() Backtest vs TimeCurrent Live ticks

To add comments, please log in or register
Store your source codes in MQL5 Storage. It is secure!
Ndumiso Mavuso
Ndumiso Mavuso 2016.05.16 20:43 

There is something I don't understand, Im using TimeCurrent() on my indicator and something is not working as it should or as backtester and I planned it to so I investigated.

I used TimeCurrent() trying to match backtest's ticks speed with live feed ticks speed, but live feed's speed seems always faster calculated with TimeCurrent(). I will explain with a code.

(create object at this price)time=TimeCurrent(); //record the time at which object was created

int sec=1;

if (time<=TimeCurrent()-sec) //if 1 second past since object was created, edit its position
(move the created object to this price)time=TimeCurrent(); // record again the time at which is was created

//But if ticks were faster to reach the object within 1 sec
if(Bid>=object price)
ObjectDelete("Objectname"); // then delete the object

As I try to explain how I try to match backtest's and Live feed with above code. How do I know that live feed ticks are faster than backtest's, so is live TimeCurrent slower than backtest's? by observing this during backtest: my object will be deleted only at bars that only have high volume or during VisualMode bars that move faster or spikes, While during live ticks, my object will be often be deleted by a 20 volume bar.  Even if sec=5; (sec from code above) on backtest and sec=1; Live but still, low volume bars will delete the object while on tester it takes longer the object to be deleted and deleted by spike bars.

...any idea how to work around this?

Lorentzos Roussos
Lorentzos Roussos 2016.05.16 22:51  
Are you developing moving pending orders ?
Ndumiso Mavuso
Ndumiso Mavuso 2016.05.16 23:29  

No Mr Roussos, Its an indicator. I need to calculate price speed.

Did you have an idea? 

To add comments, please log in or register