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.
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
//@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)