Breakeven- and trailing stop problem

Forums ProRealTime English forum ProOrder support Breakeven- and trailing stop problem

Viewing 15 posts - 1 through 15 (of 17 total)
  • #90086

    If a strategy uses a long and short criteria and a breakeven- or trailing stop there’s a problem.

    The case is that they both need a scenario where there’s no market position, and that “not on market” is used to enter a new position.

    If there’s no market position, the breakeven and trailing stop are correctly calculated when a position is entered.

    If there’s i.e. a long position and there’s short signal, the position should go the opposite.

    Problem is that the breakevenstop and trailingstop are not correctly calculated for the short position, there was never a “not on market” moment.

    As a result to have good strategy calculations, you need to enter “not on market” when the position enters the market, but then it ignores the short (opposite) signal and stays long.

    Not an obvious flaw, but one which can impact a strategy in a good or bad way.

    So my goal is:

    use correct values for breakeven and trailing stop, regardless if the position goes the opposite direction, so replace the “not on market” check for the breakeven- and trailingstop with something else.

    That “not on market” is not used as criteria to enter a new position, since it skips an valid opposite signal

    Any solutions?

     

    #90108

    When On Market is true you should save your TRADEPRICE in a variable each bar, so that as soon as you detect that the current value is different from that of the previous bar and On Market is still true it’s because there’s been a change and you can reset your Trailing Stop/Breakeven settings to the default ones for the new trade.

    Not tested but sounds logically correct.

    1 user thanked author for this post.
    #90116

    Or something like: (not tested).

     

    2 users thanked author for this post.
    #90183

    Thank you both. The easiest try was Nicolas suggestion so I tried that to start with.

    Focussed on the trailing stop.

    1. if I use “not on market’ as a criteria to enter a new position, a new position is not entered with a valid opposite signal. So removed “not on market’ to start with
    2. If the trailing stop is not used, a long signal goes short with a valid opposite signal
    3. But a trailing stop (0.35) is used but not reached, the long signal goes short, but short is immediately closed.  So there’s the problem and it’s in the trailing stop I believe.

    In de added suggestion, I tried with onmarket[1] or onmarket[0], or without onmarket but that made no difference

    tried with elsif, and with new if command no difference

     

     

    #90189

    I will try to replicate the problem with a clean test code and post later.

    #90201

    Here’s a clean code.

    To test the differences optimize tss and bes with 0 and 1 and see the differences with the added suggestion from Nicolas.

    It has no effect on breakeven.

     

    #90226

    Since you use market orders, you already know that you are on market, so why not flagging a variable when you enter an order. In this case, if new conditions are met to put a contrarian order on market, you can reset the breakeven variables at that point of the code.

    Bear in mind that code is read from top to bottom, conditions testing in the right order is crucial to solve your problem.

    #90263

    I made everything visual. Didn’t work on the flag yet. Maybe I’am missing something obvious.

     

     

    #90338

    It seems that adding the code from Nicolas and also splitsing the newsl and priceexit exits for long and short criteria worked.

    Thanks for the tips.

    1 user thanked author for this post.
    #90391

    Thank you Paul, do you have the complete code to share here, in order to have it for future reference please?

    #90441

    Here’s my final test code on the dax with working breakeven- and trailing stops in every scenario.

    It does matter that a trailing stop code is above the breakeven code.

     

    #90462

    How can I Forward Test the code immediately above.

    I get the results attached so it’s well worth a Fwd Test, but I can’t // Rem out all the GRAPH entries without screwing the code up.

    Am I reading this all wrong and it’s not meant to run as an Auto-System??

    #90466

    Try this:

     

    1 user thanked author for this post.
    #90467

    You can’t exclude graph by //.  But you can set display to 0 for each one to disable lines or try Vonasi suggestion.

    The lines are a bit annoying since they start at the bottom as vertical lines. As alternative you can set them to points.

    1 user thanked author for this post.
    #90475

    haha spot on Vonasi, works now, thank you!

    I had tried same / similar. but I can see now I was // out 3 lines too many in each code section with a GRAPH function.

    Also I’ve now noticed that I was optimising over 10k bars only!

    I was watching a good film at same time, but maybe I need to get my glasses from Australia! 🙂

    Actually below are what I wear on the computer when my eyes are tired!  Pinhole glasses (£4 or £1 from china!) ,,, think physics in school and pinhole cameras and that’s how they work!  Well worth checking out for anybody who’s eyesight is not what it used to be!

     

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

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