Question how to move stoploss to neut?

Forums ProRealTime English forum ProOrder support Question how to move stoploss to neut?

Viewing 6 posts - 1 through 6 (of 6 total)
  • #154267

    Hell0,

    I am working on my backtest code for EUR/USD.  To makes things easy I only talk about LONG positions!
    My buy is when the average[20] crosses over average[50]. I work with a fixed target of 10 pips and original stoploss at the lowest of the last 5 bars. BUT after a high has reached the 4 pips, I want to move the stoploss to neutral, which means the buy price. That last thing doesn’t work.

    How do need to describe this?

    Thanks a lot, Marc

    #154273

     

    #154276

    You are mixing prices with pips.

    StopLoss  is a price, while SET STOP PLOSS requires pips, with Dax your SL would become 13700 pips, with Eur/Usd just a little more than 1 pip.

    Try replacing line 15 with:

    But I think the new stoploss would be set from PositionPrice, not high, so it wouldn’t be a breakeven.

    Using a pending Stop order might be a better solution.

    Let me know if the above doesn’t work.

     

    #154285

    Thanks Xorandnot,

    It looks logical, though, when I backtest, it doesn’t do what I expect it will do. I changed the original SL to a fixed numberof 4 pips, because I see that it didn’t take the stoploss at the lowest low from the last 5 candles as descibed befor. But even then, it doesn’t move the SL to neutral after the price has reached 4 pips.
    See the image.
    I know it has to do with the order in my programming.

    #154291

    Thanks Roberto,

    Yes of course, I mix pips and price. Not good 🙂 I use EUR/USD, 600 ticks

    But still… 2 things don’t work in my coding.
    1. When BUY then I want the stoploss below the lowest low form the previous 5 candles. The code like down here doesn’t work like that.
    if c1 then
    BUY 1 contract at market
    stoploss = lowest[5] (low)
    endif

    2. When after BUY the price has reached 4 pips above the BUY, then I want the SL moved to neutral.
    I have changed my line 15 the way you suggested, but that doesn’t seem to work.

     

    #154294

    4 pips might be too few, check with IG what’s the minimum required.

    At line 9 you should add AND Not OnMarket to your conditions, so that your calculation is  not made after entering a trade since this makes your SL to move each candle.

    A pending stop order, similar to the one suggested by  XorAndNot might be useful.

     

Viewing 6 posts - 1 through 6 (of 6 total)

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