How to change indicator lookback period to market open

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #171578 quote
    RubberToe
    Participant
    Average

    I like this indicator, but instead of a lookback period, I would prefer to be able to start at the American market open (regular hours, not extended).  Is there a way to do this? thx

    Standard Deviation & Standard Error Linear Regression Channel

    //PRC_Std and Ste LinRegChannel | indicator
    //Standard Deviation and Standard Error 
    //Linear Regression Channel
    //12.03.2019
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
     
    defparam drawonlastbaronly=true
    defparam calculateonlastbars=1000
    // --- settings
    lookback= 200 //channel period
    ChannelType = 1 //1= Standard Deviation ; 2= Standard Erro
    NbDeviation = 1 //Deviation multiplier 
    colorRed = 255
    colorGreen = 255
    colorBlue = 0
    // --- 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
     
    drawsegment(barindex[lookback],a+b*lookback,barindex,a+b*0) coloured(colorRed,colorGreen,colorBlue)
     
    //channel
    if ChannelType = 1 then //Standard Deviation 
     dat = std[lookback]*NbDeviation
    else
     dat = ste[lookback]*NbDeviation
    endif
    drawsegment(barindex[lookback],(a+b*lookback)+dat,barindex,a+b*0+dat) coloured(colorRed,colorGreen,colorBlue)
    drawsegment(barindex[lookback],(a+b*lookback)-dat,barindex,a+b*0-dat) coloured(colorRed,colorGreen,colorBlue)
     
    return
    #171802 quote
    RubberToe
    Participant
    Average

    Also, in regards to the STD DEV indicator above, can it be adjusted to calculate on last candle close?

    Currently, it wiggles with the live candle, and I would like it to not do that.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

How to change indicator lookback period to market open


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
RubberToe @rubbertoe Participant
Summary

This topic contains 1 reply,
has 1 voice, and was last updated by RubberToe
4 years, 9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/10/2021
Status: Active
Attachments: No files
Logo Logo
Loading...