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.
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 đồ?
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)