How do you Optimise ATR Stops Around Price

Viewing 7 posts - 46 through 52 (of 52 total)
  • Author
    Posts
  • #82501 quote
    Nicolas
    Keymaster
    Master

    Do not change any code I provided. Repeat after me:

    1. I will download the code Nicolas has provided
    2. I will import it and overwrite the existant files
    3. I will NOT CHANGE ANYTHING IN THE CODES
    4. I will only optimize the p2 and the n value
    5. I will come back here to say everything is working fine.

    Sound like a prayer 🙂

    (I only used p3 instead of p2 because

    Don’t! p3 is used to define another line of the indicator, it is useless YOU ARE NOT USING IN YOUR STRATEGY! p2 is the only variable that set the “dev” line of the DEV STOP LISSE indi. At that point I think you are confounding the name of the line with the variable used to set its standard deviation. Sorry to seems rude, but I feel that I’m near to giving up.. 😆

    #82525 quote
    Bard
    Participant
    Master

    Everything is working fine! Kcuf! Of course! I left the “dev” in the system code, within the ignored’s, at the dev stop 2.2 position… When I’ve optimised this value manually it sticks out like a sore thumb because it’s labelled “indicator” and I’ve manually moved it around tons of times between the ignored values and tested it. Somehow being called “dev” did exactly what you said, “confounding the name of the line with the variable.” “Dev” just became invisible.

    The other confusion came in this thread about REM’ing all the indicator variables code or just the variable your optimising, which is what I mistakenly thought I was meant to do hence “//p3” and “//n.” I see now that you’d mentioned that the indicator code is ALL // REM’d out and that it’s the strategy optimisation variables window that determines if a value from the indicator is fixed or optimised. 

    D’oh! https://www.youtube.com/watch?v=SVBR3mo9RKA

    You’re a star @nicolas, thanks again, now I can start optimising exits on all my favourite instruments and examine this exit strategy properly. It’ll also be good to see how it ties in with John Ehler’s indicators. For me this is the most logical, well researched and tested exit system I’ve come across in 13 years of trading/research.. and to think for years I was using a 10% capital stop when I was successfully scalping spot forex.

    Here’s the Excel Optimisation analysing Gain v’s ATR periods and Gain v’s Dev Stops. (ps/ Date range Jan 2015. to June 2017 not June 2018)
    The ATR result was surprising, Kase uses a 30 day period:

    Nicolas thanked this post
    #83473 quote
    Bard
    Participant
    Master

    Okay don’t have a heart attack @nicolas! This post is not about me not being able to optimise the Kase Dev Stop, (again). (-:

    However… I was wondering is it possible to optimise the bandedge of the Ehler’s Universal Oscillator if I’ve coded the Kase Dev Stop to use Ehler’s oscillator to flip the Dev Stops either above or below the price series (instead of using Mov. Averages or SAR)?

    I tried a system just now that has this new Dev Stop exit indicator and wanted to optimise the bandedge that is now part of it. The system has entries via Kase’s Peak Oscillator and exits via a Kase (SAR based) Dev Stop. You saw that system and warned of potential large drawdowns if the Peak Oscillator gets you in on the wrong side of a trend and the Dev Stop doesn’t get you out in time.

    The Kase Dev Stop has been modified to remove the moving average crossovers or SAR and now includes Ehler’s Osc code, so as to flip the Std Deviation lines above or below the price series:

    //PRC_KaseDevStop v3 | indicator
    //29.06.2018
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //translated from MT5 code version
    
    //--- settings
    inpDevPeriod= 30// Dev-stop period. // Set Default = 20 Set to 30, to allow for the data to have a greater statistical significance.
    
    //inpFastPeriod = 21// Dev-stop fast period
    //inpSlowPeriod = 34// Dev-stop slow period
    
    //Default = 10 and 21 day mvg - if you want the Stops to be faster use 5 and 21 day or a 21 and 34 if you wanted a slower flip.
    
    inpStdDev0= 0.0// Deviation 0
    inpStdDev1=1.0// Deviation 1
    inpStdDev2=2.2// Deviation 2
    inpStdDev3=3.6// Deviation 3
    inpStdDev4=4.5// Deviation 4
    inpStdDev5=6.0// Deviation 5
    //--- end of settings
    
    pricc=customclose
    
    once price=close*100
    
    indicator1, ignored = CALL "Ehler's Univ Osc SuperSmoother"
    c1 = (indicator1 > 0.0)
    
    If c1 then
    trend=1
    else
    trend=-1
    endif
    
    if trend<>trend[1] then
    if trend=1 then
    price=high
    else
    price=low
    endif
    endif
    if trend>0 then
    price=max(price,high)
    endif
    if trend<0 then
    price=min(price,low)
    endif
    
    mmax=max(max(high,high[1]),pricc[2])
    mmin=min(min(low,low[1]),pricc[2])
    rrange=mmax-mmin
    avg=rrange
    for n=1 to inpDevPeriod-1 do
    avg=(avg+rrange[n])
    next
    avg=avg/n
    
    dev = square(rrange-avg)
    for n=1 to inpDevPeriod-1 do
    dev=dev+(rrange[n]-avg)*(rrange[n]-avg)
    next
    dev=sqrt(dev/n)
    
    val0 = price+(-1)*trend*(avg+(inpStdDev0*dev))
    val1 = price+(-1)*trend*(avg+(inpStdDev1*dev))
    val2 = price+(-1)*trend*(avg+(inpStdDev2*dev))
    val3 = price+(-1)*trend*(avg+(inpStdDev3*dev))
    val4 = price+(-1)*trend*(avg+(inpStdDev4*dev))
    val5 = price+(-1)*trend*(avg+(inpStdDev5*dev))
    
    return val0 coloured(255,0,0) style(line,2) as "Warning Line",val1 coloured(0,0,250) style(dottedline,2) as "Dev Stop 1.0",val2 coloured(0,0,250) style(dottedline,2) as "Dev Stop 2.2",val3 coloured(0,0,250) style(line,2) as "Dev Stop 3.6",val4 coloured(0,0,250) style(dottedline,2) as "Dev Stop 4.5",val5 coloured(0,0,250) style(line,2) as "Dev Stop 6.0"

    I added the modified Kase Dev Stop (with Ehler’s Oscillator modifications) into this systems code:

    // Conditions to exit long positions
    ignored, ignored, ignored, ignored,dev, ignored = CALL "Kase Dev Stop Ehler + 4.5/6"[bandedge](close)
    c2 = (close CROSSES UNDER dev)//Dev Stop 4.5

    but got the familiar warning when I tried to backtest the code — please see screenshot #1 below.
    The thing is I have already added the bandedge variable to the Ehlers Universal Oscillator — as per screenshot #2 below, — so how do I get this system to optimise Ehler’s bandedge parameter within Kase’s Dev Stop?

    My reasoning is that an advanced (long/short) oscillator like Ehler’s should make the Kase Dev Stop perform better in trading systems that use this kind of exit rather than using Kase’s Mov. Averages or SAR’s. My other intention is to post here in this forum, some of the Kase Dev Stop optimisations results using a random entry piece of code to get the system to take trades and Kase’s Dev Stops to exit, so as to see the volatility profiles of assets like the Dow and S&P500 and £/$ and $/CHF, so we can know what’s best when it comes to choosing that crucial optimal (std deviation) exit distance.

    Cheers
    Bard

    #83488 quote
    Vonasi
    Moderator
    Master

    Bard – I have tidied up your post. I’ve deleted the duplicated image (and your post regarding this) and used the ‘Insert PRT Code’ button to make the code in your post more readable (please use this feature in your future posts that include code). There is an error message attached to your post so it seems you may have had some issues uploading images.

    #83497 quote
    Bard
    Participant
    Master

    Thanks @Vonasi, I did have trouble with the image. Btw, I always use insert PRT code and did this time, i even added a nice title, when I submitted my post it showed the code just as it appears above, i.e. separate and in it’s own field/box, within the main post? Why, how did the PRT code look to you?

    #83503 quote
    Vonasi
    Moderator
    Master

    Why, how did the PRT code look to you?

    The PRT code was just as normal text.

    Bard thanked this post
    #83888 quote
    Bard
    Participant
    Master

    Seems to be a glitch in the s/ware as I fixed the issue by simply duplicating the Kase + Ehler Dev Stop  indicator, renaming it and renaming it in the system code and now it is optimising Ehler’s bandedge fine without warnings about missing parameters it shouldn’t have been giving…

Viewing 7 posts - 46 through 52 (of 52 total)
  • You must be logged in to reply to this topic.

How do you Optimise ATR Stops Around Price


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Bard @brad Participant
Summary

This topic contains 51 replies,
has 4 voices, and was last updated by Bard
7 years, 3 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/16/2018
Status: Active
Attachments: 31 files
Logo Logo
Loading...