Trigger Trailing SL if target is met

Forums ProRealTime English forum ProOrder support Trigger Trailing SL if target is met

Viewing 15 posts - 1 through 15 (of 69 total)
  • #198152

    Hi

    I now use this in one of my programs

    SET TARGET pPROFIT 425

    Is there a way to make it so if 425 is hit my position is not sold but a trailing stoploss kicks in?

    #198215

    Simlply remove SET TARGET pPROFIT 425 and append this code snippet to your strategy. You only need to set the TRAILINGSTART (I set it to 425 as you rquested) and the TRAILINGSTEP (the pace at which the trailing stop will be updated):

     

    1 user thanked author for this post.
    #198266

    Tank you Roberto for your fast answer.

    I have put in the code in one of my long robots and one of my short, but the results I get from backtesting makes no sence. For example changing the trailingstep from 5 to 6 could change the backtesting results by 40% and that is just not possible with such a small change, I trade the DAX and 1 piont is nothing. Every number I used as trailingstop gave a worse result the just useing target profit. I even tried to set trailingstep to 0 to see if I would get the same results as just “SET TARGET pPROFIT 425” and it did not give the same result.

    If you have any ide where I went wrong it would be much appreciated.

    #198276

    Optimise the start and the step using …

    Start:    min 25  max 500 increment 25

    Step   min 10 max 100 increment 10

    Tell us how you get on

    1 user thanked author for this post.
    #198299

    Tried both my short and long with alot of different numbers. My short gave great results where all test improved backtesting with 5-10%, but the long gives alot of strange numbers.

    Made a matrix in excel and attached

     

    #198306

    The first one is my short that is working fine, and the second one is my long that I have problems with.

    #198310

    You still have SET STOP pLOSS 165 in yuor Short so how do you know exits are not due to SET STOP pLOSS 165?

    It is quite time consuming going over trades and only yourself will have the motivation.

    Enter as a  last line of code …

    GRAPH newSL as “trailing”

    and try and work out what is happening re exits … zoom in 1 or 2 trades and look at price levels together with the line for NewSL and fit it altogether in your mind … it can be interesting and enlightening! 🙂

     

     

    1 user thanked author for this post.
    #198312

    Yes this is really fun, and having you guys help is priceless. I have one more Q before I dive deep in grafs and numbers, that is close to my other Q.

    I have this 3th robot that end like this

    Is there some way to make c2 to not trigger a “sell at market” but to trigger a Trailing stoploss?

    #198313

    at the c2 level, (sry)

    #198319

    You cannot have twice the same code, as it’s read sequentially and the second one will override the first one.

     

    #198320

    Try this …

     

    #198322

    Tank you for taking your time to help me. In this one I’m not intrested in 425 starting point, but would like it to start trailing at c2. Would this work, just changing 425 to c2?

     

    #198323

    Would this work, just changing 425 to c2?

    No, because C2 can only be True / 1 or False / 0.  You can’t put 1 or 0 in place of 425.

    c2 = (indicator3[2] CROSSES OVER indicator4[2])

    1. If  indicator3[2] CROSSES OVER indicator4[2]  then C2 = True / 1.
    2. If indicator3[2] CROSSES OVER indicator4[2] does NOT occur then C2 = False / 0.

    1 user thanked author for this post.
    #198333

    Ok ,but how would I then go about if I want a trailing stop to start at just that level where  indicator3<span class=”crayon-o”>[</span><span class=”crayon-cn”>2</span><span class=”crayon-o”>]</span> <span class=”crayon-st”>CROSSES OVER</span> indicator4<span class=”crayon-o”>[</span><span class=”crayon-cn”>2</span><span class=”crayon-o”>]? Is it possible to  store this value in a constant that I can later use in “trailingstarts?</span>

    #198334

    I want a trailing stop to start at just that level

    To achieve above, I provided you with the code in the post below

    https://www.prorealcode.com/topic/trigger-trailing-sl-if-target-is-met/#post-198320

    1 user thanked author for this post.
Viewing 15 posts - 1 through 15 (of 69 total)

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