Trailing Stop and Breakeven codes

Forums ProRealTime English forum ProOrder support Trailing Stop and Breakeven codes

Viewing 11 posts - 16 through 26 (of 26 total)
  • #145411

     

    3 users thanked author for this post.
    #161799

    Hello,

    Can you explain me how to use this in prorealtime?

    I import the itf file to prorealtime and how can apply the trailing stop to my trade?

    Thank you

    #179812

    Hi everyone,

    I’ve spent hours reading through all this and I’m still finding it tricky to understand to be honest. Why does it seem so difficult to add a breakeven line of code? I’m very new to all this so do give me some patience haha.

    I am just practicing and getting the hang of coding bits so to keep it simple I have just created a code to buy when the RSI gets to 30 and have set a trailing stop too but what I want to do is simply add something like “breakeven level 10 pips above entry, exit the market if triggered ”

    Is this possible? All I see on here is 100 lines of code for something that seems so simple!

    Any help would be greatly appreciated, thanks guys

    #179813

    This is the code for breakeven from https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/:

    1 user thanked author for this post.
    #179818

    The above code is 1/4 of 100 lines!

    Is it still too much much?

    There you go with just 4 lines:

    That’s pretty short!
    Add this to your code and you will soon report that it will not always exit at the expected entry price + 10 pips.

    That’s because pending orders expire each bar, so when your profit is 30+ pips they will be placed, but if they are not triggered and the next bar your profit is, say, 29 pips, they will not be placed again and you may suffer an unexpected big loss! How can this be dealt with? By adding a few lines to RECORD that your trigger level has been reached, so the stop orders are to be placed again, next bar, even if by that time your profit is lower than that level:

    as you can see, a few more lines have been added, but they are still not so many!

    Well… there’s still a problem. Next trade NewSL will still retain the previous exit price and it may exit at an incorrect price,

    We need to add a few more lines to prevent this from happening:

    it’s no more just a few lines (and I did not add comments to make code easier to read),  it it can’t be done with less than that!

    100+ lines can easily be reached to add more sophisticated features.

    It’s like starting a car, you don’t need too much engineering, but then you have to add support for speeding up, then slowing down, then braking, then steering, then accommodating people, etc…

    2 users thanked author for this post.
    #179819

    That’s great thank you so much for the help. I really appreciate it!

    #184196

    Hi Paul, thank you for sharing your hard work. I was trying your latest code based on (%) and I keep getting the same values in backtest while varying “trailingpercentlong” and “trailingpercentshort” from 0.1 to 1 with an increment of 0.1. I kept accelerator and sensitivity fixed.

    Is there something I’m missing?

    Thanks

     

    #184215

    Try to make it way more extreme. Say up to +10%, starting even at a minus percentage. It is quite easy to have the same trade results with different trailing because of other factors (I did not check out that code).

    Obviously you did not forget to comment out the setting of the variables you now let vary in optimising, right ?

    1 user thanked author for this post.
    #184220

    Thanks Peter, just found out that this trailing module doesn’t react the same way in MTF. Say you’re executing a 5min Algo on a 1 min chart. If you leave everything under TIMEFRAME(5 minutes), this module doesn’t change. If you insert TIMEFRAME(DEFAULT) just before this module, it works fine.

    #213001

    hi every one, I hope your are fine,

    I discovered this code a few days ago that I’m trying to understand, I understood the first two parts well, the I’m going to concentrate on the MFE, however I don’t understand the logic of wanting to disable the trailing stop and the BE?

    Can someone explain to me why you want to deactivate these two options, because anyway if the trade doesn’t go our way there’s no point in giving it more chance or more room to manoeuvre, because in this case you don’t stick to your plan and you end up hoping, and that’s really not good for trading

    Translated with http://www.DeepL.com/Translator (free version)

    #213025

    Khaled

    What kind of crossing hull do you use ???

Viewing 11 posts - 16 through 26 (of 26 total)

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