//| "Tick" event handler function | //+------------------------------------------------------------------+ void OnTick() { static datetime timeCur; datetime timePre = timeCur; timeCur=Time[0]; bool isNewBar = timeCur != timePre; if(isNewBar){ : // Once per bar } : // every tick } //+------------------------------------------------------------------+
Just past like this ?
Update : it has some errors Quenney Lam:
Just past like this ?
Update : it has some errorsvoid OnTick() { static datetime barTime=0; datetime nowTime=iTime(_Symbol,PERIOD_CURRENT,0); if(barTime!=nowTime) { barTime=nowTime; //Here do stuff that you only want executed on a new bar open. } //Here do stuff that you want executed every tick }
Interesting idea . It raises some questions :
- Are the open prices treated like ticks in mt5 ?
- If yes ,then you should also code custom stops and take profits to execute only in the new bar opening (yes = 1 tick = 1 open price)
- If not ,then you should test more to see what is processed first , the SL or the TP (no = 3 ticks = 1open 1low 1high )
- Same for any trailing
- and lastly ,why does testing with open prices only 38 days on a daily chart report a 99% history quality ?
- is history quality = modelling quality ?

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
How can I modify my EA for it to execute order at open price only like backtest ?