[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Alan Hull's Linear RoR indicator



PureBytes Links

Trading Reference Links

Hi
I'm interested in plotting Alan Hull's Linear Rate of Return indicator in AB. The Supercharts code for this indicator is given below. I would like to convert this code into AB code.

My questions are:

1. Has anyone already made the conversion (he asked hopefully..)?

2. How can I work around the PREV-like references in the code below (eg in Plot1 reference is made to Plot1[1], in Plot2 reference is made to Plot2[2], etc).

I did some searching on replacing PREV and found AMA2 promoted but I don't see how that fits here.

Many thanks for help



--------------- Supercharts code ------------------

Plot1

iff( round( 
((6.854*LinearRegValue(close,13,0))
+(4.236*LinearRegValue(LinearRegValue(close,13,0),11,0))
+(2.618*LinearRegValue(LinearRegValue(LinearRegValue(close,13,0),11,0),7,0))
+(1.618*LinearRegValue(LinearRegValue(LinearRegValue(LinearRegValue(close,13,0),11,0),7,0),5,0))
+ (1*LinearRegValue(LinearRegValue(LinearRegValue(LinearRegValue(LinearRegValue(close,13,0),11,0),7,0),5,0),3,0)) )
/16.326,2) > plot1[1],
iff(round( 
((6.854*LinearRegValue(close,13,0))
+(4.236*LinearRegValue(LinearRegValue(close,13,0),11,0))
+(2.618*LinearRegValue(LinearRegValue(LinearRegValue(close,13,0),11,0),7,0))
+(1.618*LinearRegValue(LinearRegValue(LinearRegValue(LinearRegValue(close,13,0),11,0),7,0),5,0))
+ (1*LinearRegValue(LinearRegValue(LinearRegValue(LinearRegValue(LinearRegValue(close,13,0),11,0),7,0),5,0),3,0)) )
/16.326,2)-(2.5*AvgTrueRange(13)) > plot1[1],
round( 
((6.854*LinearRegValue(close,13,0))
+(4.236*LinearRegValue(LinearRegValue(close,13,0),11,0))
+(2.618*LinearRegValue(LinearRegValue(LinearRegValue(close,13,0),11,0),7,0))
+(1.618*Linea rRegValue(LinearRegValue(LinearRegValue(LinearRegValue(close,13,0),11,0),7,0),5,0))
+ (1*LinearRegValue(LinearRegValue(LinearRegValue(LinearRegValue(LinearRegValue(close,13,0),11,0),7,0),5,0),3,0)) )
/16.326,2)-(2.5*AvgTrueRange(13)),
plot1[1]),
LinearRegValue(close,13,0)) 


Plot2

iff( 
Summation(weightedclose*volume,13) > 100000
and (LinearRegValue(weightedclose,13,0)
+LinearRegValue(LinearRegValue(weightedclose,8,0),13,0)
+LinearRegValue(LinearRegValue(LinearRegValue(weightedclose,5,0),8,0),13,0)
+LinearRegValue (LinearRegValue(LinearRegValue(LinearRegValue(weightedclose,3,0),5,0),8,0),13,0)
+LinearRegValue(LinearRegValue(LinearRegValue(LinearRegValue(LinearRegValue(weightedclose,2,0),3,0), 5,0),8,0),13,0))
/5 > (LinearRegValue(weightedclose[1],13,0)
+LinearRegValue(LinearRegValue(weightedclose[1],8,0),13,0)
+LinearRegValue(LinearRegValue(LinearRegValue(weightedclose[1],5,0),8,0),13,0)
+LinearRegValue(LinearRegValue(LinearRegValue(LinearRegValue(weightedclose[1],3,0),5,0),8,0),13,0)
+LinearRegValue(LinearRegValue(LinearRegValue(LinearRegValue(LinearRegValue(weightedclos e[1],2,0),3,0),5,0),8,0),13,0))
/5 and LowestBar(weightedclose,Tperiod)=Tperiod-1 
and plot2[1] = 0 
and average(weightedclose,13) > average(weightedclose,21),
Tperiod-1,
iff(plot2[1] > Tperiod-2 
and average(weightedclose,13) > average(weightedclose,21)
and plot3[1] > 24 
and plot1 >= plot1[1],
plot2[1]+1,
iff(average(weightedclose,21) >= average(weightedclose,13)
or Summation(weightedclose*volume,13) > 100000
or plot1[1]>plot1 or plot3[1] <25, 0, plot2[1]))) 

Plot3

round(iff(
plot2>0,
iff( plot2<52,
(5200/(plot2+1))
*((LinearRegValue(weightedclose,13,0)-weightedclose[plot2])
/LinearRegValue(weightedclose,13,0)),
100*((LinearRegValue(weightedclose,13,0)-LinearRegValue( weightedclose[51],13,0) )
/LinearRegValue(weightedclose,13,0))),0),0)

Plot4

25 

---------------------------------------------------