Hab mal versucht das Schließen der Order in den Ea einzubauen. Klappt leider nicht.Wo ist der Fehler?
extern int StopLoss=50;
extern int TakeProfit=50;
//+------------------------------------------------------------------+
void start()
{
double SL,TP;
int i,Total;
int Dig=MarketInfo(Symbol(),MODE_DIGITS);
int order_ticket;
//+------------------------------------------------------------------+
Total=OrdersTotal();
if(Total>0)
{
for(i=Total-1; i>=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true)
{
if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderStopLoss()==0 && OrderTakeProfit()==0)
{
if(StopLoss>0)SL=OrderOpenPrice()+StopLoss*Point;e lse SL=0;
if(TakeProfit>0)TP=OrderOpenPrice()-TakeProfit*Point;else TP=0;
OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(SL,Dig),NormalizeDouble(TP,Dig),0,CLR_NON E);
if (Time[0] > OrderOpenTime() + 2*Period()*60)
OrderClose(OrderTicket(),0.1,Bid,3,0);
return(0);
}
if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderStopLoss()==0 && OrderTakeProfit()==0)
{
if(StopLoss>0)SL=OrderOpenPrice()-StopLoss*Point;else SL=0;
if(TakeProfit>0)TP=OrderOpenPrice()+TakeProfit*Poi nt;else TP=0;
OrderModify(OrderTicket(),OrderOpenPrice(),Normali zeDouble(SL,Dig),NormalizeDouble(TP,Dig),0,CLR_NON E);
if (Time[0] > OrderOpenTime() + 2*Period()*60)
OrderClose(OrderTicket(),0.1,Ask,3,0);
return(0);
}
}
}
}
}
|