set stop loss in profit region when in profit

Forums ProRealTime English forum ProOrder support set stop loss in profit region when in profit

Viewing 15 posts - 1 through 15 (of 16 total)
  • #162496

    hi,

    anyone know how to code set stop loss in profit region when in profit?

    thank you

    #162498

    You need to use pending a STOP order.

    Example to set SL at breakeven + 10 pips, after profits have reached 50 pips:

    (not tested)

    1 user thanked author for this post.
    #162505

    can someone explain why I exit there?

    I’m not suppose to have a stop loss in the loss region

     

    thanks

    1 user thanked author for this post.
    #162507

    sorry problem solved. the reason why it stopped because the backtest period ended where it stopped.

    #162514

    Be warned that pending orders expire each bar and you have to place them again and again, if needed.

    Lines 9-10 will only be executed the first time.

    You should place them outside that check (like my example), otherwise you SL will placed correctly when 10 pips are reached but, if not hit and the next bar profit decreses to 6 pips, it won’t be placed at all!

    #162645

    hi, i want to put stoploss at 0 when profit is 5 pips above the positionprice and move to 5 pips in profit when it is 10pips above the positionprice. can you check my codes if i have done that? thank you

     

    #162647
    #162649

    does not seem to trigger the stop loss i have on 5 pips above position price.

    #162652

    solved it

    #162659

    Tell us then please … stories without endings are not good for sleeping!? 🙂

    #162704

    change line 12 to

     

    #162705

    but for going short it does not work. it opens and closes immediately and the stoploss variable is always zero.

    anyone got any ideas?

     

    1 user thanked author for this post.
    #162706

    seems like it worked when i changed line 2 to stoploss=2 because i have spread =2 when i backtested

    1 user thanked author for this post.
    #162707

    Obviously when going short prices and stop losses are reversed. So the calculations in lines 7 and 11 need to be reversed.

     

    2 users thanked author for this post.
    #179088

    Thanks – very useful to code this to minimise losing any initial capital.

Viewing 15 posts - 1 through 15 (of 16 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login