hi !
I try to search a solution for allowed or not allowed a trade ( Buy or sell ) based on the last order time closed, look like that : OrderCloseTime() + Hours for allow the news trade
Help me please :(. ( Sorry for my poor english :s )
I try that but it's not work :
Yes i now it useless, but i tryed everything ... Without success :/
I have strictly no idea who allowed a trade 3 hours after the last order close, and not before.
If you can help me, your welcome :).
Print("Now="+TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS) +" ok="+TimeToStr(TimeAllowed, TIME_DATE|TIME_MINUTES|TIME_SECONDS) +" T"+(TimeCurrent() - TimeAllowed) ); if (TimeCurrent() >= TimeAllowed )
Yes i now it useless, but i tryed everything ... Without success :/
I have strictly no idea who allowed a trade 3 hours after the last order close, and not before.
If you can help me, your welcome :).
Yes i read the documentation, i check the OrderOpenTime() because on this forum a guy have a similar problem ( just one trade on 24h ) and he use if(TimeCurrent()> OrderOpenTime + 86000 && TimeCurrent() + OrderCloseTime()+2*3600)
I try to wrote a similar code by taking his code.
if(TimeCurrent >= OrderCloseTime() + Hours*3600){
//Buy & Sell
}
I try that but not working ... Have you got a good documentation RaptorUK ? Or the correct solution ?
Thank for help guy
bool AllowOpen(int _iHour){ int liLastClose = 0; for (int i = 0; i < OrdersHistoryTotal(); i++){ if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) == false) continue; liLastClose = MathMax(liLastClose, OrderCloseTime()); } if (liLastClose+_iHour*3600 > TimeCurrent()){ return(false); } return(true); }untested, hth
It compiles in my editor. You should be able to call the function like this.
int start(){ //manage open positions here if (!AllowOpen(3)) return(0); // open your trade here return(0); }the function just finds the youngest closed record in your history. It could be written somewhat more efficiently, but first make it work, then make it faster.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi !
I try to search a solution for allowed or not allowed a trade ( Buy or sell ) based on the last order time closed, look like that : OrderCloseTime() + Hours for allow the news trade
Help me please :(. ( Sorry for my poor english :s )
I try that but it's not work :