why Error 130 in ONLY BuyStop order but not showing in SellStop order?

 

Hello,

I wrote code for activate 1 Buystop at BBand UpperBand and 1 Sellstop order at BBand LowerBand, the code for buystop and sellstop is exactly the same except the direction is different.

When the condition is meet, the Sellstop is posted, but Buystop is not and get an error msg of "Order Sent Error 130"

I was testing it with Strategy Tester.

The code is below,can someone tell me why ONLY Buystop get an error msg and no order is sent?  

#define __SLEEP_AFTER_EXECUTION_FAIL 400

//Extern variables


//Global declaration
double _BB_Lower_Bands;
double _BB_Upper_Bands;

int start() {
   
    //Local declaration    
    bool _Send_PendingS;  
    bool _Send_PendingB;
         
    //check if no open or pending trade exist
    if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)!=true)//no open or pending order found, run 1st order
    { 
    //only store first Upper Band Value
    _BB_Lower_Bands= iBands(Symbol(), 0, 20, 2, 0, 0, 2, 0);
    _BB_Upper_Bands= iBands(Symbol(), 0, 20, 2, 0, 0, 1, 0);
  
   
    if( (_BB_Upper_Bands-_BB_Lower_Bands)<=0.002 )
   
         {
          
           _Send_PendingS = 0.1 >= MarketInfo( Symbol() ,MODE_MINLOT);
           _Send_PendingB = 0.1 >= MarketInfo( Symbol() ,MODE_MINLOT);
          
           if( _Send_PendingS == true ) _Send_PendingS = OrderSend( Symbol(), 5, 0.1,NormalizeDouble(_BB_Lower_Bands,5), MarketInfo( Symbol(), MODE_DIGITS ), 0,0, 0,0,0,0);
           if( _Send_PendingS == false ) Sleep(__SLEEP_AFTER_EXECUTION_FAIL);
           if( _Send_PendingB == true ) _Send_PendingB = OrderSend( Symbol(), 5, 0.1,NormalizeDouble(_BB_Upper_Bands,5), MarketInfo( Symbol(), MODE_DIGITS ), 0,0, 0,0,0,0);
           if( _Send_PendingB == false ) Sleep(__SLEEP_AFTER_EXECUTION_FAIL);
         }
    }
   
   

    return(0);
}

 
makemoneyorg:

Hello,

I wrote code for activate 1 Buystop at BBand UpperBand and 1 Sellstop order at BBand LowerBand, the code for buystop and sellstop is exactly the same except the direction is different.

When the condition is meet, the Sellstop is posted, but Buystop is not and get an error msg of "Order Sent Error 130"

I was testing it with Strategy Tester.

The code is below,can someone tell me why ONLY Buystop get an error msg and no order is sent?  

#define __SLEEP_AFTER_EXECUTION_FAIL 400

//Extern variables


//Global declaration
double _BB_Lower_Bands;
double _BB_Upper_Bands;

int start() {
   
    //Local declaration    
    bool _Send_PendingS;  
    bool _Send_PendingB;
         
    //check if no open or pending trade exist
    if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)!=true)//no open or pending order found, run 1st order
    { 
    //only store first Upper Band Value
    _BB_Lower_Bands= iBands(Symbol(), 0, 20, 2, 0, 0, 2, 0);
    _BB_Upper_Bands= iBands(Symbol(), 0, 20, 2, 0, 0, 1, 0);
  
   
    if( (_BB_Upper_Bands-_BB_Lower_Bands)<=0.002 )
   
         {
          
           _Send_PendingS = 0.1 >= MarketInfo( Symbol() ,MODE_MINLOT);
           _Send_PendingB = 0.1 >= MarketInfo( Symbol() ,MODE_MINLOT);
          
           if( _Send_PendingS == true ) _Send_PendingS = OrderSend( Symbol(), 5, 0.1,NormalizeDouble(_BB_Lower_Bands,5), MarketInfo( Symbol(), MODE_DIGITS ), 0,0, 0,0,0,0);
           if( _Send_PendingS == false ) Sleep(__SLEEP_AFTER_EXECUTION_FAIL);
           if( _Send_PendingB == true ) _Send_PendingB = OrderSend( Symbol(), 5, 0.1,NormalizeDouble(_BB_Upper_Bands,5), MarketInfo( Symbol(), MODE_DIGITS ), 0,0, 0,0,0,0);
           if( _Send_PendingB == false ) Sleep(__SLEEP_AFTER_EXECUTION_FAIL);
         }
    }
   
   

    return(0);
}

Two SELL_STOP.
 

Thanks A lot!

It was a stupid error I made:)