forexpirate

Adaptive SMA

Coders,

I am working on this adaptive SMA. It has its pros and cons. It is a work in progress and I welcome any one that wants to add or change it. If you add or make positive changes please let me know. It is based off of daily range. Currently it is set to the open three days prior to the current open.
开源脚本

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

免责声明

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

想在图表上使用此脚本?
//@version=2
study("Adaptive SMA",overlay=true)
length = input(title="SMA Length",defval=200)
f=input(title="range factor",defval=16)
rs=input(title="range smoother",defval=100)
r=abs(open[3]-open)*2000
ra=round(sma(r,rs))
l=iff(ra*f>length,length,length-ra*f)
sum = 0
for i = 0 to (l-1)
    sum := sum + close[i]
adpsma = sum/l

plot(sma(adpsma,3), color=red,transp=0,linewidth=3)
plot(sma(close,length),color=yellow,linewidth=3,transp=0)

//l=len+aa*f
//adj = if f*aa<=len
//    f*aa
//else
//    for i = 0 to 60   
//        adj = if f*aa[i]<len  
//            f*aa[1] 
//            break
//        else     
//            continue 
//l=len+adj
//a=sma(close,34)
//b=round((abs(close-a))*200)
//c=iff(b*f>=len,len,len-b*f)