Newbie coding Request – BB S&R
Forums › ProRealTime English forum › ProBuilder support › Newbie coding Request – BB S&R
- This topic has 24 replies, 4 voices, and was last updated 5 years ago by denmar.
-
-
05/15/2017 at 1:36 PM #35588
Just my attempt to emulate Volatility-Based Technical analysis as developed by Kirk Northington – see http://www.tradingtheinvisible.com/htm/resources.html
05/15/2017 at 4:42 PM #35615ok, so the code you have posted is incomplete, it only has the upper bollinger bands lines. That’s why I did not understand it very well at the first glance. My attempt is still buggy, I let you know if I can get it through .. soon .. or not 😉
05/15/2017 at 4:55 PM #35616This is a rough code, I don’t think it is completely accurate, because I can’t get to know if a Peak() must be consecutive to a Trough() or not (like zigzag..)
123456789101112131415161718192021222324252627282930313233343536373839404142434445//PRC_BBands S/R inflection (WIP)//https://www.prorealcode.com/topic/newbie-coding-request-bb-sr/percent = 0.3peakData=BollingerUp[20](close)troughData=BollingerUp[20](close)if barindex>20 then//Metastock Peak() functionif lastdottedline<=0 thenhigher=max(higher,peakData)endifpeakpercent=(higher-peakData)/highernewpeak=peakpercent>percent/100if newpeak and lastdottedline<=0 thenlower=peakDatalastdottedline=1lastpeak=peakDataendif//Metastock Trough() functiononce lower=troughDataif lastdottedline>=0 thenlower=min(lower,troughData)endiftroughpercent=(troughData-lower)/lowernewtrough=troughpercent>percent/100if newtrough and lastdottedline>=0 thenhigher=troughDatalastdottedline=-1lasttrough=troughDataendifatr40=averagetruerange[40]if lastpeak<>lastpeak[1] thenpeak1=lastpeakpeak2=lastpeak-ATR40endifif lasttrough<>lasttrough[1] thentrough1=lasttroughtrough2=lasttrough+ATR40endifendifreturn peak1 coloured(0,0,255) style(point,2),peak2 coloured(255,100,0) style(point,2),trough1 coloured(0,0,255) style(point,2),trough2 coloured(255,100,0) style(point,2)05/15/2017 at 5:48 PM #35621Hey Nicolas -fantastic. I’m sorry- I should have been more explicit in the beginning. I was willing to hack the other half of the code (and still am) once the one half was complete. I’m going to study this and will let you know soon. Once again – great,awesome – now just to see if it is doing the right thing. Merci.
05/15/2017 at 8:58 PM #35638Hi Nicolas
I have had a look a the indicator and it seems to be plotting about four bars “to late” and a little to high. (Although for some strange reason it seem to be a little to low on the chart you posted) For the purposes of comparison I have done the following:
- Plotted the upper BB in white (the lower is in blue – ignore)
- Drawn the peak lines in white – main as solid and 1ATR in dotted
- Drawn the trough lines in yellow – main solid and 1ATr dotted
By comparing the METASTOCK chart with the PRT one you will notice the discrepancy. I have drawn arrows to indicate more or less where the lines should be if they were correctly plotted.
Hope this helps. Thanks once again for your effort to date. Much appreciated.
05/15/2017 at 9:48 PM #3564605/16/2017 at 7:18 AM #3565910/22/2019 at 3:12 PM #110844I think the problem is that the values are correct and found at the right time but not plot in the past like it seems to be in MetaStock. I’ll have a deeper look ASAP.
hello did you get updates on this beautiful indicator?
10/22/2019 at 3:50 PM #11085511/27/2019 at 2:43 PM #113735Hi
I a revisiting this indicator but wish to replace the bollinger bands with code incorporating linear regression. However it just plots a value of zero. I substituted linear regression with the close and it plots just fine. Any help in resolving the code will be greatly appreciated.
The code posted is with the close (working). The first three lines need to be modified to substitute linear regression for the close.
The attached figure depicts:
TOP: Original code with Bollinger Bands (by Nicolas)
MIDDLE: LinearRegression (my modification, not working)
BOTTOM: Close (my modification, working)
LinearRegression not working1234567891011121314151617181920212223242526272829303132333435363738394041424344454647//LR= LinearRegression[14](Close)a = ExponentialAverage[20](Close) //(LR)StdDeviation = STD[20](Close) //(LR)Bsup = a + 2 * StdDeviationpercent = 0.3peakData=BsuptroughData=Bsupif barindex>20 then//Metastock Peak() functionif lastdottedline<=0 thenhigher=max(higher,peakData)endifpeakpercent=(higher-peakData)/highernewpeak=peakpercent>percent/100if newpeak and lastdottedline<=0 thenlower=peakDatalastdottedline=1lastpeak=peakDataendif//Metastock Trough() functiononce lower=troughDataif lastdottedline>=0 thenlower=min(lower,troughData)endiftroughpercent=(troughData-lower)/lowernewtrough=troughpercent>percent/100if newtrough and lastdottedline>=0 thenhigher=troughDatalastdottedline=-1lasttrough=troughDataendifatr40=averagetruerange[40]if lastpeak<>lastpeak[1] thenpeak1=lastpeakpeak2=lastpeak-ATR40endifif lasttrough<>lasttrough[1] thentrough1=lasttroughtrough2=lasttrough+ATR40endifendifreturn peak1, peak2, trough1, trough2 -
AuthorPosts
Find exclusive trading pro-tools on