田向式MTF水平線 & MA & スクショ枠

「過去の高値・安値に水平線を引いて、ブレイクや反発を狙う」 これはシンプルでありながら最強の手法の一つです(日本でも著名なトレーダーである田向氏の著書等で有名ですね)。しかし、日足・4時間足・1時間足の高安にいちいち手作業で線を引くのは非常に手間がかかりますし、チャートが線だらけになってしまいます。 この 田向式MTF水平線 & MA & スクショ枠 は、その面倒な作業を完全に自動化し、さらに**「情報発信者(ブロガー・X民)に嬉しい特殊機能」**を搭載した変態的かつ実用的なインジケーターです。 インジケーターの特徴 MTF自動水平線(幽霊ラベル対策済み) 日足(赤)、4時間足(黄)、1時間足(青)の直近の高値・安値を自動で判定し、常に最新のレジスタンス(R)とサポート(S)を水平線として描画します。 特筆すべきは**「究極の縦軸ラベル表示ロジック」**です。通常のスクリプトでは過去の線にもラベルが残ってしまい縦軸がごちゃごちゃ(幽霊ラベル)になりますが、このインジでは「最新のローソク足」の時だけ価格を読み取ってラベルを表示するため、右端の価格軸が極めてクリアに保たれます。 スクショ用:直近本数フレーム機能 「X(Twitter)やブログにチャートのスクショを貼りたいけど、どこからどこまでを見せればいいか迷う……」という経験はありませんか? このインジケーターには、直近N本(デフォルト100本)の背景をハイライトし、開始地点に縦の点線を引く機能がついています。この「青い枠」の部分だけを切り取ってスクショすれば、**「誰が見ても同じ縮尺で、今一番重要な値動き」**を綺麗に共有することができます。 10 MA(移動平均線)同時表示機能 先ほど公開した「10 MA/DMA Flexible Master」の基本機能も内包しており、SMA・EMA・WMA・RMAを最大10本まで同時表示可能です。 TradingViewへの追加方法 以下のPine Scriptコードをコピーし、TradingViewの画面下部にある「Pineエディタ」に貼り付けて「チャートに追加」をクリックしてください。 [TOOL REQUIREMENT] 稼働必須環境 このオリジナル・インジケーターは、世界標準チャートツール「TradingView」専用です。まだアカウントをお持ちでない方は、先に無料登録を済ませてからチャートに追加してください。 » TradingViewの無料アカウントを作成する //@version=6 indicator("田向式MTF水平線 & MA & スクショ枠", overlay=true, max_lines_count=100) // ========================================== // 1. MTF自動水平線(高安4本制限)の設定 // ========================================== show_labels = input.bool(true, title="価格ラベルを縦軸に表示", group="自動水平線:基本設定") leftBars = input.int(4, title="高安判定の左側足数", minval=1, group="自動水平線:基本設定") rightBars = input.int(4, title="高安判定の右側足数", minval=1, group="自動水平線:基本設定") show_d = input.bool(true, title="表示", group="自動水平線:日足", inline="d") col_d = input.color(color.red, title="色(赤)", group="自動水平線:日足", inline="d") width_d = input.int(2, title="太さ", minval=1, maxval=4, group="自動水平線:日足", inline="d") show_4h = input.bool(true, title="表示", group="自動水平線:4時間足", inline="4h") col_4h = input.color(color.yellow, title="色(黄)", group="自動水平線:4時間足", inline="4h") width_4h = input.int(2, title="太さ", minval=1, maxval=4, group="自動水平線:4時間足", inline="4h") show_1h = input.bool(true, title="表示", group="自動水平線:1時間足", inline="1h") col_1h = input.color(color.blue, title="色(青)", group="自動水平線:1時間足", inline="1h") width_1h = input.int(1, title="太さ", minval=1, maxval=4, group="自動水平線:1時間足", inline="1h") // 高安値取得関数 get_pivots() => ph = ta.pivothigh(high, leftBars, rightBars) pl = ta.pivotlow(low, leftBars, rightBars) ph_series = ta.valuewhen(not na(ph), ph, 0) pl_series = ta.valuewhen(not na(pl), pl, 0) [ph_series, pl_series] // 各時間足データの取得 [ph_d, pl_d] = request.security(syminfo.tickerid, "D", get_pivots(), barmerge.gaps_off, barmerge.lookahead_off) [ph_4h, pl_4h] = request.security(syminfo.tickerid, "240", get_pivots(), barmerge.gaps_off, barmerge.lookahead_off) [ph_1h, pl_1h] = request.security(syminfo.tickerid, "60", get_pivots(), barmerge.gaps_off, barmerge.lookahead_off) // オブジェクト管理変数 var line d_h1 = na, var line d_h2 = na var line d_l1 = na, var line d_l2 = na var line b4_h1 = na, var line b4_h2 = na var line b4_l1 = na, var line b4_l2 = na var line b1_h1 = na, var line b1_h2 = na var line b1_l1 = na, var line b1_l2 = na // ライン生成・消去ロジック(古い線は完全に消去されます) if ta.change(ph_d) != 0 line.delete(d_h2), d_h2 := d_h1, d_h1 := line.new(x1=bar_index-1, y1=ph_d, x2=bar_index, y2=ph_d, color=show_d ? col_d : na, width=width_d, extend=extend.both) if ta.change(pl_d) != 0 line.delete(d_l2), d_l2 := d_l1, d_l1 := line.new(x1=bar_index-1, y1=pl_d, x2=bar_index, y2=pl_d, color=show_d ? col_d : na, width=width_d, extend=extend.both) if ta.change(ph_4h) != 0 line.delete(b4_h2), b4_h2 := b4_h1, b4_h1 := line.new(x1=bar_index-1, y1=ph_4h, x2=bar_index, y2=ph_4h, color=show_4h ? col_4h : na, width=width_4h, extend=extend.both) if ta.change(pl_4h) != 0 line.delete(b4_l2), b4_l2 := b4_l1, b4_l1 := line.new(x1=bar_index-1, y1=pl_4h, x2=bar_index, y2=pl_4h, color=show_4h ? col_4h : na, width=width_4h, extend=extend.both) if ta.change(ph_1h) != 0 line.delete(b1_h2), b1_h2 := b1_h1, b1_h1 := line.new(x1=bar_index-1, y1=ph_1h, x2=bar_index, y2=ph_1h, color=show_1h ? col_1h : na, width=width_1h, extend=extend.both) if ta.change(pl_1h) != 0 line.delete(b1_l2), b1_l2 := b1_l1, b1_l1 := line.new(x1=bar_index-1, y1=pl_1h, x2=bar_index, y2=pl_1h, color=show_1h ? col_1h : na, width=width_1h, extend=extend.both) // ========================================== // ★ 究極の縦軸ラベル表示ロジック(幽霊ラベル対策済み) // barstate.islast(最新のローソク足)の時だけ、現在引かれている線の価格を読み取って縦軸に表示します // 過去の足にはデータが存在しなくなるため、マウスを動かしても古いラベルは一切出ません! // ========================================== plot(barstate.islast and show_labels and show_d and not na(d_h1) ? line.get_y1(d_h1) : na, title="日足R1", color=col_d, display=display.price_scale, editable=false) plot(barstate.islast and show_labels and show_d and not na(d_h2) ? line.get_y1(d_h2) : na, title="日足R2", color=col_d, display=display.price_scale, editable=false) plot(barstate.islast and show_labels and show_d and not na(d_l1) ? line.get_y1(d_l1) : na, title="日足S1", color=col_d, display=display.price_scale, editable=false) plot(barstate.islast and show_labels and show_d and not na(d_l2) ? line.get_y1(d_l2) : na, title="日足S2", color=col_d, display=display.price_scale, editable=false) plot(barstate.islast and show_labels and show_4h and not na(b4_h1) ? line.get_y1(b4_h1) : na, title="4HR1", color=col_4h, display=display.price_scale, editable=false) plot(barstate.islast and show_labels and show_4h and not na(b4_h2) ? line.get_y1(b4_h2) : na, title="4HR2", color=col_4h, display=display.price_scale, editable=false) plot(barstate.islast and show_labels and show_4h and not na(b4_l1) ? line.get_y1(b4_l1) : na, title="4HS1", color=col_4h, display=display.price_scale, editable=false) plot(barstate.islast and show_labels and show_4h and not na(b4_l2) ? line.get_y1(b4_l2) : na, title="4HS2", color=col_4h, display=display.price_scale, editable=false) plot(barstate.islast and show_labels and show_1h and not na(b1_h1) ? line.get_y1(b1_h1) : na, title="1HR1", color=col_1h, display=display.price_scale, editable=false) plot(barstate.islast and show_labels and show_1h and not na(b1_h2) ? line.get_y1(b1_h2) : na, title="1HR2", color=col_1h, display=display.price_scale, editable=false) plot(barstate.islast and show_labels and show_1h and not na(b1_l1) ? line.get_y1(b1_l1) : na, title="1HS1", color=col_1h, display=display.price_scale, editable=false) plot(barstate.islast and show_labels and show_1h and not na(b1_l2) ? line.get_y1(b1_l2) : na, title="1HS2", color=col_1h, display=display.price_scale, editable=false) // ========================================== // 2. スクショ用:直近本数フレーム // ========================================== show_frame = input.bool(true, title="フレーム枠を表示(オン/オフ)", group="スクショ用フレーム設定") frame_bars = input.int(100, title="フレームの本数", minval=1, group="スクショ用フレーム設定") bg_color = input.color(color.new(color.blue, 95), title="背景色", group="スクショ用フレーム設定") line_col = input.color(color.gray, title="縦線の色", group="スクショ用フレーム設定") is_recent = (last_bar_index - bar_index) < frame_bars bgcolor(show_frame and is_recent ? bg_color : na, title="背景ハイライト") var line start_line = na if barstate.islast line.delete(start_line) if show_frame start_line := line.new(bar_index - frame_bars, low, bar_index - frame_bars, high, extend=extend.both, color=line_col, style=line.style_dashed, width=1) // ========================================== // 3. 移動平均線(10本)の設定 // ========================================== get_ma(type, len) => float ma = na switch type "SMA" => ma := ta.sma(close, len) "EMA" => ma := ta.ema(close, len) "WMA" => ma := ta.wma(close, len) "RMA" => ma := ta.rma(close, len) ma t1 = input.string("SMA", title="種類", options=["SMA", "EMA", "WMA", "RMA"], group="MA 1", inline="m1"), l1 = input.int(20, title="期間", group="MA 1", inline="m1"), o1 = input.int(0, title="ずらし幅", group="MA 1", inline="m1") t2 = input.string("SMA", title="種類", options=["SMA", "EMA", "WMA", "RMA"], group="MA 2", inline="m2"), l2 = input.int(50, title="期間", group="MA 2", inline="m2"), o2 = input.int(0, title="ずらし幅", group="MA 2", inline="m2") t3 = input.string("SMA", title="種類", options=["SMA", "EMA", "WMA", "RMA"], group="MA 3", inline="m3"), l3 = input.int(100, title="期間", group="MA 3", inline="m3"), o3 = input.int(0, title="ずらし幅", group="MA 3", inline="m3") t4 = input.string("SMA", title="種類", options=["SMA", "EMA", "WMA", "RMA"], group="MA 4", inline="m4"), l4 = input.int(200, title="期間", group="MA 4", inline="m4"), o4 = input.int(0, title="ずらし幅", group="MA 4", inline="m4") t5 = input.string("SMA", title="種類", options=["SMA", "EMA", "WMA", "RMA"], group="MA 5", inline="m5"), l5 = input.int(20, title="期間", group="MA 5", inline="m5"), o5 = input.int(0, title="ずらし幅", group="MA 5", inline="m5") t6 = input.string("SMA", title="種類", options=["SMA", "EMA", "WMA", "RMA"], group="MA 6", inline="m6"), l6 = input.int(20, title="期間", group="MA 6", inline="m6"), o6 = input.int(0, title="ずらし幅", group="MA 6", inline="m6") t7 = input.string("SMA", title="種類", options=["SMA", "EMA", "WMA", "RMA"], group="MA 7", inline="m7"), l7 = input.int(20, title="期間", group="MA 7", inline="m7"), o7 = input.int(0, title="ずらし幅", group="MA 7", inline="m7") t8 = input.string("SMA", title="種類", options=["SMA", "EMA", "WMA", "RMA"], group="MA 8", inline="m8"), l8 = input.int(20, title="期間", group="MA 8", inline="m8"), o8 = input.int(0, title="ずらし幅", group="MA 8", inline="m8") t9 = input.string("SMA", title="種類", options=["SMA", "EMA", "WMA", "RMA"], group="MA 9", inline="m9"), l9 = input.int(20, title="期間", group="MA 9", inline="m9"), o9 = input.int(0, title="ずらし幅", group="MA 9", inline="m9") t10 = input.string("SMA", title="種類", options=["SMA", "EMA", "WMA", "RMA"], group="MA 10", inline="m10"), l10 = input.int(20, title="期間", group="MA 10", inline="m10"), o10 = input.int(0, title="ずらし幅", group="MA 10", inline="m10") plot(get_ma(t1, l1), offset=o1, title="MA 1", color=color.blue, display=display.pane) plot(get_ma(t2, l2), offset=o2, title="MA 2", color=color.red, display=display.pane) plot(get_ma(t3, l3), offset=o3, title="MA 3", color=color.green, display=display.pane) plot(get_ma(t4, l4), offset=o4, title="MA 4", color=color.purple, display=display.pane) plot(get_ma(t5, l5), offset=o5, title="MA 5", color=color.gray, display=display.pane) plot(get_ma(t6, l6), offset=o6, title="MA 6", color=color.teal, display=display.pane) plot(get_ma(t7, l7), offset=o7, title="MA 7", color=color.fuchsia, display=display.pane) plot(get_ma(t8, l8), offset=o8, title="MA 8", color=color.maroon, display=display.pane) plot(get_ma(t9, l9), offset=o9, title="MA 9", color=color.navy, display=display.pane) plot(get_ma(t10, l10), offset=o10, title="MA 10", color=color.olive, display=display.pane)

2026年7月4日 · 5 min · AutoTrader