22 lines
1.0 KiB
Plaintext
22 lines
1.0 KiB
Plaintext
//@version=5
|
|
indicator(title="Moving Average Simple", shorttitle="SMA", overlay=true, timeframe="", timeframe_gaps=true)
|
|
len = input.int(9, minval=1, title="Length")
|
|
src = input(close, title="Source")
|
|
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500, display = display.data_window)
|
|
out = ta.sma(src, len)
|
|
plot(out, color=color.blue, title="MA", offset=offset)
|
|
|
|
ma(source, length, type) =>
|
|
switch type
|
|
"SMA" => ta.sma(source, length)
|
|
"EMA" => ta.ema(source, length)
|
|
"SMMA (RMA)" => ta.rma(source, length)
|
|
"WMA" => ta.wma(source, length)
|
|
"VWMA" => ta.vwma(source, length)
|
|
|
|
typeMA = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Smoothing", display = display.data_window)
|
|
smoothingLength = input.int(title = "Length", defval = 5, minval = 1, maxval = 100, group="Smoothing", display = display.data_window)
|
|
|
|
smoothingLine = ma(out, smoothingLength, typeMA)
|
|
plot(smoothingLine, title="Smoothing Line", color=#f37f20, offset=offset, display=display.none)
|