How do you Optimise ATR Stops Around Price

Forums ProRealTime English forum ProOrder support How do you Optimise ATR Stops Around Price

  • This topic has 51 replies, 4 voices, and was last updated 5 years ago by avatarBard.

Tagged: ,

Viewing 15 posts - 31 through 45 (of 52 total)
  • #80539

    There is still something wrong as all your optimized strategies show the same negative results. I believe that your settings are still in the indicator code. I have no time to test it now, so please review all your indicators code to be sure no settings are written in the code and are only present in the external variables settings.

    1 user thanked author for this post.
    #80551

    Hi @nicolas, I’ve REM’d out all the p1 to p6 values in the indicator and the strategy code (where I’d also added the indicator code). It’s optimising but without profits when profits were achieved manually adjusting the Dev Stops values using std deviations of 1 to 6…
    (I’ve put all the p values in bold)

    To clarify, is the Kase Dev Stop code being called from the code where I’d added the indicator into the strategy, or from the actual PRT indicator code when I first added the indicator originally?

    I see that the Kase Dev Stop indicator name in the strategy actually includes the p values in square brackets –  I’m assuming this maybe where the issue is, but am unsure how to add strategy variable optimsation values (via the spanner) without the strategies indicator name being modified and including those p values?

    Thanks again,

    Strategy Code:

    Indicator Code:

     

    #80653

    You have completely messed up the indicators code, there are no other deviations lines than the dev0 one, that’s why the variables p1 to p6 have no effect when optimizing because the lines that are using them are no longer present in indicators. Why did you commented all other “dev” variables in the indicators?

    #80679

    The problem arose from having the indicator code placed within the strategy. Then without clarity as to whether the optimisation works from that specific indicator code (within the system) or from the external indicator.
    Why? Because by following the suggestions in the order they came in on this thread, when I REM’d just the p1 – p6 values (posted below) in the strategy and in the indicator code it didn’t make the slightest bit of difference, the optimisation kept producing a loss when I know the reality is this strategy works with every Dev Stop setting… so as a “last ditch attempt” in what has been a long process trying to get this to optimise I REM’d anything with P values in it. Of course I can see the mistake now in the clear light of day. No doubt the home front situation (I’m a full time carer) and lack of sleep caused this current “mess.”

    Cheers
    Bard

    //p1=1.0
    //p2=2.2
    //p3=3.6
    //p4=4.5
    //p5=6.0
    #80682

    Ok, don’t worry I’ll do it for you. Hold on 🙂

    1 user thanked author for this post.
    #80691

    PFA the strategy and all indicators included. Just import it and overwrite all files when prompted. I cleaned up the code to be faster to optimize.

    There were 3 major problems:

    1. the p1-p5 and n settings in the strategy were not in the right place (n was before p1 while it needs to be before as the real settings of the indicator).
    2. some old indi code was still in the strategy ?
    3. since you are only using the dev2 line to exit orders, it is not necessary to optimize all other settings than p2, that’s why you had a lot of strategy showing the same results with different settings of p1;p3:p4:p5
    #80727

    Thanks, really appreciated @nicolas, this head cold I’ve had is not helping either!
    I’ve re-read the entire thread. To clarify, “n” must be after the the p values in the strategy, why is that? (you used the word “before” twice in you’re suggestion above).

    All the strategy and all indicators included? I only have your prc (faster) Kase itf strategy. My original Kase Dev Stop Lisse indicator still has the variables p1 to p6 and the “n” variable as it always had.

    I have managed to get it to optimise. For anyone reading this, I went to the strategy and amended the exit code on line 13:

    // Conditions to exit long positions
    ignored,ignored,dev,ignored,ignored, ignored = CALL “Kase Dev Stop Lisse +SAR+4.5/6” [p2,n]

    This is correct right Nicolas?

    I used the strategy optimisation (variable optimisation spanner) and used 0.1 to 7.5 std deviations in steps of 0.1 and “n” periods 1 to 33 in steps of 1.

    In the Kase Dev Stop indicator the variables used were “p2” (2.,2 std devs) and n = 30 default. In the code I REM’d out these settings to optimise them:

    //Settings
    //n=30
    p1=1.0
    //p2=2.2
    p3=3.6
    p4=4.5
    p5=6.0

    Here is the result: pls see Swissy optimisation results image.

    53 trades, Gain £45k, 64% winning trades, gain/loss 3.24, optimised result is Dev Stop = 5.1, period = 9 for the 4 hr Swissy, and with a 17.8% Drawdown (4th Jan 2014 to 17th Sept 2018) 

    Conclusion:

    Dev Stop 3.6 is meant to represent from extensive data testing on multiple asset classes by Cynthia Kase, the “get out now” exit point because there is 99% chance the price will continue to get away from you and not reverse back to break even. The results is Dev Stop of 5.1 standard deviations is large which as Kase told me is when the market is more “erratic.” I don’t regard the Swissy as “erratic” like the Dow Jones for example but the 15th Jan massive move in the CHF due to the SNB unpegging against the Euro will be a factor. The other thing to notice is the best period to use was 9 in this optimisation. 30 periods is usually the minimum number of samples you’d want to include to have a statistically significant result that you can rely on going forward with an auto system. Ditto the number of trades.

    This Excel, gain versus Dev Stop, shows a great level of stability with this particular entry/exit pairing for this asset: Pls see screen. NOTE: This is still a mean reverting system so you might want to code in a hard stop in case the entry gets you in on the wrong side of a sustained opposite directional move.

    Thanks, @Nicolas, @Vonasi, @ GraHal, Phew.. got there in the end! 

    #81313

    Apologies @nicolas but I have just spent 2 hours trying to replicate this optimisation result described above (£45k) and I keep getting £25k profit on every line of the optimisation result for lots of different Dev Stop p-values – pls see screenshot. All I’ve done since last week is swap the p2 for p3 as a variable in the strategy and indicator. I reloaded your itf but still not getting a diverse range of profits like in the screenshot in my post directly above this one.

    Please could you clarify that #1 major problem you listed above in your last reply:
    “the p1-p5 and n settings in the strategy were not in the right place (n was before p1 while it needs to be before as the real settings of the indicator).”
    — I took the indicator eode out of the strategy so I’m not sure if this p-position and n-position is relevant. Thanks again.

    #81566

    I have again deleted and reimported the original PRC_Kase Strategy and can only obtain the exactly the same profit with the optimisation despite the optimisation showing lots of different p-values as per the screenshot above this post. The indicator has the correct variables added (p3, n) and the strategy code has these stated at the end of the indicator name and has the variables at the top of the strategy window.

    I wonder if I have a software issue? I have strange things, like I’ll be backtesting using the same dates and then out of nowhere the system tells me I need to change the date range… I did a similar optimisation on the Clenlow Plunger strategy and it only optimised the inpFastPeriod moving average as all the values for the slow period were returned as “1”… or I am editing an indicator and then I get a repeated flashing save message ten times asking me if I want to save or discard changes.  Of course in this case it’s more likely to be tiredness and user error. Any thoughts @nicolas,

    Cheers
    Bard

     

     

     

     

     

     

     

    #82093

    There was a variation of where a “+” sign was placed in the name of the Kase Dev Stop indicator called by the system and that called a very similar version of the indicator but one which didn’t have the correct variables for optimisation… however the results of different Kase Dev Stop exits (on the 1 hours Swissy ) still produces multiple results with the same profit, eg £10,486, for many different p3 std deviation settings (I tested std deviations from 0.1 to 7.5 in steps of 0.1)? Pls see screen: Does anyone know why it is doing this? That top line of £10k profit in the Excel reflects the p3 column to the left, in that there are a wide range of p3 std deviation values that ALL make £10k? Huh?

    #82291

    I don’t mean to take up your valuable time @nicolas because I know you’re busy and particularly when it seemed this optimisation was resolved and “in the bag!” ….and yet which p3 Std Deviation stop should I use: p3=5.5 or p3=1.2 are the first two results (Screenshot A (iii))? They seem very wide apart? And if I want to use these exit stop results on the Swissy, which one is best? 

    Please see Screenshots A (i)(ii)&(iii), they’re shots of the code you kindly created for me to upload.

    I also posted 3 screens (B (i)(ii)&(iii)) of the optimisation without using n=number of periods (in the Kase Dev Stop strategy and indicator). Same profit but multiple values of p3? Please note, when I added the n value back to the strategy and indicator (to put it back to your original coding), the std deviation p3 results were different to the original optimisation (A (iii) when I had 5.5 and 1.2 as the first two optimisation results because they now show 6.3 and 5.9,.. that’s what the A (iv) screen is shows.

    Thanks once again for your patience and help, always appreciated.

    #82321

    Please find attached, a more detailed explanation of my last message. I did not launch any optimization, but I took the time to make the attached picture in order for you to have a perfect understanding of what have been done and how you should make the optimization.

    • In the strategy and indicator codes and also in the optimization window, all the settings are sorted in the same order, which was not the case in your initial version.
    • “dev” is the only line called by the strategy, it is the only one used to close an order currently running, I made it as a big dotted fat line in the “lisse” indicator. This line is calculated with only 1 deviation parameter which is set by the p2 setting in the indicator. So it is only necessary to optimize this value, not the others.
    • You can also optimize the “n” variable which is the ATR period (or global indicator period to be more clear), or set it as a fixed value of 40 for instance and optimize only the p2 deviation setting around it.

     

    #82404

    Thanks very much for taking the time to make that screenshot and explain each part @nicolas. I have used it for the optimisation of my strategy, the indicator and the variables setting in the optimisation window. (The only changes I’ve made are to use a different name for the indicator and use p3 instead of  p2).

    In my optimisation I was expecting lots of different £ profit results with different Dev Stop values snd that I’d choose the Dev Stop value corresponding to the highest profit (not a good choice without taking into account drawdown, risk/capital, etc) – this isn’t the result though, as my attached screenshot shows.

    The top 5 Dev Stop optimisation results range from 4.4 to 9.2, ALL with profits of £33,347k (and a drawdown of 19%).

    Which Dev Stop do I use going forward and why do you think are all the profits the same?

    Cheers,
    Bard

    #82419

    Bard, I think you did it wrong again 🙂

    Why are you optimizing the p3 variable which is used to set a line that you don’t even use in your strategy?!

    Please use the codes I added in one of my previous post, and optimize p2 and n only.

    #82498

    Cheers again @nicolas, I see you have different profits/losses and dev stop values. I’d kill to get an optimisation result like that! I’ve done a hundred plus optimisations before with no problem. I’ve sat here for two hours looking at this thread, your PRC code and doing optimisations trying different things to get it to work but I just get lots of identical profits with lots of different dev stop p values…

    I’ve optimised only p3 and n in my strategy as my image indicatorstrategy.png shows yesterday. The p2 value is now fixed and p3 is optimised between 0 and 10 in steps of 0.1 std deviations. I have REM’d the p3 and n values in the indicator. P3 (and the other p values) are written next to the indicator name in the strategy (as per your image above) and in the optimisation window with p3 (and n) set as “optimised.”
    (I only used p3 instead of p2 because that is – in a typical Kase Dev Stop – the last of four lines and the 99.7% point of no return line. It’s also the middle value and easy to spot quickly when including dev stop 4.5 and 6.0).

    I still am unsure why it hasn’t optimised, it should work and yet it doesn’t?

    I looked at the PRC strategy you uploaded a while back and had wondered why all the p values from p1 to p5 are all being optimised in the optimisation window and not just p2 (or p3) and why the indicator has all the p values REM’d out? (I know including all the p values was originally my attempt at optimising).

    The PRC strategy didn’t work for me (once I REM’d the p2 and n values in the indicator code and optimised the p2 and n in the variable optimisation window), in that it gave a profit of £8,612k on the 4 hour Swissy, (4th Jan 2015 – 29th June 2018), when I know manually using different dev stops made more profit as the screenshot I posted earlier shows: https://www.prorealcode.com/topic/how-do-you-optimise-atr-stops-around-price/page/2/#post-80533. 

    I notice you left all the p values and the n value in the uploaded PRC strategy code written next to the indicator name that is being called. 

    Why then doesn’t the optimisation work when everything is REM’d and optimised in the same manner albeit switching everything that happened to p2 now for p3 as in your optimisation image yesterday (10th Oct)?

    Does your indicator code look like my code and variables? Pls see screenshot below.

    Thanks once again for your patience because I realise to you this must look simple but I’m just going round in circles here and I genuinely can’t figure it out.

    Ps/ Pls ignore first image. See “//p2 image.”

Viewing 15 posts - 31 through 45 (of 52 total)

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