RicardoSantos

[RS]JR Moving Average System V1.b

update: changes to code, ma's now split over 3 sets fast, medium and slow, removed cloud and sl_lines(no use?), ma's visually display as shapes :p added option to toggle the ma's on/off.
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="[RS]JR Moving Average System V1.b", shorttitle="[RS]JR.MAS.V1b", overlay=true)

//  ||---   Median Line.
median = sma(hl2, input(1))
//  ||---   Fast MA's
fastmas = input(2)
fastma1 = wma(open, fastmas)
fastma2 = ema(open, fastmas)
//  ||---   Medium MA's
mediummas = input(8)
mediumma1 = wma(open, mediummas)
mediumma2 = ema(open, mediummas)
//  ||---   Slow MA's
slowmas = input(32)
slowma1 = wma(open, slowmas)
slowma2 = ema(open, slowmas)
//  ||---
hidemediumline = input(false)
risingmediumma1 = mediumma1 > mediumma1[1] and mediumma2 > mediumma2[1] ? mediumma1 : na
risingmediumma1color = risingmediumma1 ? green : na
plotshape(hidemediumline ? na : risingmediumma1, style=shape.triangleup, color=risingmediumma1color, location=location.absolute)

fallingmediumma1 = mediumma1 < mediumma1[1] and mediumma2 < mediumma2[1] ? mediumma1 : na
fallingmediumma1color = fallingmediumma1 ? maroon : na
plotshape(hidemediumline ? na : fallingmediumma1, style=shape.triangledown, color=fallingmediumma1color, location=location.absolute)
//---
//  ||---
hideslowline = input(false)
risingslowma1 = slowma1 > slowma1[1] and slowma2 > slowma2[1] ? slowma1 : na
risingslowma1color = risingslowma1 ? green : na
plotshape(hideslowline ? na : risingslowma1, style=shape.triangleup, color=risingslowma1color, location=location.absolute)

fallingslowma1 = slowma1 < slowma1[1] and slowma2 < slowma2[1] ? slowma1 : na
fallingslowma1color = fallingslowma1 ? maroon : na
plotshape(hideslowline ? na : fallingslowma1, style=shape.triangledown, color=fallingslowma1color, location=location.absolute)
//---
ma1color= fastma1 > fastma1[1] and fastma2 > fastma2[1] ? green : 
        fastma1 < fastma1[1] and fastma2 < fastma2[1] ? maroon : gray
plot(median, color=black)
//plotshape(fastma1, style=shape.diamond, color=ma1color, location=location.absolute)
//plot(ma2, color=silver)

condition = median >= fastma1 and fastma1 >= fastma2 ? (close >= open ? lime : green) :
        median <= fastma1 and fastma1 <= fastma2 ? (close >= open ? red : maroon) :
        median >= mediumma1 and mediumma1 >= mediumma2 ? (close >= open ? lime : green) :
        median <= mediumma1 and mediumma1 <= mediumma2 ? (close >= open ? red : maroon) :
        (close >= open ? silver : gray)

barcolor(condition)

//  ||---   Crossovers
buyx1 = cross(median,fastma1) and median >= median[1] ? true : false
sellx1 = cross(median,fastma1) and median <= median[1] ? true : false
plotshape(buyx1, style=shape.arrowup, color=green, location=location.belowbar)
plotshape(sellx1, style=shape.arrowdown, color=maroon, location=location.abovebar)