-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathribbon.pine
More file actions
36 lines (28 loc) · 1.44 KB
/
ribbon.pine
File metadata and controls
36 lines (28 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//@version=6
indicator(title="Moving Average Ribbon", shorttitle="Ribbon", overlay=true)
// FEATURES
// - Draws a ribbon of moving averages.
// Source code on GitHub: https://github.com/chingc/TradingView
// Follow me on X: https://x.com/NeonNoodle22
// User settings
source = input.source(defval=close, title="Source", tooltip="The source for calculations.")
exponential = input.bool(defval=true, title="Exponential", tooltip="Use EMA instead of SMA.")
show100 = input.bool(defval=true, title="MA 100", tooltip="Show 100 day moving average.")
show200 = input.bool(defval=true, title="MA 200", tooltip="Show 200 day moving average.")
// Return a moving average of the given length
ma(length) =>
exponential ? ta.ema(source, length) : ta.sma(source, length)
// Draw moving averages
plot(series=ma(20), title="MA 20", color=#FFFF0080)
plot(series=ma(25), title="MA 25", color=#FFDF0080)
plot(series=ma(30), title="MA 30", color=#FFBF0080)
plot(series=ma(35), title="MA 35", color=#FF9F0080)
plot(series=ma(40), title="MA 40", color=#FF7F0080)
plot(series=ma(45), title="MA 45", color=#FF5F0080)
plot(series=ma(50), title="MA 50", color=#FF3F0080)
ma100 = show100 ? ma(100) : na
ma200 = show200 ? ma(200) : na
p100 = plot(series=ma100, title="MA 100", color=#FF0000FF)
p200 = plot(series=ma200, title="MA 200", color=#800000FF)
// Color the area between ma100 and ma200
fill(plot1=p100, plot2=p200, color=ma100 > ma200 ? #4CAF5033 : #FF525233, title="MA Fill")