MT4 Real account OrderSend Error 131

To add comments, please log in or register
FXBeam
8
FXBeam  

Hi,

This happened in  broker only.

When placing order on real account thru EA getting OrderSend Error 131   Demo account is working fine.  I believe the reason for the error that: MODE_MINLOT, MODE_LOTSTEP and MODE_MAXLOT are all 0.0

Prints results:

Print("MODE_LOTSIZE = ", MarketInfo(Symbol(),MODE_LOTSIZE), ", Symbol = ", Symbol());
Print("MODE_MINLOT = ", MarketInfo(Symbol(),MODE_MINLOT), ", Symbol = ", Symbol());
Print("MODE_LOTSTEP = ", MarketInfo(Symbol(),MODE_LOTSTEP), ", Symbol = ", Symbol());
Print("MODE_MAXLOT = ", MarketInfo(Symbol(),MODE_MAXLOT), ", Symbol = ", Symbol());


Real account:

MODE_LOTSIZE = 100000.0
MODE_MINLOT = 0.0
MODE_LOTSTEP = 0.0
MODE_MAXLOT = 0.0

Demo account:

MODE_LOTSIZE = 100000.0
MODE_MINLOT = 0.01
MODE_LOTSTEP = 0.01
MODE_MAXLOT = 50.0

EA working fine on forex.com real account.

Any advise?

Thank you

Norbert Molnar
157
Norbert Molnar  

Error 131 means Invalid Stops.

Check the STOPLEVEL values. Maybe the SopLoss is smaller than the StopLevel

Or if the IG is STP broker (I don't know) you should use the OrderSend command in 2 steps.

Step 1: Send OrderSend command with  SL=0 and TP=0,

Step 2  Use OrderModify to set the correct SL and TP. 

If the EA is not your own - report the problem to the author. He has to modify the EA.

BR

AlgoGURU

William Roeder
18315
William Roeder  
Don't call MarketInfo in OnInit. Don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:
  1. Terminal starts.
  2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
  3. OnInit is called.
  4. For indicators OnCalculate is called with any existing history.
  5. Human may have to enter password, connection to server begins.
  6. New history is received, OnCalculate called again.
  7. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
To add comments, please log in or register