Move stop loss level to opening level

Forums ProRealTime English forum ProOrder support Move stop loss level to opening level

Viewing 12 posts - 1 through 12 (of 12 total)
  • #78262

    Hi there,

    I was wondering if somebody could help me out. I would like to have my stoploss moved to the level of entry as soon as price hits 70% of my target. This has to be implemented in my code. My code so far works really well. The code is shown below. It’s fairly simple: when the conditions are met, 1 contract will be bought. Stop loss lies 5 pips below the candle previous from entry, and target profit lies at the exact same distance.

    Now I just would like to have added that if the price moves in the favourable direction and reaches 70% of the target level (positionprice + (0.7*distancelong??), the stop loss will be moved from the original level to the level of entry (positionprice). Of course maintaing the same target profit level.

    Ik hope someone can help me out. Thanks in advance!

     

    Daniel (foxfutures)

     

    #78268

    To write code, please use the <> “insert PRT code” button, to make code easier to read and understand. Thank you.

    #78269

    There you go (not tested, though, let me know of any issue):

    Beware that line 8  will only be executed next bar, since ProOrder takes a bar to know it’s On Market. Also, PPROFIT doesn’t want a price, but the number of PIPS!

    #78270

    Thank you Robertogozzi, I was not aware of that. I hope this works better.

    1 user thanked author for this post.
    #78271

    The above line of your code is not correct Robert. Foxfutures wanted it at 70% of the target distance and not 70 pips.

    Also this line is wrong as it sets a price rather than a distance:

    I think this is what you meant to write:

     

    #78272

    Beware that line 8  will only be executed next bar, since ProOrder takes a bar to know it’s On Market.

    I’m not sure that is correct either. All the three orders will be sent to market, the buy, the target and the stop loss as at that time you are not ONMARKET which is one of the conditions.

    #78278

    Thank you for spotting my error about 70%, I misread it.

    As for TRADEPRICE, ProOrder will know it next candle, so I guess it evakuates it to ZERO, thus leaving DISTANCELONG as SL. I see you amended it.

     

    #78279

    I’m not sure that I fully follow you. At the time when the orders are placed on the market this bit of code will be ignored as you are not long on the market so the value of TRADEPRICE is irrelevant:

    At the close of the first bar you are now LONGONMARKET so  it checks to see if it is above the TRADEPRICE which is now a known value.

    #78281

    Foxfutures – you may want to consider using MTF for this sort of break even idea. I don’t know what time frame you are testing it on but if for example it is an hourly chart then price could go above your 70% threshold several times in that hour but then actually close below it so your move to break even would not be triggered. A faster time frame would allow you to trigger it as soon as the 70% threshold was hit – although at the cost of less data to back test on of course.

    #78282

    Line 6 of the original code was

    ProOrder will send it to the broker as

    which, in this particular case, may be working because he was adding a price to pips using PPROFIT.

    #78283

    Aaah! We are confusing each other – you wrote TRADEPRICE when you meant POSITIONPRICE and I was looking at my amended code where I had fixed that problem that you were trying to refer to!

    #78288

    Hi guys,

    Thank you both for your solutions and feedback. However, I am not a specialist and have trouble following you both completely, but you’ve helped me a lot.

    Thanks!

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

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