Hello to all , i am new here.
Actually i also have problem to adding the close all function to my martingale ea .
I have searching many forum , but i cant find the answer .
after reading this thread , i think i have the problem with the code symbol () too.
(I think is a same problem so i reply here .)
I want the close all function close profit/loss when it have open more then 1 order .
(if single open trade is in profit just let it continue )
When i attach the ea to single pair chart is working fine , but if i attach to more the 1 chart it will direct close when it hit the profit / loss i set .
Any one please help me to see , what should i need to change the code to specified the symbol() to the ea .
Thank you .
Code: Select all
int start()
{
// 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);
}
Code: Select all
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(),MarketInfo(OrderSymbol(), MODE_BID),5*Spread,Blue);
if((OrderType()==OP_SELL)&&((OrdrType==0)||(OrdrType==-1))) ClTicket=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(), MODE_ASK),5*Spread,Red);
}
}
return(0);
}