For example if i set candle back 4, when current candle 5 have create then stop loss only start move to the candle i set high or low .
And one more problem , is the ea only trail on buy but not trail on sell .
I cant find the problem .
Any one can giving a helping hand ?
Thank You .
Code: Select all
int BuyStopCandle = iLowest(NULL,0,MODE_LOW,CandlesBack,0);
int SellStopCandle = iHighest(NULL,0,MODE_HIGH,CandlesBack,0);
int err;
//
int digits = MarketInfo(OrderSymbol(),MODE_DIGITS);
double point = MarketInfo(OrderSymbol(),MODE_POINT);
double PointRatio = 1;
if (digits==3 || digits==5) PointRatio = 10;
for(int b = OrdersTotal()-1; b>=0; b--)
{
MyResult = OrderSelect(b,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber() == Magic)
if(OrderSymbol()!=Symbol()) continue;
if(OrderType() == OP_BUY)
RefreshRates();
if(OrderStopLoss()<Low[BuyStopCandle]-PipAmountsForTrailing*point)
MyResult = OrderModify(OrderTicket(),OrderOpenPrice(),Low[BuyStopCandle]-PipAmountsForTrailing*point,OrderTakeProfit(),0,CLR_NONE);
err=GetLastError();
if(err==4 || err==136 || err==137 || err==138 || err==146)
{
RefreshRates();
continue;
}
break;
}
for(int s = OrdersTotal()-1; s>=0; s--)
{
if(OrderSelect(s,SELECT_BY_POS,MODE_TRADES))
if(OrderMagicNumber()== Magic)
if(OrderSymbol()!=Symbol()) continue;
if(OrderType() == OP_SELL)
RefreshRates();
if(OrderStopLoss()>High[SellStopCandle]+PipAmountsForTrailing*point)
MyResult = OrderModify(OrderTicket(),OrderOpenPrice(),High[SellStopCandle]+PipAmountsForTrailing*point,OrderTakeProfit(),0,CLR_NONE);
err=GetLastError();
if(err==4 || err==136 || err==137 || err==138 || err==146)
{
RefreshRates();
continue;
}
}
}