Problem by scanning the Linear-Regresion Chanel
Forums › ProRealTime English forum › ProScreener support › Problem by scanning the Linear-Regresion Chanel
- This topic has 4 replies, 2 voices, and was last updated 1 week ago by thomas2004ch.
-
-
10/25/2024 at 2:11 PM #239463
Hi,
I have an indicator here to measure the linear regression as follow:
//Parameters :
Len = 100
percent = 0.002once j=0
de48=DPO[Len*2](close)
if de48=de48[1] and de48[1]=de48[2] and de48[2]<>de48[3] then
flag=1
endifn=(Len*2)-4
p=(n/2)-1
d100=DPO[n](close)
moy100=close-d100
co=(moy100-moy100[1]+(close[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
endifif flag=0 then
reg=undefined
upperchan=undefined
lowerchan=undefined
else
j=j+1
reg=a*j+b
upperchan = reg + reg*percent
lowerchan = reg – reg*percent
endifRETURN reg COLOURED(0,0,255) as “channel center”, upperchan COLOURED(0,255,0) as “upper channel”, lowerchan COLOURED(255,0,0) as “lower channel”
It looks like in the the attached picture.
I create a scnner to scan which stock has the positive LR as follow but it finds nothing:
//Parameters :
Len = 100
percent = 0.002once j=0
de48=DPO[Len*2](close)
if de48=de48[1] and de48[1]=de48[2] and de48[2]<>de48[3] then
flag=1
endifn=(Len*2)-4
p=(n/2)-1
d100=DPO[n](close)
moy100=close-d100
co=(moy100-moy100[1]+(close[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
endifif flag=0 then
reg=undefined
upperchan=undefined
lowerchan=undefined
else
j=j+1
reg=a*j+b
upperchan = reg + reg*percent
lowerchan = reg – reg*percent
endifc1 = reg > 1
SCREENER[c1]
What could be the problem?
10/25/2024 at 3:14 PM #239465REG will always be > 1.
You check whether REG is on the rise:
1c1 = reg > reg[1]or falling:
1c1 = reg < reg[1]1 user thanked author for this post.
10/25/2024 at 4:24 PM #239472Here is my code again. But no stock is scanned out:
//Parameters :
Len = 100once j=0
de48=DPO[Len*2](close)
if de48=de48[1] and de48[1]=de48[2] and de48[2]<>de48[3] then
flag=1
endifn=(Len*2)-4
p=(n/2)-1
d100=DPO[n](close)
moy100=close-d100
co=(moy100-moy100[1]+(close[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
endifif flag=0 then
reg=undefined
else
j=j+1
reg=a*j+b
endifc1 = reg > reg[1]
SCREENER[c1]
Maybe here something wrong?
10/25/2024 at 4:44 PM #239475The issue is the data history, which is limited to 256 bars (unless you have the Premium version by ProRealTime).
Both the Regression and DPO use many more periods than those you oplan to use.
Try using LEN = 20 (or maybe 50, you’ll have to make some attempts till you find the max value supported).
1 user thanked author for this post.
10/25/2024 at 5:10 PM #239478Many thanks.
I use Len=10, then there are about 8 stocks be scanned out. Terrible. 🙂
the smaller the Len, the more stocks can be scanned out.
-
AuthorPosts