+ Reply to Thread
Results 1 to 8 of 8
 0 Attachment(s)    

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

  1. #1
    Member sleepypipsCDN's Avatar
    Join Date
    Apr 2009
    Posts
    32

    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!

    SP.

  2. #2
    Member
    Join Date
    Feb 2009
    Posts
    317

    Default

    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;
    else
    lotsi = 2.0*max_lot_b;

  3. #3
    Member sleepypipsCDN's Avatar
    Join Date
    Apr 2009
    Posts
    32

    Default

    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
    Code:
    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...

    Code:
    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
    Member
    Join Date
    Jan 2009
    Posts
    151

    Default

    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?
    PipRider.com - The home of the PipRider EA. From $100 to over $1m in 10 year backtest, and it works LIVE too!!

  5. #5
    Member
    Join Date
    Jan 2009
    Posts
    151
    PipRider.com - The home of the PipRider EA. From $100 to over $1m in 10 year backtest, and it works LIVE too!!

  6. #6
    Member
    Join Date
    Feb 2009
    Posts
    317

    Default

    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
    Member sleepypipsCDN's Avatar
    Join Date
    Apr 2009
    Posts
    32

    Default

    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 lots.....no...i 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,

    Code:
    // expert open position value
    if((AddP()&&Add_Positions&&OP<=MaxOrders)||(OP==0&&!Add_Positions)){
    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);}}
    for(j=0;j<OrdersTotal();j++){if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES)){if(OrderSymbol()==Symbol()&&((OrderMagicNumber()==Magic)||Magic==0)){TrP();}}}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
    Member
    Join Date
    Jan 2009
    Posts
    151

    Default

    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.

    Code:
    double LotStep=MarketInfo(Symbol(),MODE_LOTSTEP);
    Lots=NormalizeDouble(Lots/LotStep,0)*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.

    Code:
    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.
    PipRider.com - The home of the PipRider EA. From $100 to over $1m in 10 year backtest, and it works LIVE too!!

+ Reply to Thread

Similar Threads

  1. Getting Error ')' Parameter expected
    By anand1268 in forum MQL programming
    Replies: 4
    Last Post: 05-16-2009, 07:33
  2. Change the color of an indicator
    By domick in forum MQL programming
    Replies: 7
    Last Post: 04-03-2009, 17:13
  3. Error for the EA that trade in the same hours everyday
    By alexlsy in forum MQL programming
    Replies: 1
    Last Post: 03-12-2009, 17:22
  4. Mini Lots - Micro Lots
    By funyoo in forum General discussion
    Replies: 0
    Last Post: 01-23-2009, 11:06
  5. Change of bar versus each tick
    By saintmo in forum MQL programming
    Replies: 2
    Last Post: 12-25-2008, 04: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