Problem by scanning the Linear-Regresion Chanel

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #239463 quote
    thomas2004ch
    Participant
    Average

    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?

    LRC.png LRC.png
    #239465 quote
    robertogozzi
    Moderator
    Master

    REG will always be > 1.

    You  check whether REG is on the rise:

    c1 = reg > reg[1]

    or falling:

    c1 = reg < reg[1]
    Iván González thanked this post
    #239472 quote
    thomas2004ch
    Participant
    Average

    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 quote
    robertogozzi
    Moderator
    Master

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

    Iván González thanked this post
    #239478 quote
    thomas2004ch
    Participant
    Average

    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)
  • You must be logged in to reply to this topic.

Problem by scanning the Linear-Regresion Chanel


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by thomas2004ch
1 year, 4 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 10/25/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...