in the start function
Now=TimeCurrent(); TicketAge = (Now-TicketDate)/60; if (TicketAge>=(Period()*1)) // 1 or the number of bars you want to pass { *your code what you want to do if the order is older than one minute or you period* }
in the ordersend function,
if (ordersend ==success) { TicketDate=TimeCurrent(); // remember the time when the order is opened, you can also use one of the Order***() funtions, but i prefer this }
I don't know the direct answer to your question, but this seems to work for me:
curBarTime = iTime(curSymbol,curPeriod,0); if (curBarTime == prevBarTime) return; else prevBarTime = curBarTime;

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
Hi,
I want my expert to wait 1 candle after entering a trade to look for exit conditions. The way I tried to implement this in my code was the following :
....
ticket = ordersend(...)
if(ticket != -1)
Sleep(Period()*60000)
Check exit conditions.....
It doesn't seems to work in backtesting mode (I didn't try in live yet). Is there a known compatibility problem with the function Sleep and the Backtest mode ? Or is my code wrong ?
Thanks