Hi Everyone! I'm sharing an indicator I've scripted in hope that some mathematicians can help in turning the smoothing rules into an equation.
The script appears to work just fine as is (please let me know if you think differently).
I just think that a smoothing equation would allow more flexibility.
I've tried using Excel to create the equation, but it doesn't do a good enough job..
Paul Carroll also talked about using Adv-Dec data instead of closing price of the stock.
More on Haurlan can be read here
Please let me know if you have any thoughts. Enjoy!
The script appears to work just fine as is (please let me know if you think differently).
I just think that a smoothing equation would allow more flexibility.
I've tried using Excel to create the equation, but it doesn't do a good enough job..
Paul Carroll also talked about using Adv-Dec data instead of closing price of the stock.
More on Haurlan can be read here
Please let me know if you have any thoughts. Enjoy!

Ruby:
#Haurlan Index
#SOURCE: PN Haurlan - Measuring Trend Values & Paul Carroll - Haurlan Index [TASC]
#Developed by PN Haurlan to measure how far the current price has departed from the trend incorporating adjustments based on Proportional Control (used in missile guidance)
#Book Link: https://www.mcoscillator.com/download/special/McClellan_MTAaward.pdf
input lenShort = 5; #HINT lenShort: select a stabilization period between 1-10
input lenMedium = 20; #HINT lenMedium: select a stabilization period between 11-20
input lenLong = 200; #HINT lenLong: select a stabilization period between 21-200
script tr {
input len = 0;
def rate = if Between(len, 1, 4) then 1.00 else if
Between(len, 5, 9) then 0.50 else if
Between(len, 10, 11) then 0.25 else if
Between(len, 12, 19) then 0.20 else if
Between(len, 20, 44) then 0.10 else if
Between(len, 45, 99) then 0.05 else if
Between(len, 100, 199) then 0.02 else if
len == 200 then 0.01 else 0.00;
plot rateTracking = rate;
}
def C = close;
def trackShort = tr(lenShort); #tracking rate
def trackMedium = tr(lenMedium); #tracking rate
def trackLong = tr(lenLong); #tracking rate
def trendShort = if !isNan(trendShort[1]) then trendShort[1] + ((C - trendShort[1]) * trackShort) else Double.NaN;
def trendMedium = if !isNan(trendMedium[1]) then trendMedium[1] + ((C - trendMedium[1]) * trackMedium) else Double.NaN;
def trendLong = if !isNan(trendLong[1]) then trendLong[1] + ((C - trendLong[1]) * trackLong) else Double.NaN;
plot haurlanShort = trendShort;
plot haurlanMedium = trendMedium;
plot haurlanLong = trendLong;
Last edited by a moderator: