Problem by scanning the Linear-Regresion Chanel

Forums ProRealTime English forum ProScreener support Problem by scanning the Linear-Regresion Chanel

Viewing 5 posts - 1 through 5 (of 5 total)
  • #239463

    Hi,

    I have an indicator here to measure the linear regression as follow:

    //Parameters :
    Len = 100
    percent = 0.002

    once j=0
    de48=DPO[Len*2](close)
    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](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
    endif

    if 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
    endif

    RETURN 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.002

    once j=0
    de48=DPO[Len*2](close)
    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](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
    endif

    if 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
    endif

    c1 = reg > 1

    SCREENER[c1]

    What could be the problem?

     

     

     

    #239465

    REG will always be > 1.

    You  check whether REG is on the rise:

    or falling:

     

     

     

    1 user thanked author for this post.
    #239472

    Here is my code again. But no stock is scanned out:

    //Parameters :
    Len = 100

    once j=0
    de48=DPO[Len*2](close)
    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](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
    endif

    if flag=0 then
    reg=undefined
    else
    j=j+1
    reg=a*j+b
    endif

    c1 = reg > reg[1]

    SCREENER[c1]

    Maybe here something wrong?

    #239475

    The 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.
    #239478

    Many 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.

Viewing 5 posts - 1 through 5 (of 5 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login