Hi,
I try to apply the LR-Chanel indicator created by Nikolas on the MACD Histogram but it shows nothing when I add this onto the MACD.
My code looks as follow:
REM Dieses Beispiel berechnet den MACD Indikator.
//Parameters :
// Len = 100
// percent = 0.002
fastMA = exponentialAverage[p](close)
slowMA = exponentialAverage[q](close)
myMACD = fastMA - slowMA
line1 = exponentialAverage[r](myMACD)
hist = myMACD - line1
once j=0
de48=DPO[Len*2](hist)
if de48=de48[1] and de48[1]=de48[2] and de48[2]<>de48[3] then
flag=1
endif
n=(Len*2)-4
p=(n/2)-1
d100=DPO[n](hist)
moy100=hist-d100
co=(moy100-moy100[1]+(hist[p])/n)*n
if flag=1 and flag[1]=0 then
test=linearregression[Len](co)
test1=linearregressionslope[Len](co)
a=test1
b=test-test1*Len
endif
if flag=0 then
reg=undefined
else
j=j+1
reg=a*j+b
endif
RETURN reg COLOURED(255,0,0) as "channel center"
Where is from the original code of the LR channel please?
In your code, flag will never be equal to 1 and thus calculation of the channel will never start. Condition at line 17 will surely never be true, that’s where the trouble is, at the first glance.
Hi Nicolas,
I forgot where I exactly see this code. It is definitely from this forum. I though it was from you.
>>…Condition at line 17 will surely never be true…
Why? If I replace the ‘hist’ with ‘close’ or ‘high’ or ‘low’. It works (without the MACD code).
Now I find out where I see the LR Channel code. It is here:
Linear Regression Channel with percent upper and lower lines