Problem by scanning the Linear-Regresion Chanel

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

    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    thomas2004chthomas2004ch
    Participant
    Senior

    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    thomas2004chthomas2004ch
    Participant
    Senior

    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.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

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 thomas2004chthomas2004ch
1 year, 10 months ago.

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