Automatic validation Invalid Order send error 131 - page 2

 
Alain Verleyen:
If you want to sell a product and can't manage to fix such error (though I provide you a link with the solution) I would suggest you to hire someone in Freelance section.

Thanks my friend this will be my last best solution 

 
Adel Haouam:

sorry for late reply 

many thanks for the idea  still diidn't manage to resolve it 


i will keep trying 

Hi adel i have this problem too 

do you have the solution now ?

 
Khaled Mahammedi:

Hi adel i have this problem too 

do you have the solution now ?

I am also interested to understand the solution better.


My resolve for now is to focus on selling my products elsewhere

 

Hi All

This error comes when the lot size that you are sending to ordersend command is either Big or not in proper format... Sometimes the broker does not allow 0.01 lots and you are sending 0.01 lots to ordersend.

or sometimes the lot size u r sending is wrong as 0.023 .. or sometimes its too big that the validation program cant handle..


1) Please use MarketInfo(Symbol(),MODE_MINLOT) if you want to send 0.01 lots... Store the value of MarketInfo(Symbol(),MODE_MINLOT)  in some variable and multiply it while using Ordersend

e.g. 

LotMultiplier  = 1;

FinalLots = LotMultiplier * MarketInfo(Symbol(),MODE_MINLOT);

TickOpen = OrderSend(Symbol(),OP_SELL,FinalLots ,Bid,15,NULL,NULL,"",0,11,Red);   


2) Check whether your lot size is getting too big during program, (i.e. if u r using martingale)


3) Check whether your lot size is not improper such as 0.012 or 0.125 etc.


I hope this will solve 

Thanks

Mangesh


 
Mangesh Chinchalkar:

Hi All

This error comes when the lot size that you are sending to ordersend command is either Big or not in proper format... Sometimes the broker does not allow 0.01 lots and you are sending 0.01 lots to ordersend.

or sometimes the lot size u r sending is wrong as 0.023 .. or sometimes its too big that the validation program cant handle..


1) Please use MarketInfo(Symbol(),MODE_MINLOT) if you want to send 0.01 lots... Store the value of MarketInfo(Symbol(),MODE_MINLOT)  in some variable and multiply it while using Ordersend

e.g. 

LotMultiplier  = 1;

FinalLots = LotMultiplier * MarketInfo(Symbol(),MODE_MINLOT);

TickOpen = OrderSend(Symbol(),OP_SELL,FinalLots ,Bid,15,NULL,NULL,"",0,11,Red);   


2) Check whether your lot size is getting too big during program, (i.e. if u r using martingale)


3) Check whether your lot size is not improper such as 0.012 or 0.125 etc.


I hope this will solve 

Thanks

Mangesh


I have tried uploading simple as well as more complex EAS and still the validator will not validate EA clearly the issue is with the validator. It validate scripts in the EA which may even render the EA inoperable yet it reject simple basic EAs.

Here are couple scripts which seem to work right now even though they are still not perfect....MT4 : #property strict


#include <stdlib.mqh>

#include <stderror.mqh>


//| Checking the new values of levels before order modification      |

//+------------------------------------------------------------------+

bool OrderModifyCheck(int ticket,double price,double sl,double tp)

  {

//--- select order by ticket

   if(OrderSelect(ticket,SELECT_BY_TICKET))

     {//+------------------------------------------------------------------+

      //--- point size and name of the symbol, for which a pending order was placed

      string symbol=OrderSymbol();

      double point=SymbolInfoDouble(symbol,SYMBOL_POINT);

      //--- check if there are changes in the Open price

      bool PriceOpenChanged=true;

      int type=OrderType();

      if(!(type==OP_BUY || type==OP_SELL))

        {

         PriceOpenChanged=(MathAbs(OrderOpenPrice()-price)>point);

        }

      //--- check if there are changes in the StopLoss level

      bool StopLossChanged=(MathAbs(OrderStopLoss()-sl)>point);

      //--- check if there are changes in the Takeprofit level

      bool TakeProfitChanged=(MathAbs(OrderTakeProfit()-sl)>tp);

      //--- if there are any changes in levels

      if(PriceOpenChanged || StopLossChanged || TakeProfitChanged)

         return(true);  // order can be modified      

      //--- there are no changes in the Open, StopLoss and Takeprofit levels

      else

      //--- notify about the error

         PrintFormat("Order #%d already has levels of Open=%.5f SL=.5f TP=%.5f",

                     ticket,OrderOpenPrice(),OrderStopLoss(),OrderTakeProfit());

     }

//--- came to the end, no changes for the order

   return(false);       // no point in modifying 

  }

//+------------------------------------------------------------------+

//| Script program start function                                    |

//+------------------------------------------------------------------+

void OnStart()

  {

//--- price levels for orders and positions

   double priceopen,stoploss,takeprofit;

//--- ticket of the current order 

   int orderticket;

/*

   ... get the order ticket and new StopLoss/Takeprofit/PriceOpen levels

*/

//--- check the levels before modifying the order   

   if(OrderModifyCheck(orderticket,priceopen,stoploss,takeprofit))

     {

      //--- checking successful

      OrderModify(orderticket,priceopen,stoploss,takeprofit,OrderExpiration());

     }

  }

//+------------------------------------------------------------------+




For MT5: 

//--- class for performing trade operations

#include <Trade\Trade.mqh>

CTrade trade;

#include <Trade\Trade.mqh>

//--- class for working with orders

#include <Trade\OrderInfo.mqh>

COrderInfo orderinfo;

//--- class for working with positions

#include <Trade\PositionInfo.mqh>

CPositionInfo positioninfo;

//+------------------------------------------------------------------+

//| Checking the new values of levels before order modification      |

//+------------------------------------------------------------------+

bool OrderModifyCheck(ulong ticket,double price,double sl,double tp)

  {

//--- select order by ticket

   if(orderinfo.Select(ticket))

     {

      //--- point size and name of the symbol, for which a pending order was placed

      string symbol=orderinfo.Symbol();

      double point=SymbolInfoDouble(symbol,SYMBOL_POINT);

      int digits=(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);

      //--- check if there are changes in the Open price

      bool PriceOpenChanged=(MathAbs(orderinfo.PriceOpen()-price)>point);

      //--- check if there are changes in the StopLoss level

      bool StopLossChanged=(MathAbs(orderinfo.StopLoss()-sl)>point);

      //--- check if there are changes in the Takeprofit level

      bool TakeProfitChanged=(MathAbs(orderinfo.TakeProfit()-sl)>tp);

      //--- if there are any changes in levels

      if(PriceOpenChanged || StopLossChanged || TakeProfitChanged)

         return(true);  // order can be modified      

      //--- there are no changes in the Open, StopLoss and Takeprofit levels

      else

      //--- notify about the error

         PrintFormat("Order #%d already has levels of Open=%.5f SL=.5f TP=%.5f",

                     ticket,orderinfo.PriceOpen(),orderinfo.StopLoss(),orderinfo.TakeProfit());

     }

//--- came to the end, no changes for the order

   return(false);       // no point in modifying 

  }

//+------------------------------------------------------------------+

//| Checking the new values of levels before order modification      |

//+------------------------------------------------------------------+

bool PositionModifyCheck(ulong ticket,double sl,double tp)

  {

//--- select order by ticket

   if(positioninfo.SelectByTicket(ticket))

     {

      //--- point size and name of the symbol, for which a pending order was placed

      string symbol=positioninfo.Symbol();

      double point=SymbolInfoDouble(symbol,SYMBOL_POINT);

      //--- check if there are changes in the StopLoss level

      bool StopLossChanged=(MathAbs(positioninfo.StopLoss()-sl)>point);

      //--- check if there are changes in the Takeprofit level

      bool TakeProfitChanged=(MathAbs(positioninfo.TakeProfit()-sl)>tp);

      //--- if there are any changes in levels

      if(StopLossChanged || TakeProfitChanged)

         return(true);  // position can be modified      

      //--- there are no changes in the StopLoss and Takeprofit levels

      else

      //--- notify about the error

         PrintFormat("Order #%d already has levels of Open=%.5f SL=.5f TP=%.5f",

                     ticket,orderinfo.StopLoss(),orderinfo.TakeProfit());

     }

//--- came to the end, no changes for the order

   return(false);       // no point in modifying 

  }

//+------------------------------------------------------------------+

//| Script program start function                                    |

//+------------------------------------------------------------------+

void OnStart()

  {

//--- price levels for orders and positions

   double priceopen,stoploss,takeprofit;

//--- ticket of the current order and position

   ulong orderticket,positionticket;

/*

   ... get the order ticket and new StopLoss/Takeprofit/PriceOpen levels

*/

//--- check the levels before modifying the pending order   

   if(OrderModifyCheck(orderticket,priceopen,stoploss,takeprofit))

     {

      //--- checking successful

      trade.OrderModify(orderticket,priceopen,stoploss,takeprofit,

                        orderinfo.TypeTime(),orderinfo.TimeExpiration());

     }

/*

   ... get the position ticket and new StopLoss/Takeprofit levels

*/

//--- check the levels before modifying the position

   if(PositionModifyCheck(positionticket,stoploss,takeprofit))

     {

      //--- checking successful

      trade.PositionModify(positionticket,stoploss,takeprofit);

     }

//---

  }

//+------------------------------------------------------------------+



Just for clarification I dont take neither credit nor responsibility for these I found them in another forum

 
Uriel Melliphant:

I have tried uploading simple as well as more complex EAS and still the validator will not validate EA clearly the issue is with the validator. It validate scripts in the EA which may even render the EA inoperable yet it reject simple basic EAs.

Here are couple scripts which seem to work right now even though they are still not perfect....MT4 : #property strict


#include <stdlib.mqh>

#include <stderror.mqh>


//| Checking the new values of levels before order modification      |

//+------------------------------------------------------------------+

bool OrderModifyCheck(int ticket,double price,double sl,double tp)

  {

//--- select order by ticket

   if(OrderSelect(ticket,SELECT_BY_TICKET))

     {//+------------------------------------------------------------------+

      //--- point size and name of the symbol, for which a pending order was placed

      string symbol=OrderSymbol();

      double point=SymbolInfoDouble(symbol,SYMBOL_POINT);

      //--- check if there are changes in the Open price

      bool PriceOpenChanged=true;

      int type=OrderType();

      if(!(type==OP_BUY || type==OP_SELL))

        {

         PriceOpenChanged=(MathAbs(OrderOpenPrice()-price)>point);

        }

      //--- check if there are changes in the StopLoss level

      bool StopLossChanged=(MathAbs(OrderStopLoss()-sl)>point);

      //--- check if there are changes in the Takeprofit level

      bool TakeProfitChanged=(MathAbs(OrderTakeProfit()-sl)>tp);

      //--- if there are any changes in levels

      if(PriceOpenChanged || StopLossChanged || TakeProfitChanged)

         return(true);  // order can be modified      

      //--- there are no changes in the Open, StopLoss and Takeprofit levels

      else

      //--- notify about the error

         PrintFormat("Order #%d already has levels of Open=%.5f SL=.5f TP=%.5f",

                     ticket,OrderOpenPrice(),OrderStopLoss(),OrderTakeProfit());

     }

//--- came to the end, no changes for the order

   return(false);       // no point in modifying 

  }

//+------------------------------------------------------------------+

//| Script program start function                                    |

//+------------------------------------------------------------------+

void OnStart()

  {

//--- price levels for orders and positions

   double priceopen,stoploss,takeprofit;

//--- ticket of the current order 

   int orderticket;

/*

   ... get the order ticket and new StopLoss/Takeprofit/PriceOpen levels

*/

//--- check the levels before modifying the order   

   if(OrderModifyCheck(orderticket,priceopen,stoploss,takeprofit))

     {

      //--- checking successful

      OrderModify(orderticket,priceopen,stoploss,takeprofit,OrderExpiration());

     }

  }

//+------------------------------------------------------------------+




For MT5: 

//--- class for performing trade operations

#include <Trade\Trade.mqh>

CTrade trade;

#include <Trade\Trade.mqh>

//--- class for working with orders

#include <Trade\OrderInfo.mqh>

COrderInfo orderinfo;

//--- class for working with positions

#include <Trade\PositionInfo.mqh>

CPositionInfo positioninfo;

//+------------------------------------------------------------------+

//| Checking the new values of levels before order modification      |

//+------------------------------------------------------------------+

bool OrderModifyCheck(ulong ticket,double price,double sl,double tp)

  {

//--- select order by ticket

   if(orderinfo.Select(ticket))

     {

      //--- point size and name of the symbol, for which a pending order was placed

      string symbol=orderinfo.Symbol();

      double point=SymbolInfoDouble(symbol,SYMBOL_POINT);

      int digits=(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);

      //--- check if there are changes in the Open price

      bool PriceOpenChanged=(MathAbs(orderinfo.PriceOpen()-price)>point);

      //--- check if there are changes in the StopLoss level

      bool StopLossChanged=(MathAbs(orderinfo.StopLoss()-sl)>point);

      //--- check if there are changes in the Takeprofit level

      bool TakeProfitChanged=(MathAbs(orderinfo.TakeProfit()-sl)>tp);

      //--- if there are any changes in levels

      if(PriceOpenChanged || StopLossChanged || TakeProfitChanged)

         return(true);  // order can be modified      

      //--- there are no changes in the Open, StopLoss and Takeprofit levels

      else

      //--- notify about the error

         PrintFormat("Order #%d already has levels of Open=%.5f SL=.5f TP=%.5f",

                     ticket,orderinfo.PriceOpen(),orderinfo.StopLoss(),orderinfo.TakeProfit());

     }

//--- came to the end, no changes for the order

   return(false);       // no point in modifying 

  }

//+------------------------------------------------------------------+

//| Checking the new values of levels before order modification      |

//+------------------------------------------------------------------+

bool PositionModifyCheck(ulong ticket,double sl,double tp)

  {

//--- select order by ticket

   if(positioninfo.SelectByTicket(ticket))

     {

      //--- point size and name of the symbol, for which a pending order was placed

      string symbol=positioninfo.Symbol();

      double point=SymbolInfoDouble(symbol,SYMBOL_POINT);

      //--- check if there are changes in the StopLoss level

      bool StopLossChanged=(MathAbs(positioninfo.StopLoss()-sl)>point);

      //--- check if there are changes in the Takeprofit level

      bool TakeProfitChanged=(MathAbs(positioninfo.TakeProfit()-sl)>tp);

      //--- if there are any changes in levels

      if(StopLossChanged || TakeProfitChanged)

         return(true);  // position can be modified      

      //--- there are no changes in the StopLoss and Takeprofit levels

      else

      //--- notify about the error

         PrintFormat("Order #%d already has levels of Open=%.5f SL=.5f TP=%.5f",

                     ticket,orderinfo.StopLoss(),orderinfo.TakeProfit());

     }

//--- came to the end, no changes for the order

   return(false);       // no point in modifying 

  }

//+------------------------------------------------------------------+

//| Script program start function                                    |

//+------------------------------------------------------------------+

void OnStart()

  {

//--- price levels for orders and positions

   double priceopen,stoploss,takeprofit;

//--- ticket of the current order and position

   ulong orderticket,positionticket;

/*

   ... get the order ticket and new StopLoss/Takeprofit/PriceOpen levels

*/

//--- check the levels before modifying the pending order   

   if(OrderModifyCheck(orderticket,priceopen,stoploss,takeprofit))

     {

      //--- checking successful

      trade.OrderModify(orderticket,priceopen,stoploss,takeprofit,

                        orderinfo.TypeTime(),orderinfo.TimeExpiration());

     }

/*

   ... get the position ticket and new StopLoss/Takeprofit levels

*/

//--- check the levels before modifying the position

   if(PositionModifyCheck(positionticket,stoploss,takeprofit))

     {

      //--- checking successful

      trade.PositionModify(positionticket,stoploss,takeprofit);

     }

//---

  }

//+------------------------------------------------------------------+



Just for clarification I dont take neither credit nor responsibility for these I found them in another forum

I am having the same issue, and I used some available EAs I found online and it is still giving me the same issue as you.


Currently I used the following codes to verify what lot size and steps my broker allows:

Print(MarketInfo(Symbol(), MODE_LOTSIZE));   // Lot size
Print(MarketInfo(Symbol(), MODE_MINLOT));    // Minimum lot size
Print(MarketInfo(Symbol(), MODE_LOTSTEP));   // Increment lot size
Print(MarketInfo(Symbol(), MODE_MAXLOT));    // Maximum lot size

My increments are well within what was shown, but I am still getting that error.


Will be googling more and reading the forums to see i can find a solution or not.

Reason: