Hello ,
I have a problem with the close all function add to my ea .
I want the function to close all when i have open more then >1 trade with certain profit for each symbol chart.
When i back test is work correctly , but i run it for few symbol chart together it will close when the profit is reach and i only have open 1 position for each chart .
Please any one can help me find out the problem .
Thanks in advance .
I have a problem with the close all function add to my ea .
I want the function to close all when i have open more then >1 trade with certain profit for each symbol chart.
When i back test is work correctly , but i run it for few symbol chart together it will close when the profit is reach and i only have open 1 position for each chart .
Please any one can help me find out the problem .
Thanks in advance .
Inserted Code
// close all if (OrdersTotal()>1 && Profit_>0 && NetProfit()>=Profit_){ CloseAll(0); Sleep(1000); if (OrdersTotal()>1) CloseAll(0); } if (OrdersTotal()>1 && Loss_>0 && NetProfit()<=-Loss_){ CloseAll(0); Sleep(1000); if (OrdersTotal()>1) CloseAll(0); }
Inserted Code
int CloseAll(int OrdrType) { bool ClTicket=false; for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) { if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) { if (OrderSymbol() == Symbol() && (OrderMagicNumber() == MagicNumberBuy || OrderMagicNumber() == MagicNumberSell) && OrderCloseTime()==0) { if((OrderType()==OP_BUY)&&((OrdrType==0)||(OrdrType==1))) ClTicket=OrderClose(OrderTicket(),OrderLots(),Bid,2*Spread,Blue); if((OrderType()==OP_SELL)&&((OrdrType==0)||(OrdrType==-1))) ClTicket=OrderClose(OrderTicket(),OrderLots(),Ask,2*Spread,Red); } } } return(0); }