Nadaraya Watson Indicator not working well on some charts

Forums ProRealTime English forum ProBuilder support Nadaraya Watson Indicator not working well on some charts

  • This topic has 1 reply, 2 voices, and was last updated 2 years ago by avatarJS.
Viewing 2 posts - 1 through 2 (of 2 total)
  • #203178

    Hello, I have this indicator (please see code below) Nadaraya Watson Indicator and on most daily charts it plots just fine, but some charts on Daily time frame, box pops up with Error Message:

    ” Error in the indicator: Nadaraya Watson
    A positive integer field is expected with $a”

    Daily Units I have set to 1k.  For example ticker METHUSDXXXX , this indicator is refusing to draw, but other futures and stocks it draws just fine .

    As well this indicator Does Not Draw at all on ALL Weekly charts, even if units amount is set to 100 units.

    Any idea how to fix this? I am using the stable version of Prorealtime end of day data v11.1

    This is the code:

    //Nadaraya-Watson Envelope
    defparam drawonlastbaronly = true
    length = 500//Window Size
    hh = 8 //Bandwidth
    mult = .3
    src = Close
    n = barindex
    k = 2
    if IsLastBarUpdate then
    y2 = 0
    sume = 0
    for i = 0 to length-1
    sum = 0
    sumw = 0
    for j = 0 to length-1
    w = EXP(-pow(i-j,2)/(hh*hh*2))
    sum = sum+src[j]*w
    sumw = sumw+w
    next
    y2 = sum/sumw
    sume = sume+abs(src[i] – y2)
    $a[barindex-i]=y2
    //DRAWPOINT(barindex-i, y2, 1)
    next
    mae = sume/(length*mult)
    for i=0 to length-1
    DRAWPOINT(barindex-i, $a[barindex-i]-mae, 2) coloured(0,255,0,100)
    DRAWPOINT(barindex-i, $a[barindex-i]+mae, 2) coloured(255,0,0,100)
    //if close[barindex-i] > ($a[barindex-i]+mae) then // and src[1]<y2[1]+mae then
    //drawarrowdown(barindex-i,high) coloured(“red”)
    //endif
    //if close[barindex-i] < ($a[barindex-i]-mae) then //and src[1]>y2[1]-mae then
    //drawarrowup(barindex-i,low) coloured(“green”)
    //endif
    next
    /*drawpoint(barindex,y2,1)
    drawpoint(barindex,y2+mae,1)
    drawpoint(barindex,y2-mae,1)*/
    Y2High=$a[barindex]+mae
    Y2Low=$a[barindex]-mae

    endif
    return y2,y2+mae,y2-mae

     

     

    #203180
    JS

    Hi @Mary

    Replace the second line in the code with:

    length = Min(500,BarIndex)

    1 user thanked author for this post.
Viewing 2 posts - 1 through 2 (of 2 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login