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.
开源脚本

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

免责声明

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

想在图表上使用此脚本?
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)