勉強用インジケーター<無料>

ストップ高研究所
FREE INDICATOR ARCHIVE
無料配布|TradingView

ストップ高
マーカー

過去のストップ高を、日付と縦線でチャート上に刻む。銘柄研究を効率化するためのシンプルなPine Scriptです。

表示例:ストップ高発生日に赤い縦線と日付ラベル、右上に日付一覧を表示。

機能

日足基準で判定

表示中の時間足に関係なく、確定済みの日足データを使って判定します。

縦線と日付ラベル

ストップ高が発生した日をチャート上に縦線と日付で表示します。

発生日一覧

検出した日付を右上などのテーブルにまとめて表示します。

細かな表示設定

色、太さ、ラベル位置、文字サイズ、一覧位置を変更できます。

ロジック

判定ロジック

前日終値を基準値段としてJPXの制限値幅を計算し、当日の高値がストップ高価格に到達したかを確認します。O=H=L=Cとなるロック足も任意で含められます。判定は確定済みの日足に対して行われるため、未確定足の変動による表示の揺れを抑えています。

使い方

  1. TradingViewにログイン無料会員でもPineエディタを利用できます。
  2. チャート下部の「Pineエディタ」を開く既存コードを削除し、このページのコードを貼り付けます。
  3. 「保存」→「チャートに追加」ストップ高の日に赤い縦線と日付ラベルが表示されます。
  4. 設定を調整縦線の色・太さ、ラベル位置、テーブル位置などを変更できます。

配布コード

Pine Script v6
//@version=6
// 日本株個別銘柄向け ストップ高マーカー(日足基準)
// ① ストップ高の日(ロック足 O=H=L=C 含む)に縦線+日付ラベル
// ② ストップ高の日すべての日付をテーブル表示
// ※ どの時間足を表示していても、ストップ高判定は「日足」のみで行う
indicator("日本株 ストップ高マーカー(日足基準)", overlay=true, max_lines_count=500, max_labels_count=500)

// ===== 入力 =====
incLocked = input.bool(true,  "ロック足(O=H=L=C)も含める")
lineCol   = input.color(color.new(color.red, 0), "縦線の色")
lineW     = input.int(1, "縦線の太さ", minval=1, maxval=4)
tblPos    = input.string("top_right", "テーブル位置", options=["top_right","top_left","bottom_right","bottom_left","middle_right"])
rowsPerCol= input.int(30, "1列あたりの行数", minval=5, maxval=60)
tickTol   = input.bool(true, "呼値ズレ許容(高値判定)")
showLbl   = input.bool(true,  "縦線に日付ラベルを表示")
lblPos    = input.string("above", "ラベル位置", options=["above","below"])
lblSize   = input.string("small", "ラベル文字サイズ", options=["tiny","small","normal"])

// ===== JPX 制限値幅(内国株:基準値段別)=====
limitWidth(base) =>
    w = 0.0
    if base < 100
        w := 30
    else if base < 200
        w := 50
    else if base < 500
        w := 80
    else if base < 700
        w := 100
    else if base < 1000
        w := 150
    else if base < 1500
        w := 300
    else if base < 2000
        w := 400
    else if base < 3000
        w := 500
    else if base < 5000
        w := 700
    else if base < 7000
        w := 1000
    else if base < 10000
        w := 1500
    else if base < 15000
        w := 3000
    else if base < 20000
        w := 4000
    else if base < 30000
        w := 5000
    else if base < 50000
        w := 7000
    else if base < 70000
        w := 10000
    else if base < 100000
        w := 15000
    else if base < 150000
        w := 30000
    else if base < 200000
        w := 40000
    else if base < 300000
        w := 50000
    else if base < 500000
        w := 70000
    else if base < 700000
        w := 100000
    else if base < 1000000
        w := 150000
    else
        w := 150000
    w

// ===== 日足データ取得(チャートの時間足に依存しない)=====
[dO, dH, dL, dC, dBase, dT] = request.security(syminfo.tickerid, "D", [open, high, low, close, close[1], time], lookahead=barmerge.lookahead_off)

// 新しい日足バーが確定した最初のチャートバーで、1つ前(=確定済み)の日足を評価
isNewDay = ta.change(dT) != 0
pO    = dO[1]
pH    = dH[1]
pL    = dL[1]
pC    = dC[1]
pBase = dBase[1]
pT    = dT[1]

tol      = tickTol ? syminfo.mintick / 2 : 0.0
sh_price = pBase + limitWidth(pBase)
strictSH = not na(pBase) and math.abs(pH - sh_price) <= tol
lockedSH = not na(pBase) and pO == pH and pH == pL and pL == pC and pC > pBase
isSH     = isNewDay and (strictSH or (incLocked and lockedSH))

// ===== ① 縦線 + 日付ラベル(日足の位置に時刻基準で描画)=====
if isSH
    float y2 = pH == pL ? pH + syminfo.mintick : pH
    line.new(pT, pL, pT, y2, xloc=xloc.bar_time, extend=extend.both, color=lineCol, width=lineW)
    if showLbl
        string d   = str.format_time(pT, "yyyy/MM/dd", "Asia/Tokyo")
        bool   abv = lblPos == "above"
        sz = lblSize == "tiny" ? size.tiny : lblSize == "normal" ? size.normal : size.small
        label.new(pT, abv ? pH : pL, text=d, xloc=xloc.bar_time, yloc=yloc.price, style=abv ? label.style_label_down : label.style_label_up, color=lineCol, textcolor=color.white, size=sz)

// ===== ② 日付収集 =====
var array<string> dates = array.new<string>()
if isSH
    array.push(dates, str.format_time(pT, "yyyy/MM/dd", "Asia/Tokyo"))

// ===== テーブル描画(最終バーのみ)=====
posMap(p) =>
    p == "top_left"      ? position.top_left      :
     p == "bottom_right" ? position.bottom_right  :
     p == "bottom_left"  ? position.bottom_left   :
     p == "middle_right" ? position.middle_right  :
     position.top_right

var table t = na
if barstate.islast
    table.delete(t)
    int n    = array.size(dates)
    int cols = math.max(1, int(math.ceil(n / rowsPerCol)))
    t := table.new(posMap(tblPos), cols, rowsPerCol + 1, border_width=1, frame_color=color.gray, frame_width=1)
    for c = 0 to cols - 1
        string hdr = c == 0 ? "計 " + str.tostring(n) + "件" : "日付"
        table.cell(t, c, 0, hdr, text_color=color.white, bgcolor=color.new(color.red, 0), text_size=size.small)
    if n > 0
        for i = 0 to n - 1
            int c  = int(i / rowsPerCol)
            int rr = i % rowsPerCol + 1
            table.cell(t, c, rr, array.get(dates, i), text_color=color.white, bgcolor=color.new(color.black, 15), text_size=size.small)
本インジケーターは情報提供・学習目的です。判定結果の完全性を保証するものではなく、投資判断は必ず公式情報や取引所情報も確認したうえで、ご自身の責任で行ってください。
ストップ高研究所
タイトルとURLをコピーしました