Alert setting is not possible in Standard Deviation Channel

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #102614 quote
    Partha Banerjee
    Participant
    Junior

    Hello Nicholas,
    This is brilliant. Many thanks. One last request Nicholas please, can you please let me know how to start the upper and lower line from 50 bars before dynamically instead of anchoring it to a fixed date and time. It needs a little change to your code to make the start point dynamic please.
    Many thanks, Nicholas.
    Regards,

    #102619 quote
    Nicolas
    Keymaster
    Master

    how to start the upper and lower line from 50 bars before dynamically instead of anchoring it to a fixed date and time

    That’s what the initial indicators was doing, so I don’t understand your question?

    #102634 quote
    Partha Banerjee
    Participant
    Junior

    Sorry Nicholas, for the confusion, if any.

    If you remember, we can not set the ALERT on the initial indicator as depicted below.

    This is why, the request is how to set an ALERT in the initial indicator or the anchored one if it’s starting point is 50 bar behind dynamically.

    Anyone will suffice the request please.

    Regards,

    //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
    // chnlper = 200, sdsr = 1, devmul = 1.62
    lookback= chnlper //channel period = 50
    ChannelType = sdsr //1= Standard Deviation ; 2= Standard Erro
    NbDeviation = devmul //Deviation multiplier = 1
    colorRed = C1
    colorGreen = C2
    colorBlue = C3
    // --- 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
    elsif ChannelType = 2 then
    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
    
    #102640 quote
    Nicolas
    Keymaster
    Master

    Here is the version of the channel with dynamic lookback and with returned values for the upper and lower lines to create signals:

    //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)
    
    startbar=barindex[lookback]
    endbar=barindex
    coeff = ((a+b)-(a+b*lookback))/(max(1,endbar-startbar))
    
    return ((a+b*lookback)+dat)+(barindex-startbar)*coeff coloured(100,100,100,0) as "upper line",((a+b*lookback)-dat)+(barindex-startbar)*coeff coloured(100,100,100,0) as "lower line"
    #102795 quote
    Partha Banerjee
    Participant
    Junior

    You are a GENIUS, my dear Nicholas.

    Thanks a trillion for your kind, fast and reliable response.

    Really appreciate your effort.

    Best regards,

    #103874 quote
    Partha Banerjee
    Participant
    Junior

    Hello Nicholas,

    It seems the standard error channel is not working properly in Bitcoin’s monthly chart as shown in the enclosed chart.

    Appreciate if it can be fixed.

    Regards,

    StdDev-StdErr-Channel-Monthly.jpg StdDev-StdErr-Channel-Monthly.jpg
    #103899 quote
    Nicolas
    Keymaster
    Master

    Because you are using a logarithmic scale.

    #103918 quote
    Partha Banerjee
    Participant
    Junior

    You are correct Nicolas.

    Many thanks.

Viewing 8 posts - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.

Alert setting is not possible in Standard Deviation Channel


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 22 replies,
has 2 voices, and was last updated by Partha Banerjee
6 years, 6 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/26/2019
Status: Active
Attachments: 9 files
Logo Logo
Loading...