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 6 years ago by Bard.
Tagged: Cynthia Kase, Kase
-
-
08/16/2018 at 2:42 PM #78385
I posted this: https://www.prorealcode.com/topic/how-do-you-optimise-bands-based-on-price/#post-77380
a month ago and would still like to know how this achieved using the PRT platform.
Cheers in advance.
08/16/2018 at 3:27 PM #7839608/16/2018 at 6:14 PM #78410Sorry! Wrong link above. The request was actually posted a month ago: https://www.prorealcode.com/topic/optimisation-of-atr-dev-stops/
How do I “up” my own post?
(Have a few tech issues using Safari here on PRC – hence comment about not seeing the post when I first posted as it wasn’t in my Topics list and so I reposted it later that day.
I won’t double post again… Frankly I have no idea how you keep up with the myriad of single posts/comment threads here but appreciate that you do)08/17/2018 at 12:11 PM #78453Ok, so that is a triple posts! First time for me! 😆
To “up” your topic (being freshness), just reply to it.
When posting a new topic, be sure to have sufficient words in your title (at least 2 words).
I replied yesterday to the second one, link in the first post of this topic! (so confusing…).
1 user thanked author for this post.
08/17/2018 at 6:13 PM #78489“First time for me!” You and me!
My original post disappeared, so I thought better makes sure… then it reappeared later on a new log in.. ooops.
Then I reposted the same question 2 wks later.. ooops.Should I hand myself in to ‘Forum Etiquette’ jail?
Thank you for the optimisation tip @nicolas.
I was trying to do it from the Variable Optimisation spanner and also didn’t have the indicator code in the strategy.Now, when I add my (Stop and Reverse) Kase Dev Stop code posted here:
to the System code (Kase Peak Oscillator entry and Dev Stop exit) I am still not sure how to proceed?A lot of the indicator code needed to be removed with: “//” as “it’s not found” when I click on the backtest button.
If I try and “optimise” the Dev Stop 3.6 by adding the line with something like: p3=optimiseddevstop
I’m getting the same profit result when I know that using Dev 1.0 or Dev 2.2 makes a difference in the profit when running backtests.
Why do I get the feeling I’m going to be saying “D’oh!” when you explain what I’m doing wrong?
08/17/2018 at 6:15 PM #78491The123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsignored, ignored, ignored, ignored, indicator2 = CALL "Kase Peak Oscillator"c1 = (indicator2 < 0)IF c1 THENBUY 10 PERPOINT AT MARKETENDIF// Conditions to exit long positionsignored,ignored,indicator3,ignored,ignored, ignored = CALL "Kase Dev Stop Lisse +SAR+4.5/6"c2 = (close CROSSES UNDER indicator3)IF c2 THENSELL AT MARKETENDIF// Conditions to enter short positionsignored, ignored, ignored, ignored, indicator5 = CALL "Kase Peak Oscillator"c3 = (indicator5 > 0)IF c3 THENSELLSHORT 10 PERPOINT AT MARKETENDIF// Conditions to exit short positionsignored,ignored,indicator6,ignored, ignored, ignored = CALL "Kase Dev Stop Lisse +SAR+4.5/6"c4 = (close CROSSES OVER indicator6)IF c4 THENEXITSHORT AT MARKETENDIF// Stops and targets//SET STOP pTrailing 500 //OPTIMISED = 430//250 and anything over 300 to 500 tics)//Settingsn=30p1=1.0p2=2.2p3=optimiseddevp4=4.5p5=6.0difference=0Hg=highest[2](high)Lw=lowest[2](low)DTR=max(max(Hg-Lw,abs(Hg-close[2])),abs(Lw-close[2]))aDTR=average[n](DTR)for i=0 to n-1 dodifference=difference+square(DTR[i]-aDTR)nextdifference=difference/nsdev=sqrt(difference)dev0=close-aDTRdev1=close-aDTR-p1*sdevdev2=close-aDTR-p2*sdevdev3=close-aDTR-p3*sdevdev4=close-aDTR-p4*sdevdev5=close-aDTR-p5*sdevif dev0<dev0[1] and close>dev5[1] thendev0=dev0[1]endifif dev1<dev1[1] and close>dev5[1] thendev1=dev1[1]endifif dev2<dev2[1] and close>dev5[1] thendev2=dev2[1]endifif dev3<dev3[1] and close>dev5[1] thendev3=dev3[1]endifif dev4<dev4[1] and close>dev5[1] thendev4=dev4[1]endifif dev5<dev5[1] and close>dev5[1] thendev5=dev5[1]endifdev6=close+aDTRdev7=close+aDTR+p1*sdevdev8=close+aDTR+p2*sdevdev9=close+aDTR+p3*sdevdev10=close+aDTR+p4*sdevdev11=close+aDTR+p5*sdevif dev6>dev6[1] and close<dev11[1] thendev6=dev6[1]endifif dev7>dev7[1] and close<dev11[1] thendev7=dev7[1]endifif dev8>dev8[1] and close<dev11[1] thendev8=dev8[1]endifif dev9>dev9[1] and close<dev11[1] thendev9=dev9[1]endifif dev10>dev10[1] and close<dev11[1] thendev10=dev10[1]endifif dev11>dev11[1] and close<dev11[1] thendev11=dev11[1]endifif close>dev11[1] then//flag=-1elseif close<dev5[1] then//flag=1endifendif//if flag=-1 then//ind0=dev0//ind1=dev1//ind2=dev2//ind3=dev3//ind4=dev4//ind5=dev5//k=1//r=0//g=191//b=255//else//ind0=dev6//ind1=dev7//ind2=dev8//ind3=dev9//ind4=dev10//ind5=dev11//k=-1//r=255//g=128//b=0//endif//ORANGE AND LIGHT BLUE//return ind0 coloured(r,g,b) style(dottedline,2) as "Warning Line", ind1 coloured(r,g,b) style(dottedline,2) as "Dev Stop 1.0", ind2 coloured(r,g,b) style(dottedline,2) as "Dev Stop 2.2", ind3 coloured(r,g,b) style(line,2) as "Dev Stop 3.6", ind4 coloured(r,g,b) style(dottedline,2) as "Dev Stop 4.5", ind5 coloured(r,g,b) style(line,2) as "Dev Stop 6.0"08/17/2018 at 6:37 PM #78492To optimise variables in a strategy REM them out by typing // in front of them where their value is set and then click the spanner shown in my image and then enter the variable name and assign the start and finish quantities and steps you want to optimize over. Add multiple variables to do several at the same time – up to a limit.
1 user thanked author for this post.
08/17/2018 at 9:34 PM #78504Thanks @Vonassi I didnt know about the REM strikeouts.
However I get the same profit result of 15.427k (please see screenshot) which is wrong because I’ve seen different profits results by using different Dev Stops. i.e. I’ve individually tested which Dev Stop to use to produce the most profit for this system by manually moving the Dev Stop by changing Dev 2.2 (standard deviations) to Dev 3.6, by moving “indicator 6” code over to the right from:123// Conditions to exit short positionsignored,ignored,<strong>indicator6</strong>,ignored, ignored, ignored = CALL "Kase Dev Stop Lisse +SAR+4.5/6"c4 = (close CROSSES OVER indicator6)to:
123// Conditions to exit short positionsignored,ignored,ignored,<strong>indicator6</strong>,ignored, ignored = CALL "Kase Dev Stop Lisse +SAR+4.5/6"c4 = (close CROSSES OVER indicator6)Yet these screens show 15.427k profit for ALL the Dev Stops ranging from 1.0 to 6.0?
(I did try using “//” for all the Dev Stops for P1 to P5 – it just produces the same 15.427k profit figure).Cheers
Bard08/17/2018 at 9:52 PM #78507I’ve not been following the thread closely enough to understand all the ins and outs of it but if you see all the same results in your optimization then it is usually the fact that the different value has no effect on the result or you have the optimized variable still fixed at a value somewhere in the code.
1 user thanked author for this post.
08/17/2018 at 9:56 PM #78508Then it must be this: “you have the optimized variable still fixed at a value somewhere in the code” although I’m not sure where?
The Dev Stops are basically just like an ATR band being used as a Stop, so it’s like asking: how far away is the optimal distance from price so I know where to put my ATR band to maximise returns.08/19/2018 at 9:07 AM #78588“you have the optimized variable still fixed at a value somewhere in the code” although I’m not sure where?
Use Find (right click within the coding window) to search for the variable name … sounds like you have used the same name twice??
1 user thanked author for this post.
08/19/2018 at 8:33 PM #78609I can see another reference for the p1, p2 etc starting from line 87. Is that what is causing this Dev Stop not to be able to be optimised? Yet it is supposed to be possible?
Here is the full code a few posts further up this page @GraHal
https://www.prorealcode.com/topic/how-do-you-optimise-atr-stops-around-price/#post-78491
Cheers
08/20/2018 at 7:48 AM #78616Your ProOrder program don’t have sufficient information to know what to optimize. All the indicators declared at lines 5,13,21,29 don’t have settings. These indicators must have their settings set as external ones and not in their codes to be CALLed and optimized with ProBacktest.
For example, the settings for the “Kase Dev Stop Lisse +SAR+4.5/6” indicator should be REM or // like Vonasi said:
123456//n=30//p1=1.0//p2=2.2//p3=3.6//p4=4.5//p5=6.0and these settings added as external variables like explained in this video:
08/20/2018 at 3:19 PM #78657Cheers @nicolas, right, that makes sense why it wouldn’t work using “//” on all the variables as per Vonasi’s tip.
Now that I have an improved indicator with adjustable settings (as per the video above) and an optimised parameter set in the auto system (made in steps of 0.2 because 0.1 is too much to calculate/optimise), I get this warning when running an optimised backtest, please see screenshot ?
Ideally I’d want to just use one variable “devstopoptimised” or “p1” (with values ranging from 1 to 7) to test the whole range of values, from dev stop 1.0 (standard deviations) all the way up to dev stop 7.5 which is the widest stop used by Cynthia Kase… but that would alter the whole way that the Stop and Reverse SAR works in this indicator.
08/20/2018 at 3:39 PM #78660That’s normal since your CALL function is no longer valid. Now, if you want to call your indicator, you must embed the variables when you declare it:
1CALL "Kase Dev Stop Lisse +SAR+4.5/6"[p1,p2,p3,p4,p5]See CALL instruction in the documentation: https://www.prorealcode.com/documentation/call/
-
AuthorPosts
Find exclusive trading pro-tools on