Change lots/multiplier to lots=0.01 gives OrderSend error 130?

Results 1 to 8 of 8
 0 Attachment(s)    

Thread: Change lots/multiplier to lots=0.01 gives OrderSend error 130?

  1. #1

    Default Change lots/multiplier to lots=0.01 gives OrderSend error 130?

    to funyoo or others,

    for the life of me I can't get a martingale to revert back to initial lots.

    I've tried "extern double InitialLots=0.01", and said lots=InitialLots etc., but that didn't work either.

    this is all i have done, i tried 'hard-coding' the number into the 'else if'. I figured that has to work for sure, but after compiling without errors, it won't take any trades.

    all i did was replace this:

    else if((Balance+MinProfit)<AccountBalance())Lots=Lots/Multiplier;

    to this:

    else if((Balance+MinProfit)<AccountBalance())Lots=0.01;

    to which I get "OrderSend error 130"

    What have i done wrong? Is compile the same as "verify"? because the manual says 'verify', but my MT4 only says "compile".

    thanks for your help here!


  2. #2


    Something like this?? If it's equal to zero it's the initial lot, if it's not zero it goes to Martingale...

    if(max_lot_b == 0.0)
    lotsi = 0.1;
    lotsi = 2.0*max_lot_b;

  3. #3


    thanks for your input Bill.

    your code is definately a martingale, and takes care of any remote chance of lots=0, but what I'm looking for , is to have it check for a winner, ie: account balance is greater now.

    you gave me another idea, another way to skin the cat though, thanks...i'll paste syntax for syntax and see if anyone can see why the dang thing will compile, but won't take a trade...

    this time I replaced this entire line
    if (Balance!=0.0&&Martingale==True){if(Balance>AccountBalance())Lots=Multiplier*Lots;else if((Balance+MinProfit)<AccountBalance())Lots=Lots/Multiplier;else if((Balance+MinProfit)>=AccountBalance()&&Balance<=AccountBalance())Lots=Lots;}Balance=AccountBalance();
    with this...

    if(Balance<AccountBalance())Lots=0.1;else Lots=2*Lots;Balance=AccountBalance();
    she compiles and everything. I can't understand why it simply won't even take one trade. It gives OrderSend error 131

  4. #4


    If it is returning an OrderSend error, then it appears to be attempting to trade. This suggests that your logic is OK, but it is impossible to tell from just those 2 snippets of code.

    Error 131 is to do with the EA trying to send its order with an invalid trade size. Have you adjusted for minimum and maximum lots? Have you ensured that the lots use the correct lot step? Have you normalised the lot double before sending the order?

  5. #5

  6. #6


    Jeezz might have something...are you testing on a broker and/or account that will allow .01 Lots??? Many won't....FXDD etc...Posting the OrderSend lines (and broker) may help...
    Last edited by BillR; 04-11-2009 at 21:30.

  7. #7


    Hi jezzer and Bill, yes it is attempting to trade...the journal even shows it continuing even after the tester has apparently run its course...strange.

    minimum and maximum didn't do anything with that. But it had worked previously, until i changed that line in the first post.

    normalized....just the 'extern double Lot=0.1;'

    lot step....I'm not sure if it has it, or even needs it? I'm just multiplying times 2.

    I'm trying this on both IBFX and Alpari UK demo. I switched to hardcoding Lots=0.1, not 0.01 thinking that would cover all brokers and atleast get this thing going. Funyoo posted a very basic MACD crossing the zero line with a martingale, that stepped down one after a win. That's where all this stems from. I just want it to go back to Lots=0.1 after a win.

    below, i've posted his code for the ordersend,

    // expert open position value
    if(OS==1){if(TP==0)TPI=0;else TPI=Bid-TP*Point;if(SL==0)SLI=0;else SLI=Bid+SL*Point;TK=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slip,SLI,TPI,OrSt,Magic,0,Red);OS=0;return(0);}	
    if(OB==1){if(TP==0)TPI=0;else TPI=Ask+TP*Point;if(SL==0)SLI=0;else SLI=Ask-SL*Point;TK=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,SLI,TPI,OrSt,Magic,0,Lime);OB=0; return(0);}}
    thanks for your input, I just don't want to bother you guys for such a silly thing. Always some newbie trying to reinvent the wheel

    **** ok, I see now the original EA doesn't "OrderSend" on backtesting anyway! I was forward testing on demo last week, so I assumed it would backtest too! Apparently not. So maybe let's just forget it. Since my logical code made sense, maybe the thing will work in demo forward test anyway....sigh...****
    Last edited by sleepypipsCDN; 04-12-2009 at 02:23. Reason: info come to light...

  8. #8


    As I said previously, error 131 is because the EA is trying to send an order of the incorrect lot size.

    Once you have calculated your lot size, it is important to process the lot size further so that it is returned in a manner which your broker will accept. If you send an order for 1.5467 lots for instance, your broker's server will not understand.

    Firstly, you need to ensure that it uses the correct lot step.

    double LotStep=MarketInfo(Symbol(),MODE_LOTSTEP);
    Secondly, you need to check that it doesn't fall outside the minimum/maximum range that your broker will accept, so you need to run a line of code to do this.

    double MinLotSize=MarketInfo(Symbol(),MODE_MINLOT);
    if (Lots<MinLotSize) Lots=MinLotSize;
    You would also run a similar line to ensure it didn't exceed the maximum acceptable lot size.

    Once you've done that I suspect that your EA will start to send orders correctly.

Similar Threads

  1. OrderSend error 134
    By fxtester in forum MQL programming
    Replies: 0
    Last Post: 02-11-2015, 20:39
  2. Lots Multiplier( help Please)
    By joepayne in forum MQL programming
    Replies: 22
    Last Post: 02-12-2011, 03:35
  3. (Question) OrderSend error 4051
    By 4x4me in forum MQL programming
    Replies: 1
    Last Post: 08-18-2010, 15:01
  4. Nano Lots
    By JXBlack in forum Brokers
    Replies: 1
    Last Post: 07-23-2010, 19:36
  5. Mini Lots - Micro Lots
    By funyoo in forum Trading discussion
    Replies: 0
    Last Post: 01-23-2009, 11:06

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Change lots/multiplier to lots=0.01 gives OrderSend error 130?

GadgetVersus GadgetVersus France W3Ask W3Ask Brasil W3Ask Deutschland W3Ask Espaņa W3Ask France W3Ask Italia W3Ask Nederland