Conversion from trading view Nadaraya-Watson Envelope

Viewing 15 posts - 1 through 15 (of 28 total)
  • Author
    Posts
  • #196081 quote
    Gau_trading
    Participant
    New

    Here is the code attached, 70 lines.
    Thanks to all

    #196255 quote
    Nicolas
    Keymaster
    Master

    Please next time, add some explanations and screenshots of what we have to recode for you.

    This indicator is repainting, it means that in real time the signals will be very different than the ones you see in the past, it uses futures datas in order to show perfect channels and signals. So it is useless for trading, what’s your opinion?

    #196261 quote
    Gau_trading
    Participant
    New

    Thank you Nicolas, no indicator is perfect, but here is the screenshot of the NQ for the last 2 days.

    #196268 quote
    Nicolas
    Keymaster
    Master

    Of course, I simply meant that today's curve will not look the same tomorrow, when the history is completed. Each data that is included in the calculation modifies the calculation of the past and the indicator is continually retraced.

    #196273 quote
    Gau_trading
    Participant
    New

    I understand your point, but in daytrading this indicator gives good TP or entry points as you can see on the chart.

    #196295 quote
    Nicolas
    Keymaster
    Master

    Believe me I’d like to help, and sorry to insist, I do want to be sure you have fully undersand what it means since you are still talking about entries/tp of the past history: The entries plotted on the chart were not the same in real time.

    #196301 quote
    Gau_trading
    Participant
    New

    At first thanks for helping,

    I understand your point, but  even if the past triggers are modified afterwards, Real time triggers  are still worth it

    .

    #196303 quote
    Nicolas
    Keymaster
    Master

    Ok so if you are just looking at real time signals, then the over complicated repainting coding is not mandatory. I will have a look on a simple way to convert it.

    #196304 quote
    Gau_trading
    Participant
    New

    Is very nice of you,

    Thanks again

    #196311 quote
    Nicolas
    Keymaster
    Master

    Please find attached the translated version (non repainting) of Nadaraya-Watson Envelope

    //Nadaraya-Watson Envelope
    length = 21 //Window Size
    hh      = 8 //Bandwidth
    mult   = 2
    
    src    = CustomClose 
    
    n = barindex
    k = 2
    
    //if IsLastBarUpdate and barindex>length then
    //y = 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)
    //array.push(y,y2)
    
    next
    mae = sume/length*mult
    /*drawpoint(barindex,y2,1)
    drawpoint(barindex,y2+mae,1)
    drawpoint(barindex,y2-mae,1)*/
    
    if src crosses under y2+mae then // and src[1]<y2[1]+mae then 
    drawarrowdown(barindex,high) coloured("red")
    endif
    if src crosses over y2-mae then //and src[1]>y2[1]-mae then
    drawarrowup(barindex,low) coloured("green")
    endif
    //endif
    
    return y2,y2+mae,y2-mae

    The nested loops are huge intensive for calculation, please consider using a limited units display (such as 1k units only).

    #196314 quote
    Gau_trading
    Participant
    New

    Thanks a lot, I have this error in the window ?

    “hh” Variable which becomes  “h”

    And one stupid question, How to you show the indicator in the chart and not only in the window below ?

    Thanks again

    #196316 quote
    Gau_trading
    Participant
    New

    Sorry I found for hh.

    If i declare hh variable as decimal, is it possible for me to input 2.1?

    Also Lengh is supposed to minimize loop calculation, but it shows on the graph for value superior to 500.

    Thanks again

    #196318 quote
    Gau_trading
    Participant
    New

    Sorry I found for the TA overlay. So the only question :

    • If i declare hh variable as decimal, is it possible for me to input 2.1?
    • Also Lengh is supposed to minimize loop calculation, but it shows on the graph for value superior to 500

    Thanks again

    #196321 quote
    Nicolas
    Keymaster
    Master

    Yes, hh can be decimal.

    The loop is made on each candlestick for “length” candles back in history, in order to calculate for each of them what is the value of the channel.

    #196323 quote
    Gau_trading
    Participant
    New

    Here are the diffrence (crosses)  between the 2 plateforms with the same variables.

    Thanks

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

Conversion from trading view Nadaraya-Watson Envelope


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 27 replies,
has 8 voices, and was last updated by JS
3 years, 5 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/25/2022
Status: Active
Attachments: 11 files
Logo Logo
Loading...