error 130

 

Hi guys. I can't understand why the backtest of this strategy gives me back error 130. can someone help me?


void OnTick(){

   OpenOrder_Short();
   OpenOrder_Long();
   CloseOrder();

}

void OpenOrder_Short(){
   
   ampiezzaSL();
   
   if(iClose(Symbol(), 0, 1) > iHigh(Symbol(), 0, iHighest(Symbol(), 0, MODE_HIGH, 50, 2))&&
      
      OrdersTotal() == 0){
   
      Ticket = OrderSend(Symbol(), OP_SELL, 0.2, Bid, 0, Bid + SL*Point, 0, 0, 0, 0, clrAliceBlue);
   
   }

}
 
void OpenOrder_Long(){
   
   ampiezzaSL();
   
   if(iClose(Symbol(), 0, 1) < iLow(Symbol(), 0, iLowest(Symbol(), 0, MODE_LOW, 50, 2))&&
      
      OrdersTotal() == 0){
   
      Ticket = OrderSend(Symbol(), OP_BUY, 0.2, Ask, 0, Ask - SL*Point, 0, 0, 0, 0, clrBlanchedAlmond);
   
   }

}
   
void CloseOrder(){
   
   if(iClose(Symbol(), 0, 1) < iLow(Symbol(), 0, iLowest(Symbol(), 0, MODE_LOW, 50, 2))){
   
      OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES);
         
         if (OrderCloseTime() == 0 && OrderType() == OP_SELL){
         
            OrderClose(Ticket, OrderLots(), Ask, 0, 0);
           
         }

   }
   
   else if(iClose(Symbol(), 0, 1) > iHigh(Symbol(), 0, iHighest(Symbol(), 0, MODE_HIGH, 50, 2))){
   
       OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES);
         
         if (OrderCloseTime() == 0 && OrderType() == OP_BUY){
         
            OrderClose(Ticket, OrderLots(), Bid, 0, 0);
   
         }
   }

}

void ampiezzaSL(){ //wideness stop loss

   SL = AccountFreeMargin()*8/100/(MarketInfo(Symbol(),MODE_TICKVALUE))*0.2;
   SL = NormalizeDouble(SL, 0);

}
 
maybe this code can be useful... it's the code that i have used to try to find the reason why the upper code doesn't work. in basis of the results printed by this code it should be correct... but... :/
double SL;
void OnInit(){

SL = AccountFreeMargin()*8/100/(MarketInfo(Symbol(),MODE_TICKVALUE))*0.2;
SL = NormalizeDouble(SL, 0);
Alert ("sl no *Point ", SL);
SL = SL*Point;
Alert("sl ",SL);
Alert("price level sl ",Ask - SL);

}
Reason: