OPEN-SOURCE SCRIPT
Multi-Timeframe 5 Moving Averages

//version=5
indicator("Multi-Timeframe 5 Moving Averages", shorttitle="MTF MA x5", overlay=true)
// ============== MOVING AVERAGE 1 ==============
ma1_enabled = input(true, title="Enable MA1", group="Moving Average 1")
ma1_period = input.int(9, title="MA1 Period", minval=1, group="Moving Average 1")
ma1_type = input.string("EMA", title="MA1 Type", options=["SMA", "EMA", "WMA"], group="Moving Average 1")
ma1_color = input(color.new(#FF6B35, 0), title="MA1 Color", group="Moving Average 1")
// ============== MOVING AVERAGE 2 ==============
ma2_enabled = input(true, title="Enable MA2", group="Moving Average 2")
ma2_period = input.int(20, title="MA2 Period", minval=1, group="Moving Average 2")
ma2_type = input.string("EMA", title="MA2 Type", options=["SMA", "EMA", "WMA"], group="Moving Average 2")
ma2_color = input(color.new(#004E89, 0), title="MA2 Color", group="Moving Average 2")
// ============== MOVING AVERAGE 3 ==============
ma3_enabled = input(true, title="Enable MA3", group="Moving Average 3")
ma3_period = input.int(50, title="MA3 Period", minval=1, group="Moving Average 3")
ma3_type = input.string("SMA", title="MA3 Type", options=["SMA", "EMA", "WMA"], group="Moving Average 3")
ma3_color = input(color.new(#F7931E, 0), title="MA3 Color", group="Moving Average 3")
// ============== MOVING AVERAGE 4 ==============
ma4_enabled = input(true, title="Enable MA4", group="Moving Average 4")
ma4_period = input.int(100, title="MA4 Period", minval=1, group="Moving Average 4")
ma4_type = input.string("SMA", title="MA4 Type", options=["SMA", "EMA", "WMA"], group="Moving Average 4")
ma4_color = input(color.new(#1E88E5, 0), title="MA4 Color", group="Moving Average 4")
// ============== MOVING AVERAGE 5 ==============
ma5_enabled = input(true, title="Enable MA5", group="Moving Average 5")
ma5_period = input.int(200, title="MA5 Period", minval=1, group="Moving Average 5")
ma5_type = input.string("EMA", title="MA5 Type", options=["SMA", "EMA", "WMA"], group="Moving Average 5")
ma5_color = input(color.new(#43A047, 0), title="MA5 Color", group="Moving Average 5")
// ============== FUNCTION TO CALCULATE MA ==============
calcMA(period, maType, source) =>
switch maType
"SMA" => ta.sma(source, period)
"EMA" => ta.ema(source, period)
"WMA" => ta.wma(source, period)
=> ta.sma(source, period)
// ============== CALCULATE MOVING AVERAGES (CHART TIMEFRAME ONLY) ==============
ma1_value = calcMA(ma1_period, ma1_type, close)
ma2_value = calcMA(ma2_period, ma2_type, close)
ma3_value = calcMA(ma3_period, ma3_type, close)
ma4_value = calcMA(ma4_period, ma4_type, close)
ma5_value = calcMA(ma5_period, ma5_type, close)
// ============== PLOT MOVING AVERAGES ==============
plot(ma1_enabled ? ma1_value : na, title="MA1", color=ma1_color, linewidth=2)
plot(ma2_enabled ? ma2_value : na, title="MA2", color=ma2_color, linewidth=2)
plot(ma3_enabled ? ma3_value : na, title="MA3", color=ma3_color, linewidth=2)
plot(ma4_enabled ? ma4_value : na, title="MA4", color=ma4_color, linewidth=2)
plot(ma5_enabled ? ma5_value : na, title="MA5", color=ma5_color, linewidth=2)
indicator("Multi-Timeframe 5 Moving Averages", shorttitle="MTF MA x5", overlay=true)
// ============== MOVING AVERAGE 1 ==============
ma1_enabled = input(true, title="Enable MA1", group="Moving Average 1")
ma1_period = input.int(9, title="MA1 Period", minval=1, group="Moving Average 1")
ma1_type = input.string("EMA", title="MA1 Type", options=["SMA", "EMA", "WMA"], group="Moving Average 1")
ma1_color = input(color.new(#FF6B35, 0), title="MA1 Color", group="Moving Average 1")
// ============== MOVING AVERAGE 2 ==============
ma2_enabled = input(true, title="Enable MA2", group="Moving Average 2")
ma2_period = input.int(20, title="MA2 Period", minval=1, group="Moving Average 2")
ma2_type = input.string("EMA", title="MA2 Type", options=["SMA", "EMA", "WMA"], group="Moving Average 2")
ma2_color = input(color.new(#004E89, 0), title="MA2 Color", group="Moving Average 2")
// ============== MOVING AVERAGE 3 ==============
ma3_enabled = input(true, title="Enable MA3", group="Moving Average 3")
ma3_period = input.int(50, title="MA3 Period", minval=1, group="Moving Average 3")
ma3_type = input.string("SMA", title="MA3 Type", options=["SMA", "EMA", "WMA"], group="Moving Average 3")
ma3_color = input(color.new(#F7931E, 0), title="MA3 Color", group="Moving Average 3")
// ============== MOVING AVERAGE 4 ==============
ma4_enabled = input(true, title="Enable MA4", group="Moving Average 4")
ma4_period = input.int(100, title="MA4 Period", minval=1, group="Moving Average 4")
ma4_type = input.string("SMA", title="MA4 Type", options=["SMA", "EMA", "WMA"], group="Moving Average 4")
ma4_color = input(color.new(#1E88E5, 0), title="MA4 Color", group="Moving Average 4")
// ============== MOVING AVERAGE 5 ==============
ma5_enabled = input(true, title="Enable MA5", group="Moving Average 5")
ma5_period = input.int(200, title="MA5 Period", minval=1, group="Moving Average 5")
ma5_type = input.string("EMA", title="MA5 Type", options=["SMA", "EMA", "WMA"], group="Moving Average 5")
ma5_color = input(color.new(#43A047, 0), title="MA5 Color", group="Moving Average 5")
// ============== FUNCTION TO CALCULATE MA ==============
calcMA(period, maType, source) =>
switch maType
"SMA" => ta.sma(source, period)
"EMA" => ta.ema(source, period)
"WMA" => ta.wma(source, period)
=> ta.sma(source, period)
// ============== CALCULATE MOVING AVERAGES (CHART TIMEFRAME ONLY) ==============
ma1_value = calcMA(ma1_period, ma1_type, close)
ma2_value = calcMA(ma2_period, ma2_type, close)
ma3_value = calcMA(ma3_period, ma3_type, close)
ma4_value = calcMA(ma4_period, ma4_type, close)
ma5_value = calcMA(ma5_period, ma5_type, close)
// ============== PLOT MOVING AVERAGES ==============
plot(ma1_enabled ? ma1_value : na, title="MA1", color=ma1_color, linewidth=2)
plot(ma2_enabled ? ma2_value : na, title="MA2", color=ma2_color, linewidth=2)
plot(ma3_enabled ? ma3_value : na, title="MA3", color=ma3_color, linewidth=2)
plot(ma4_enabled ? ma4_value : na, title="MA4", color=ma4_color, linewidth=2)
plot(ma5_enabled ? ma5_value : na, title="MA5", color=ma5_color, linewidth=2)
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.