Error131

 

Hello,

I am experiencing the error 131 by using the following code:

    if(AccountFreeMarginCheck(Symbol(),OP_BUY,Lots)<=0 || /* NOT_ENOUGH_MONEY */GetLastError()==134)

     {

      Alert(BalanceErr);

      return;

     }

   else

     {

      RefreshRates();

double OrderPrice=Ask;
      tkt_buy=OrderSend(Symbol(),//Pair
                        OP_BUY,                       //Command Type
                        0.10/*NormalizeDouble(Lots,Digits)*///Lot Size
                        OrderPrice,                   //Market Price
                        Slippage,                     //Max. Slippage
                        NULL,                         //Stop Loss
                        NULL,                         //Take Profit
                        TradesComment,                //Comment
                        MagicNumber,                  //Magic No.
                        0,                            //Expiration (Only Pending Orders)
                        clrNONE);                     //Arrow Color

      if(tkt_buy>0)
        {
         Print("Buy order placed successfully");

         //---
         double TheStopLoss=0;
         double TheTakeProfit=0;

         bool MyOrderSelect=OrderSelect(tkt_buy,SELECT_BY_TICKET);
         if(StopLoss > 0)   TheStopLoss   = OrderOpenPrice()-StopLoss*MyPoint;
         if(TakeProfit > 0) TheTakeProfit = OrderOpenPrice()+TakeProfit*MyPoint;

         bool MyOrderModify = OrderModify(OrderTicket(),                         //Selected Ticket No.
                                          OrderOpenPrice(),                      //Selected Order Open Price
                                          /*Modify*/  NormalizeDouble(TheStopLoss,Digits),   //Selected Order Stop Loss
                                          /*Modify*/  NormalizeDouble(TheTakeProfit,Digits), //Selected Order Take Profit
                                          0,                                     //Selected Order Expiration (Only Pending Orders)
                                          Green);                                //Selected Order Arrow Color

         if(!MyOrderModify) Print("Unable to place SL/TP for the Buy order: ",ErrorDescription(GetLastError()));
        }
      else Print("Buy order failed with error: ",ErrorDescription((GetLastError())));
     }

.

seems no wrong on it!! but why I am receiving the following error????

 

I will not buy your EA for sure 

 
Alain Verleyen:

I will not buy your EA for sure 

I am not doing marketing

but just asking

where is the answer? 

 

You will find your answer in here

 
honest_knave:

You will find your answer in here

I have read it

actually, it is working perfectly on the live time

but it is giving this error on  the Auto-Validation ONLY

 

The answer is there.

131

ERR_INVALID_TRADE_VOLUME

Invalid trade volume


Have a read in the appropriate section of the link I posted.

 

I don't know what is wrong in the lot size 0.10

?? 

tkt_buy=OrderSend(Symbol(),                           //Pair
                        OP_BUY,                       //Command Type
                        0.10,                         //Lot Size
                        OrderPrice,                   //Market Price
                        Slippage,                     //Max. Slippage
                        NULL,                         //Stop Loss
                        NULL,                         //Take Profit
                        TradesComment,                //Comment
                        MagicNumber,                  //Magic No.
                        0,                            //Expiration (Only Pending Orders)
                        clrNONE);                     //Arrow Color


 

 
I'll give you another hint... first line of the appropriate section in the link I posted.
 
honest_knave:
I'll give you another hint... first line of the appropriate section in the link I posted.
I will propose you as candidate for Helper Nobel Prize :-D
 
Mohammad Soubra:

I am not doing marketing

but just asking

where is the answer? 

I will say you my opinion, very kindly and without offense. If you want to sell a product you should be able to manage such a trivial issue. This site if full of resources about that topic.
 

Check all OrderSend function calls , there might be other calls to functions , further more you are adding sl with other function call where as you have option to send it with order you just adding extra overhead to cpu and broker.

Reason: