linear regression channel screener

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #167653 quote
    cc267cc267
    Participant
    Average

    Hi, I am trying to make a screener for this indicator -https://www.prorealcode.com/prorealtime-indicators/standard-deviation-standard-error-linear-regression-channel/

    A similar thread here gives some examples but i cant get any of them to work. https://www.prorealcode.com/topic/screener-help-for-nicolass-standard-deviation-error-lr-channel/

    How could i go about screening for when the open price hits the lower band?  Many Thanks

    #167656 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    A screener detects and shows an event, while this indicator plots a channel.

    To make a screener out of it you need to tell us what event do you want to be detected and shown. For example when a price touches or breaks one of the outer bands or the middle band or whatever else you want to be detected.

    #167674 quote
    cc267cc267
    Participant
    Average

    Hi Roberto, I wanted it so the screener screens when the open price hits the lower band.

    #167675 quote
    NicolasNicolas
    Keymaster
    Legend
    #167677 quote
    cc267cc267
    Participant
    Average
    test = high > linearregression[lookback]+std[lookback]*NbDeviation OR low < linearregression[lookback]-std[lookback]*NbDeviation
     
    screener[test]

    I’ve manged to get this one to work now. I think the other one the OP posted is not working.

    #167686 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    This works:

    //PRC_Std and Ste LinRegChannel | indicator
    //Standard Deviation and Standard Error
    //Linear Regression Channel
    //12.03.2019
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
     
    // --- settings
    lookback= 200 //channel period
    ChannelType = 1 //1= Standard Deviation ; 2= Standard Erro
    NbDeviation = 1 //Deviation multiplier
    // --- end of settings
     
    sumx = 0
    sumy = 0
    sumxy = 0
    sumx2 = 0
     
    for cmpt = lookback downto 0 do
    tmpx = cmpt
    tmpy = close[cmpt]
    sumy = sumy+tmpy
    sumx = sumx+tmpx
    sumx2 = sumx2 + (tmpx*tmpx)
    sumxy = sumxy + (tmpy*tmpx)
    next
     
    n = lookback+1
     
    if (sumx2 = sumx * sumx) then // protection to avoid infinite values
    b = sumxy - sumx * sumy
    else
    b = (n * sumxy - sumx * sumy) / (n * sumx2 - sumx * sumx)
    endif
    a = (sumy - b * sumx) / n
     
    
     
    //channel
    if ChannelType = 1 then //Standard Deviation
    dat = std[lookback]*NbDeviation
    else
    dat = ste[lookback]*NbDeviation
    endif
    //UPPER band
    //UpperBand = a+b*0+dat
    //drawsegment(barindex[lookback],(a+b*lookback)+dat,barindex,a+b*0+dat) coloured(colorRed,colorGreen,colorBlue)
    //LOWER  band
    LowerBand = a+b*0-dat
    //drawsegment(barindex[lookback],(a+b*lookback)-dat,barindex,a+b*0-dat) coloured(colorRed,colorGreen,colorBlue)
    Cond = (open CROSSES UNDER LowerBand) OR (max(open,close) >= LowerBand AND min(open,close) <= LowerBand)
    SCREENER[Cond]
    #167734 quote
    cc267cc267
    Participant
    Average

    Thanks Nicholas, it looks like this works also now. This will also help me looking into Kirshenbaum bands 🙂

Viewing 7 posts - 1 through 7 (of 7 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

linear regression channel screener


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
cc267 @cc267 Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by cc267cc267
5 years, 5 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 04/20/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...