Download MetaTrader 5
To add comments, please log in or register
Format text in the messages editor. It is convenient!
Somchai Jaidee
81
Somchai Jaidee 2014.08.12 12:37 
if(CheckValueTime==iTime(NULL,TimeFrame,0)) return(0);

else CheckValueTime = iTime(NULL,TimeFrame,0);


I got this code from other forum and I have this code in my ea too.

And I got a different results between with and with out this code.

With this code it's can run optimization faster than without.

I am not sure with or without this code that make EA realistic.


Please anyone suggest to me or if anyone has a better like this code I would be appreciate.

Keith Watford
Moderator
7888
Keith Watford 2014.08.12 13:04  

That code means that any code that follows will only be executed if a new bar opens in the stipulated timeframe.

Obviously a lot quicker than when the full code executes every tick

Somchai Jaidee
81
Somchai Jaidee 2014.08.12 13:32  

Thank you GumRai.

I got a best result in backtest but bad results in demo.

You make me understand my EA better.


Thank you again.

Keith Watford
Moderator
7888
Keith Watford 2014.08.12 13:53  

Many strategies, such as MA crosses or stochastic/RSI crossing certain levels are coded to only execute when a bar closes (ie new bar opens).

This is to avoid (what some people consider) false signals when a cross happens while the bar is still open, but crosses back before the bar has closed.

Somchai Jaidee
81
Somchai Jaidee 2014.08.12 14:19  

I wonder why "CheckValueTime" variable remember previous value instant of  reset to zero when EA execute again.

I just declare in normal variable not global variable.

Keith Watford
Moderator
7888
Keith Watford 2014.08.12 23:18  
prothemeus:

I wonder why "CheckValueTime" variable remember previous value instant of  reset to zero when EA execute again.

I just declare in normal variable not global variable.


If the variable is declared locally and not static, it will not be remembered and the code will not be effective.
/
To add comments, please log in or register