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)