RicardoSantos

[RS]TEST PredictiveMA

simple yet efficient predictive algorithm applied to moving averages
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?
study("[RS]PMA", overlay=true)
useDEMA = input(true)

src = input("close")
source = src == "close" ? close : 
        src == "open" ? open :
        src == "high" ? high : 
        src == "low" ? low : 
        src == "ohlc4" ? ohlc4 : 
        src == "hlc3" ? hlc3 : 
        src == "hl2" ? hl2 : close

length1 = input(4)
length2 = input(12)
length3 = input(24)
length4 = input(48)
length5 = input(72)
length6 = input(120)
length7 = input(240)
length8 = input(360)
length9 = input(576)

term1 = ema(ema((sum(source, length1)/length1) + change(source, length1), length1), useDEMA ? length1 : 1)
term2 = ema(ema((sum(source, length2)/length2) + change(source, length2), length2), useDEMA ? length2 : 1)
term3 = ema(ema((sum(source, length3)/length3) + change(source, length3), length3), useDEMA ? length3 : 1)
term4 = ema(ema((sum(source, length4)/length4) + change(source, length4), length4), useDEMA ? length4 : 1)
term5 = ema(ema((sum(source, length5)/length5) + change(source, length5), length5), useDEMA ? length5 : 1)
term6 = ema(ema((sum(source, length6)/length6) + change(source, length6), length6), useDEMA ? length6 : 1)
term7 = ema(ema((sum(source, length7)/length7) + change(source, length7), length7), useDEMA ? length7 : 1)
term8 = ema(ema((sum(source, length8)/length8) + change(source, length8), length8), useDEMA ? length8 : 1)
term9 = ema(ema((sum(source, length9)/length9) + change(source, length9), length9), useDEMA ? length9 : 1)

colorf(pt0, pt1) => pt0 >= pt1 ? teal : navy
offsetf(v) => 1+round(v/2)

p1 = plot(term1, color=colorf(term1, term2), offset=offsetf(length1), linewidth=1)
p2 = plot(term2, color=colorf(term2, term3), offset=offsetf(length2), linewidth=2)
p3 = plot(term3, color=colorf(term3, term4), offset=offsetf(length3), linewidth=3)
p4 = plot(term4, color=colorf(term4, term5), offset=offsetf(length4), linewidth=4)
p5 = plot(term5, color=colorf(term5, term6), offset=offsetf(length5), linewidth=5)
p6 = plot(term6, color=colorf(term6, term7), offset=offsetf(length6), linewidth=6)
p7 = plot(term7, color=colorf(term7, term8), offset=offsetf(length7), linewidth=7)
p8 = plot(term8, color=colorf(term8, term9), offset=offsetf(length8), linewidth=8)
p9 = plot(term9, color=colorf(term9, term1), offset=offsetf(length9), linewidth=9)