OPEN-SOURCE SCRIPT

猛の掟・初動スクリーナー_完成版

25
//version=5
indicator("猛の掟・初動スクリーナー_完成版", overlay=true)

// =============================
// 入力パラメータ
// =============================
emaLenShort = input.int(5, "短期EMA", minval=1)
emaLenMid = input.int(13, "中期EMA", minval=1)
emaLenLong = input.int(26, "長期EMA", minval=1)

macdFastLen = input.int(12, "MACD Fast", minval=1)
macdSlowLen = input.int(26, "MACD Slow", minval=1)
macdSignalLen = input.int(9, "MACD Signal", minval=1)
macdZeroTh = input.float(0.2, "MACDゼロライン近辺とみなす許容値", step=0.05)

volMaLen = input.int(5, "出来高平均日数", minval=1)
volMinRatio = input.float(1.3, "出来高倍率(初動判定しきい値)", step=0.1)
volStrongRatio = input.float(1.5, "出来高倍率(本物/三点シグナル用)", step=0.1)

highLookback = input.int(60, "直近高値の参照本数", minval=10)
pullbackMin = input.float(5.0, "押し目最小[%]", step=0.5)
pullbackMax = input.float(15.0, "押し目最大[%]", step=0.5)
breakLookback = input.int(15, "レジブレ後とみなす本数", minval=1)

wickBodyMult = input.float(2.0, "ピンバー:下ヒゲが実体の何倍以上か", step=0.5)

// ★ シグナル表示 ON/OFF
showMou = input.bool(true, "猛シグナルを表示")
showKaku = input.bool(true, "確シグナルを表示")

// =============================
// 基本指標計算
// =============================
emaShort = ta.ema(close, emaLenShort)
emaMid = ta.ema(close, emaLenMid)
emaLong = ta.ema(close, emaLenLong)

[macdLine, macdSignal, macdHist] = ta.macd(close, macdFastLen, macdSlowLen, macdSignalLen)

volMa = ta.sma(volume, volMaLen)
volRatio = volMa > 0 ? volume / volMa : 0.0

recentHigh = ta.highest(high, highLookback)
prevHigh = ta.highest(high[1], highLookback)
pullbackPct = recentHigh > 0 ? (recentHigh - close) / recentHigh * 100.0 : 0.0

// ローソク足
body = math.abs(close - open)
upperWick = high - math.max(open, close)
lowerWick = math.min(open, close) - low

// =============================
// A:トレンド条件
// =============================
emaUp = emaShort > emaShort[1] and emaMid > emaMid[1] and emaLong > emaLong[1]
goldenOrder = emaShort > emaMid and emaMid > emaLong
aboveEma2 = close > emaLong and close[1] > emaLong[1]

trendOK = emaUp and goldenOrder and aboveEma2

// =============================
// B:MACD条件
// =============================
macdGC = ta.crossover(macdLine, macdSignal)
macdNearZero = math.abs(macdLine) <= macdZeroTh
macdUp = macdLine > macdLine[1]

macdOK = macdGC and macdNearZero and macdUp

// =============================
// C:出来高条件
// =============================
volInitOK = volRatio >= volMinRatio // 8条件用
volStrongOK = volRatio >= volStrongRatio // 三点シグナル用

volumeOK = volInitOK

// =============================
// D:ローソク足パターン
// =============================
isBullPinbar = lowerWick > wickBodyMult * body and lowerWick > upperWick and close >= open
isBullEngulf = close > open and open < close[1] and close > open[1]
isBigBullCross = close > emaShort and close > emaMid and open < emaShort and open < emaMid and close > open

candleOK = isBullPinbar or isBullEngulf or isBigBullCross

// =============================
// E:価格帯(押し目&レジブレ)
// =============================
pullbackOK = pullbackPct >= pullbackMin and pullbackPct <= pullbackMax

isBreakout = close > prevHigh and close[1] <= prevHigh
barsSinceBreak = ta.barssince(isBreakout)
afterBreakZone = barsSinceBreak >= 0 and barsSinceBreak <= breakLookback

afterBreakPullbackOK = afterBreakZone and pullbackOK and close > emaShort

priceOK = pullbackOK and afterBreakPullbackOK

// =============================
// 8条件の統合
// =============================
allRulesOK = trendOK and macdOK and volumeOK and candleOK and priceOK

// =============================
// 最終三点シグナル
// =============================
longLowerWick = lowerWick > wickBodyMult * body and lowerWick > upperWick
macdGCAboveZero = ta.crossover(macdLine, macdSignal) and macdLine > 0
volumeSpike = volStrongOK

finalThreeSignal = longLowerWick and macdGCAboveZero and volumeSpike

buyConfirmed = allRulesOK and finalThreeSignal

// =============================
// 描画
// =============================
plot(emaShort, color=color.new(color.yellow, 0), title="EMA 短期(5)")
plot(emaMid, color=color.new(color.orange, 0), title="EMA 中期(13)")
plot(emaLong, color=color.new(color.blue, 0), title="EMA 長期(26)")

// シグナル表示(ON/OFF付き)
plotshape(showMou and allRulesOK, title="猛の掟 8条件クリア候補", location=location.belowbar, color=color.new(color.lime, 0), text="猛")
plotshape(showKaku and buyConfirmed, title="猛の掟 最終三点シグナル確定", location=location.belowbar, color=color.new(color.yellow, 0), text="確")

// =============================
// アラート条件
// =============================
alertcondition(allRulesOK, title="猛の掟 8条件クリア候補", message="猛の掟 8条件クリア候補シグナル発生")
alertcondition(buyConfirmed, title="猛の掟 最終三点シグナル確定", message="猛の掟 最終三点シグナル=買い確定")

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.