Hi guys,
if a trade was closed i want my EA wait for opening a next trade till 5 bars were finished.
How can i do this?
How do i get the time of the close of the last trade and how can i compare it with the bars?
Read some of the other posts on the Forum . . .
Ok sry guys!
I did search but did'nt find the right solution.
If my EA wants to open a new trade then it show check if the last trade is minimum 5 bars ago!
Ok we open at the running bar a new trade
what can you tell about the closing time of the last closed trade your EA that it will be allowed for opening new trade ???
I tried to get the Time of the Last Closed Trade, but every time it is 0!
datetime Last; int TotalNumberOfOrders = OrdersHistoryTotal(); // for(int i = 0; i >=TotalNumberOfOrders - 1 ; i++) // { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) continue; // falls Zeile leer { if(OrderType()==OP_BUY && OrderType()==OP_SELL ) {Last=OrderCloseTime(); Alert(OrderCloseTime());} } } Alert(TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS)," Letzter Trade: ",Last); }
I tried to get the Time of the Last Closed Trade, but every time it is 0!
Your for loop is wrong . . .
for(int i = 0; // 1 starts at 0 i >= TotalNumberOfOrders - 1 ; // is i >= TotalNumberOfOrders - 1 ? yes if you only have 1 order in your History i++)
Ok i understood.
But even in this code "Last" is zero every time.
datetime Last; int TotalNumberOfOrders = OrdersHistoryTotal(); // for(int i = 0; i <=TotalNumberOfOrders - 1 ; i++) // { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) continue; // falls Zeile leer { if(OrderType()==OP_BUY && OrderType()==OP_SELL ) {Last=OrderCloseTime(); Alert(OrderCloseTime());} } } Alert(TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS)," Letzter Trade: ",Last);
Ok i understood.
But even in this code "Last" is zero every time.
How can this be true ?
if( OrderType() == OP_BUY && OrderType() == OP_SELL ) // ?? Buy and a Sell ?
How can this be true ?
Oh my god. So stupid.
Ok. Now i how can i compare the current time to the OrderCloseTime() in case of different Timeframes.
Since the close there should be minimum 5 Bars of the current timeframe.

- 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 guys,
if a trade was closed i want my EA wait for opening a next trade till 5 bars were finished.
How can i do this?
How do i get the time of the close of the last trade and how can i compare it with the bars?
Thanks guys