「TradingViewの無料プラン(または下位プラン)だと、インジケーターの表示枠が足りなくて移動平均線が全部表示できない……」
複数の時間軸のEMAや、特殊なずらし移動平均線(DMA)を使っているトレーダーにとって、TradingViewの「表示上限数」は悩みの種です。
この 10 MA/DMA Flexible Master v2 は、たった 「1枠」のインジケーター枠を消費するだけで、最大10本の移動平均線を自由自在に表示できる 超便利ツールです。
インジケーターの特徴
- ディナポリのDMA(Displaced Moving Average)を完全再現 初期設定として、ジョー・ディナポリ手法で必須となる 「3x3 DMA」「7x5 DMA」「25x5 DMA」 (※指定した期間だけ過去の価格を参照して先行表示させる移動平均線)がセットされています。
- 4種類の計算ロジックに対応
それぞれのMAについて、設定画面のドロップダウンから直感的に
SMA(単純)EMA(指数平滑)HMA(ハル)WMA(加重)を切り替えることができます。 - 王道のパーフェクトオーダー用EMAも標準装備 ディナポリのDMA3本に加え、初期状態で「EMA10, 20, 50, 100, 200」が描画されるようになっています。もちろん、不要な線は期間を「1」にするか、スタイルの設定からチェックを外すだけで簡単に非表示にできます。
TradingViewへの追加方法
以下のPine Scriptコードをコピーし、TradingViewの画面下部にある「Pineエディタ」に貼り付けて「チャートに追加」をクリックしてください。
//@version=6
indicator("10 MA/DMA Flexible Master v2", overlay=true)
// ==========================================
// --- 移動平均計算関数 ---
// ==========================================
get_ma(type, source, length) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"HMA" => ta.hma(source, length)
"WMA" => ta.wma(source, length)
=> na // なければna
// ==========================================
// --- パラメーター & 計算 & 描画 (10セット) ---
// ==========================================
// グループ名
grp_settings = "MA/DMA 設定"
// --- 【ここが重要】MAの種類を配列ではなく、オプションに直接列挙する ---
// 各input.stringの中で、options=["SMA", "EMA", "HMA", "WMA"] と記述します。
// --- MA 1 (ディナポリDMA3x3風) ---
len1 = input.int(3, "MA 1 期間", minval=1, group=grp_settings)
type1 = input.string("SMA", "MA 1 種類", options=["SMA", "EMA", "HMA", "WMA"], group=grp_settings)
dis1 = input.int(3, "MA 1 ずらす(Displace)", minval=0, group=grp_settings)
source1 = close[dis1] // Displaceの数だけ過去の価格を参照する
ma1 = get_ma(type1, source1, len1)
plot(ma1, "MA 1", color=color.new(color.aqua, 20), linewidth=2)
// --- MA 2 (ディナポリDMA7x5風) ---
len2 = input.int(7, "MA 2 期間", minval=1, group=grp_settings)
type2 = input.string("SMA", "MA 2 種類", options=["SMA", "EMA", "HMA", "WMA"], group=grp_settings)
dis2 = input.int(5, "MA 2 ずらす(Displace)", minval=0, group=grp_settings)
source2 = close[dis2]
ma2 = get_ma(type2, source2, len2)
plot(ma2, "MA 2", color=color.new(color.orange, 20), linewidth=2)
// --- MA 3 (ディナポリDMA25x5風) ---
len3 = input.int(25, "MA 3 期間", minval=1, group=grp_settings)
type3 = input.string("SMA", "MA 3 種類", options=["SMA", "EMA", "HMA", "WMA"], group=grp_settings)
dis3 = input.int(5, "MA 3 ずらす(Displace)", minval=0, group=grp_settings)
source3 = close[dis3]
ma3 = get_ma(type3, source3, len3)
plot(ma3, "MA 3", color=color.new(color.red, 20), linewidth=2)
// --- MA 4 (通常のEMA10風) ---
len4 = input.int(10, "MA 4 期間", minval=1, group=grp_settings)
type4 = input.string("EMA", "MA 4 種類", options=["SMA", "EMA", "HMA", "WMA"], group=grp_settings)
dis4 = input.int(0, "MA 4 ずらす(Displace)", minval=0, group=grp_settings)
source4 = close[dis4]
ma4 = get_ma(type4, source4, len4)
plot(ma4, "MA 4", color=color.new(color.white, 30), linewidth=1, style=plot.style_line)
// --- MA 5 (通常のEMA20風) ---
len5 = input.int(20, "MA 5 期間", minval=1, group=grp_settings)
type5 = input.string("EMA", "MA 5 種類", options=["SMA", "EMA", "HMA", "WMA"], group=grp_settings)
dis5 = input.int(0, "MA 5 ずらす(Displace)", minval=0, group=grp_settings)
source5 = close[dis5]
ma5 = get_ma(type5, source5, len5)
plot(ma5, "MA 5", color=color.new(color.green, 30), linewidth=1, style=plot.style_line)
// --- MA 6 (通常のEMA50風) ---
len6 = input.int(50, "MA 6 期間", minval=1, group=grp_settings)
type6 = input.string("EMA", "MA 6 種類", options=["SMA", "EMA", "HMA", "WMA"], group=grp_settings)
dis6 = input.int(0, "MA 6 ずらす(Displace)", minval=0, group=grp_settings)
source6 = close[dis6]
ma6 = get_ma(type6, source6, len6)
plot(ma6, "MA 6", color=color.new(color.yellow, 30), linewidth=1, style=plot.style_line)
// --- MA 7 (通常のEMA100風) ---
len7 = input.int(100, "MA 7 期間", minval=1, group=grp_settings)
type7 = input.string("EMA", "MA 7 種類", options=["SMA", "EMA", "HMA", "WMA"], group=grp_settings)
dis7 = input.int(0, "MA 7 ずらす(Displace)", minval=0, group=grp_settings)
source7 = close[dis7]
ma7 = get_ma(type7, source7, len7)
plot(ma7, "MA 7", color=color.new(color.purple, 30), linewidth=1, style=plot.style_line)
// --- MA 8 (通常のEMA200風) ---
len8 = input.int(200, "MA 8 期間", minval=1, group=grp_settings)
type8 = input.string("EMA", "MA 8 種類", options=["SMA", "EMA", "HMA", "WMA"], group=grp_settings)
dis8 = input.int(0, "MA 8 ずらす(Displace)", minval=0, group=grp_settings)
source8 = close[dis8]
ma8 = get_ma(type8, source8, len8)
plot(ma8, "MA 8", color=color.new(color.blue, 30), linewidth=1, style=plot.style_line)
// --- MA 9 (予備: 未使用) ---
len9 = input.int(1, "MA 9 期間 (1=非表示)", minval=1, group=grp_settings)
type9 = input.string("SMA", "MA 9 種類", options=["SMA", "EMA", "HMA", "WMA"], group=grp_settings)
dis9 = input.int(0, "MA 9 ずらす(Displace)", minval=0, group=grp_settings)
source9 = close[dis9]
ma9 = get_ma(type9, source9, len9)
// 期間が1の時は描画しないガード
plot(len9 > 1 ? ma9 : na, "MA 9", color=color.new(color.gray, 50), linewidth=1)
// --- MA 10 (予備: 未使用) ---
len10 = input.int(1, "MA 10 期間 (1=非表示)", minval=1, group=grp_settings)
type10 = input.string("SMA", "MA 10 種類", options=["SMA", "EMA", "HMA", "WMA"], group=grp_settings)
dis10 = input.int(0, "MA 10 ずらす(Displace)", minval=0, group=grp_settings)
source10 = close[dis10]
ma10 = get_ma(type10, source10, len10)
plot(len10 > 1 ? ma10 : na, "MA 10", color=color.new(color.silver, 50), linewidth=1)