I am trying to accomplish 3 things with this piece of code :
1) I want to check the order history and identify the last closed trade of a specific signal associated with the chart/EA.
2) I want to be able to correctly identify the symbol associated with the chart/EA, even though other EA's are running and executing trades on different symbols.
3) Once I have identified the last trade closed of said symbol, I am wanting to introduce a 1 hour delay before entering any new trades.
Withe the code below, I believe that I have requirements (1) and (2) covered, but I simply cannot get the 1 hour delay to work properly (the EA obeys the 1 trade per bar rule in the code, but not the time delay). Please would someone point out my error as I have spent days and hours on this now, but just cannot get it right :
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to accomplish 3 things with this piece of code :
1) I want to check the order history and identify the last closed trade of a specific signal associated with the chart/EA.
2) I want to be able to correctly identify the symbol associated with the chart/EA, even though other EA's are running and executing trades on different symbols.
3) Once I have identified the last trade closed of said symbol, I am wanting to introduce a 1 hour delay before entering any new trades.
Withe the code below, I believe that I have requirements (1) and (2) covered, but I simply cannot get the 1 hour delay to work properly (the EA obeys the 1 trade per bar rule in the code, but not the time delay). Please would someone point out my error as I have spent days and hours on this now, but just cannot get it right :
{ //code for waiting 1 hour between trades closed by another EA; incl this EA; starts here; datetime LastClose = OrderCloseTime(); for(int x=OrdersHistoryTotal()-1;x>=0;x--) { OrderSelect(x, SELECT_BY_POS,MODE_HISTORY); if(OrderSymbol()==Symbol() &&(OrderCloseTime()+3600<TimeCurrent())) { CountThis(); if (Buys==0 && Sells==0 && Bars != ThisBarTrade) //code for waiting 1 hour between trades closed by another EA; incl this EA; ends here {ThisBarTrade = Bars; // ensure only one trade opportunity per bar; CheckForOpen();} else{CheckForCloseThis();CheckForCloseAll();}return; } }//if }//if