Hi,
I have a problem (OrderClose error 138), but I don't no why. Can you help me?
I'd like to put an SL into this EA...
void CheckForClose()
{
double ma;
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
//---- check order type
if(OrderType()==OP_BUY)
{
if(Close[1]<ma) OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
}
{
if(Ask<OrderOpenPrice()-StopLoss*Point) OrderClose(OrderTicket(),OrderLots(),Bid,0,Green);
break;
}
if(OrderType()==OP_SELL)
{
if(Close[1]>ma) OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
}
{
if(Bid>OrderOpenPrice()+StopLoss*Point) OrderClose(OrderTicket(),OrderLots(),Ask,0,Green);
break;
}
}
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
It seems I get 138 errors on different inputs of dates
May-June gives many 138 errors
March-April doesn't
I find this somewhat strange