Codificare questo indicatore

Forums ProRealTime forum Italiano Supporto ProBuilder Codificare questo indicatore

Viewing 2 posts - 1 through 2 (of 2 total)
  • #181535

    Secondo voi è possibile codificare questo indicatore da trading view?

    //@version=4
    study(title=”Rolling Moving Average”, shorttitle=”MA_rolling”, overlay=true)
    len = input(9, minval=1, title=”Length”)
    src = input(close, title=”Source”)
    ma_type = input(options=[“SMA”,”EMA”], defval=”SMA”, title=”type”)

    roll_sma(x, y) =>
    sum = 0.0
    for i = 0 to y – 1
    sum := sum + x[i] / y
    sum

    roll_ema(x, y) =>
    alpha = 2 / (y + 1)
    sum = 0.0
    sum := alpha * x + (1 – alpha) * nz(sum[1])

    var roll_sma_len = 0

    roll_sma_len := roll_sma_len + 1

    out1 = ma_type==”SMA” ? sma(src,len) : ema(src,len)
    out2 = ma_type==”SMA” ? roll_sma(src,roll_sma_len) : roll_ema(src,roll_sma_len)

    out = bar_index+1 <= len ? out2 : out1 plot(out, color=#00FF00, title="MA")

    #181661

    E’ identico ad una SMA o EMA, cambia qualcosa solo per i primi periodi iniziali:

    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