HuangCheng

HC-MAS

13
moving average system
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
study(title="Moving Average System",shorttitle="MAS",overlay=true)

// Inputs
legs = input(defval=3)
legm = input(defval=7)
legl = input(defval=15)

sd = input(true, title="Show dots?")
ccol = input(true,title="Change Color?")

// Calc
wwma(l,p) =>
    wwma = (nz(wwma[1]) * (l - 1) + p) / l
    
wmas = wwma(legs,close)
wmam = wwma(legm,close)
wmal = wwma(legl,close)


// Styling
cols = ccol ?( wmas > wmas[1] ? #D26900: #28FF28) : #D26900
colm = ccol ?( wmam > wmam[1] ? #D26900 : #28FF28) : #D26900
coll = ccol ?( wmal > wmal[1] ? #D26900F : #28FF28) : #D26900
x = cross(wmas,wmam)
y = cross(wmam,wmal)

// Plots
plot(wmas,linewidth=1,color=cols)
plot(wmam,linewidth=1,color=colm)
plot(wmal,linewidth=1,color=coll)

plot(sd and x ? wmas : na,style=circles, linewidth=6, color=black)
plot(sd and y ? wmam : na,style=cross, linewidth=6, color=purple)