Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27
 1 Attachment(s)    

Thread: Add Hidden TP and SL into code

  1. #11

    Default

    Additional update....Removing the code seems to have Hidden S/L working.....but do see Error 4111 ...Also as this is using Martingale type and the lotsi = .10 The lot sizes on FXDD only allow .10, .20, .30 .40 etc.....and I'd like to have the progression not at double but just at 1.4 or 1.5 times. ie. .10, .14, .19, .27 I know they don't allow it at FXDD so I'd like to have the code to round off the 1.4 lotsi multipier to actually Ordersend first order .10, second order .10, third order .20, fourth order .30, fifth order .50, etc.

    This doubles it

    lotsi = 0.1;
    else
    lotsi = 2.0*max_lot_s;

    and if FXDD would allow it this would increase it by 1.4

    lotsi = 0.1;
    else
    lotsi = 1.4*max_lot_s;

    but they don't and double is too much!
    Can you help? Thanks
    Bill
    Last edited by BillR; 02-14-2009 at 22:40.

  2. #12
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by BillR View Post
    Additional update....Removing the code seems to have Hidden S/L working.....but do see Error 4111 ...Also as this is using Martingale type and the lotsi = .10 The lot sizes on FXDD only allow .10, .20, .30 .40 etc.....and I'd like to have the progression not at double but just at 1.4 or 1.5 times. ie. .10, .14, .19, .27 I know they don't allow it at FXDD so I'd like to have the code to round off the 1.4 lotsi multipier to actually Ordersend first order .10, second order .10, third order .20, fourth order .30, fifth order .50, etc.

    This doubles it

    lotsi = 0.1;
    else
    lotsi = 2.0*max_lot_s;

    and if FXDD would allow it this would increase it by 1.4

    lotsi = 0.1;
    else
    lotsi = 1.4*max_lot_s;

    but they don't and double is too much!
    Can you help? Thanks
    Bill
    You have to use the NormalizeDouble function.

    In OrderSend(..., replace lotsi by :

    NormalizeDouble(lotsi,2)

  3. #13

    Default

    Hi Funyoo,
    When testing the Hidden Stoploss I used Longs only....when testing Shorts only I don't get any orders generated. I don't think the error is in the Hidden code you entered....I believe it to be somewhere else in the code. Do you see my error?
    Thanks again, Bill

  4. #14
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by BillR View Post
    Hi Funyoo,
    When testing the Hidden Stoploss I used Longs only....when testing Shorts only I don't get any orders generated. I don't think the error is in the Hidden code you entered....I believe it to be somewhere else in the code. Do you see my error?
    Thanks again, Bill
    Strange, it works for me.

  5. #15

    Default

    Thanks Funyoo,
    When Backtesting Shorts "ONLY" it doesn't work....when testing "Long and Short", or "Longs only" it works great. The Double Normalize worked fine too.... I will be " Buying Funyoo coffee" at the top of the page....I really appreciate your sharing and teaching. Thanks again, Bill

  6. #16

    Default

    Funyoo,
    Do you see the error 4111 ??
    Thanks Bill

  7. #17
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by BillR View Post
    Funyoo,
    Do you see the error 4111 ??
    Thanks Bill
    Yes, you can ignore it. That means that shorts are not allowed (due to the expert properties).

  8. #18

    Default

    Hi Funyoo,
    I'm not sure why....but I can only get it to work if the multiplier is 1.5. (or 2) It just creates orders for .10 when I change the number of either the

    else
    lotsi = 1.5*max_lot_b;

    and/or the

    tic = OrderSend(Symbol(), OP_BUY, NormalizeDouble(lotsi,1.5), Ask, slip, Ask - (sl)*Point, Ask + (tp + 25)*Point,
    " ", m, 0, Yellow);

    to 1.4....or 1.3, 1.2 etc
    (I'm also changing the OrderSend Op_Sell)

    Were you also able find the error in the "Shorts ONLY" true not creating any orders??


    Thanks again for teaching/helping!!
    Bill

  9. #19
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by BillR View Post
    Hi Funyoo,
    I'm not sure why....but I can only get it to work if the multiplier is 1.5. (or 2) It just creates orders for .10 when I change the number of either the

    else
    lotsi = 1.5*max_lot_b;

    and/or the

    tic = OrderSend(Symbol(), OP_BUY, NormalizeDouble(lotsi,1.5), Ask, slip, Ask - (sl)*Point, Ask + (tp + 25)*Point,
    " ", m, 0, Yellow);

    to 1.4....or 1.3, 1.2 etc
    (I'm also changing the OrderSend Op_Sell)

    Were you also able find the error in the "Shorts ONLY" true not creating any orders??


    Thanks again for teaching/helping!!
    Bill
    Hi BillR,

    Yes me too. The code tries to enter first a buy order.

    Instead of using the expert properties, you should use booleans directly in the code :

    extern bool OnlyBuy=false;
    extern bool OnlySell=true;

    Then :

    if(OnlyBuy)OrderSend(Symbol(), OP_BUY...
    if(OnlySell)OrderSend(Symbol(), OP_SELL...

    For the multiplier, it comes certainly from the broker as it works for me.

  10. #20

    Default

    Hi Funyoo,
    Yes, I believe the "Multiplier" to be broker dependent....FXDD "Demo" allows anything, but the "Live" account restricts....
    I'll read up/experiment on using extern bool.
    Is this the proper syntax??
    (I assume in order for the program to work both "Shorts" and "Longs" you'd have to now say "True" for both "Longs Only" AND "Shorts Only".

    tic = if(OnlyBuy)OrderSend(Symbol(), OP_BUY, NormalizeDouble(lotsi,1.5), Ask, slip, Ask - (sl)*Point, Ask + (tp + 25)*Point,
    " ", m, 0, Yellow);

    tic = if(OnlySell)OrderSend(Symbol(), OP_SELL, NormalizeDouble(lotsi,1.5), Bid, slip, Bid + (sl)*Point, Bid - (tp + 25)*Point,
    " ", m, 0, Red);

    Thanks again,
    Bill

Similar Threads

  1. Hidden take profit idea
    By logan113 in forum MQL programming
    Replies: 3
    Last Post: 07-30-2017, 11:36
  2. hello can you help me to find Hidden trailing stop
    By m4hfoud in forum Trading discussion
    Replies: 0
    Last Post: 11-08-2015, 22:28
  3. The hidden face of the Moon
    By fxtester in forum General discussion
    Replies: 1
    Last Post: 02-27-2015, 18:13
  4. Hidden SL & TP
    By jidonk in forum MQL programming
    Replies: 2
    Last Post: 04-20-2009, 17:35

Tags for this Thread

100, add, backtesting, broker, change, demo, expert, funyoo, guide, high, learn, live, magic, magic number, martingale, mq4, programming, sells, stop, stoploss, test, time, trailing

Posting Permissions

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