5日と50日移動平均線、25日と200日移動平均線

25日移動平均線が200日移動平均線を下回ったら暴落中盤。これは予兆ではない。5日移動平均線が50日移動平均線をクロスした時のほうが予兆らしさがあるように思う。

TradingViewの大きなチャート画面右下にある「…」を選択して「pineエディタ」を選び、タイトルから新規作成でライブラリを使う。左にある数字を選択しながら文字を消去し、長押しして下記をペーストする。タイトルから「スクリプトを保存」しておき、「スクリプトを開く」で「☆」マークをタッチして色をつけると、チャート画面の下2段目にあるグラフマークのお気に入りに選択肢として表示されるようになる。

【MA + Price Divergence + McClellan + Hindenburg + Numeric MA Signals】


//@version=5
indicator("MA + Price Divergence + McClellan + Hindenburg + Numeric MA Signals", overlay=true, max_lines_count=500, max_labels_count=500)

// ====================
// MA構造(5・25・50・75・200)
// ====================
ma5   = ta.sma(close, 5)
ma25  = ta.sma(close, 25)
ma50  = ta.sma(close, 50)
ma75  = ta.sma(close, 75)
ma200 = ta.sma(close, 200)

plot(ma5,   color=color.white)
plot(ma25,  color=color.yellow)
plot(ma50,  color=color.blue)
plot(ma75,  color=color.orange)
plot(ma200, color=color.red)

// ====================
// 5日50日クロス(数字ラベル表示)
// ====================
bear_5_50 = ta.crossunder(ma5, ma50)
bull_5_50 = ta.crossover(ma5, ma50)

if bear_5_50
    label.new(bar_index, high, "5-50", color=color.blue, textcolor=color.white, style=label.style_label_down)

if bull_5_50
    label.new(bar_index, low, "5-50", color=color.blue, textcolor=color.white, style=label.style_label_up)

// ====================
// 25日200日クロス(数字ラベル表示)
// ====================
bear_25_200 = ta.crossunder(ma25, ma200)
bull_25_200 = ta.crossover(ma25, ma200)

if bear_25_200
    label.new(bar_index, high, "25-200", color=color.red, textcolor=color.white, style=label.style_label_down)

if bull_25_200
    label.new(bar_index, low, "25-200", color=color.red, textcolor=color.white, style=label.style_label_up)

// ====================
// 他の MA クロスは非表示(titleなし)
// ====================
bear_5_25  = ta.crossunder(ma5, ma25)
bear_5_75  = ta.crossunder(ma5, ma75)
bear_25_50 = ta.crossunder(ma25, ma50)
bear_25_75 = ta.crossunder(ma25, ma75)
bear_50_200 = ta.crossunder(ma50, ma200)
bear_75_200 = ta.crossunder(ma75, ma200)

plotshape(bear_5_25,  style=shape.triangledown, color=color.gray,   location=location.abovebar, text="5<25")
plotshape(bear_5_75,  style=shape.triangledown, color=color.orange, location=location.abovebar, text="5<75")
plotshape(bear_25_50, style=shape.triangledown, color=color.yellow, location=location.abovebar, text="25<50")
plotshape(bear_25_75, style=shape.triangledown, color=color.red,    location=location.abovebar, text="25<75")
plotshape(bear_50_200, style=shape.triangledown, color=color.purple, location=location.abovebar, text="50<200")
plotshape(bear_75_200, style=shape.triangledown, color=color.fuchsia, location=location.abovebar, text="75<200")

// ====================
// 価格ダイバージェンス
// ====================
pivot_len = 5
ph = ta.pivothigh(high, pivot_len, pivot_len)
pl = ta.pivotlow(low,  pivot_len, pivot_len)
osc_ph = ta.pivothigh(close, pivot_len, pivot_len)
osc_pl = ta.pivotlow(close,  pivot_len, pivot_len)

bull_div_price = not na(pl) and not na(osc_pl) and pl < nz(pl[pivot_len*2]) and osc_pl > nz(osc_pl[pivot_len*2])
bear_div_price = not na(ph) and not na(osc_ph) and ph > nz(ph[pivot_len*2]) and osc_ph < nz(osc_ph[pivot_len*2])

plotshape(bull_div_price, style=shape.labelup,   color=color.lime,   text="BullDiv(P)")
plotshape(bear_div_price, style=shape.labeldown, color=color.red,    text="BearDiv(P)")

// ====================
// McClellan(簡易版)
// ====================
ad = close - close[1]
mcc = ta.ema(ad, 19) - ta.ema(ad, 39)

// ====================
// ヒンデンブルグオーメン(簡易版)
// ====================
cond1 = close > ma200
cond2 = close < ma75
cond3 = high == ta.highest(high, 20) and low == ta.lowest(low, 20)
cond4 = mcc < 0

hindenburg = cond1 and cond2 and cond3 and cond4

plotshape(hindenburg, style=shape.circle, color=color.fuchsia, size=size.small,location=location.abovebar, text="Hindenburg")