OPEN-SOURCE SCRIPT
takeshi GPT

//version=5
indicator("猛の掟・初動スクリーナーGPT", overlay = true, timeframe = "", timeframe_gaps = true)
// ======================================================
// ■ 1. パラメータ設定
// ======================================================
// EMA長
emaFastLen = input.int(5, "短期EMA (5)", minval = 1)
emaMidLen = input.int(13, "中期EMA (13)", minval = 1)
emaSlowLen = input.int(26, "長期EMA (26)", minval = 1)
// 出来高
volMaLen = input.int(5, "出来高平均期間", minval = 1)
volMultInitial = input.float(1.3, "出来高 初動ライン (×)", minval = 1.0, step = 0.1)
volMultStrong = input.float(1.5, "出来高 本物ライン (×)", minval = 1.0, step = 0.1)
// 押し目・レジスタンス
pullbackLookback = input.int(20, "直近高値の探索期間", minval = 5)
pullbackMinPct = input.float(5.0, "押し目下限 (%)", minval = 0.0, step = 0.1)
pullbackMaxPct = input.float(15.0, "押し目上限 (%)", minval = 0.0, step = 0.1)
// ピンバー判定パラメータ
pinbarWickRatio = input.float(2.0, "ピンバー下ヒゲ/実体 比率", minval = 1.0, step = 0.5)
pinbarMaxUpperPct = input.float(25.0, "ピンバー上ヒゲ比率上限 (%)", minval = 0.0, step = 1.0)
// 大陽線判定
bigBodyPct = input.float(2.0, "大陽線の最低値幅 (%)", minval = 0.1, step = 0.1)
// ======================================================
// ■ 2. 基本テクニカル計算
// ======================================================
emaFast = ta.ema(close, emaFastLen)
emaMid = ta.ema(close, emaMidLen)
emaSlow = ta.ema(close, emaSlowLen)
// MACD
[macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9)
// 出来高
volMa = ta.sma(volume, volMaLen)
// 直近高値(押し目判定用)
recentHigh = ta.highest(high, pullbackLookback)
drawdownPct = (recentHigh > 0) ? (recentHigh - close) / recentHigh * 100.0 : na
// ======================================================
// ■ 3. A:トレンド(初動)条件
// ======================================================
// 1. 5EMA↑ 13EMA↑ 26EMA↑
emaUpFast = emaFast > emaFast[1]
emaUpMid = emaMid > emaMid[1]
emaUpSlow = emaSlow > emaSlow[1]
condTrendUp = emaUpFast and emaUpMid and emaUpSlow
// 2. 黄金並び 5EMA > 13EMA > 26EMA
condGolden = emaFast > emaMid and emaMid > emaSlow
// 3. ローソク足が 26EMA 上に2日定着
condAboveSlow2 = close > emaSlow and close[1] > emaSlow[1]
// ======================================================
// ■ 4. B:モメンタム(MACD)条件
// ======================================================
// ヒストグラム縮小+上向き
histShrinkingUp = (math.abs(histLine) < math.abs(histLine[1])) and (histLine > histLine[1])
// ゼロライン直下〜直上での上向き
nearZeroRange = 0.5 // ゼロライン±0.5
macdNearZero = math.abs(macdLine) <= nearZeroRange
// MACDが上向き
macdTurningUp = macdLine > macdLine[1]
// MACDゼロライン上でゴールデンクロス
macdZeroCrossUp = macdLine > signalLine and macdLine[1] <= signalLine[1] and macdLine > 0
// B条件:すべて
condMACD = histShrinkingUp and macdNearZero and macdTurningUp and macdZeroCrossUp
// ======================================================
// ■ 5. C:需給(出来高)条件
// ======================================================
condVolInitial = volume > volMa * volMultInitial // 1.3倍〜 初動点灯
condVolStrong = volume > volMa * volMultStrong // 1.5倍〜 本物初動
condVolume = condVolInitial // 「8掟」では1.3倍以上で合格
// ======================================================
// ■ 6. D:ローソク足パターン
// ======================================================
body = math.abs(close - open)
upperWick = high - math.max(close, open)
lowerWick = math.min(close, open) - low
rangeAll = high - low
// 安全対策:0除算回避
rangeAllSafe = rangeAll == 0.0 ? 0.0000001 : rangeAll
bodyPct = body / close * 100.0
// ● 長い下ヒゲ(ピンバー)
lowerToBodyRatio = (body > 0) ? lowerWick / body : 0.0
upperPct = upperWick / rangeAllSafe * 100.0
isBullPinbar = lowerToBodyRatio >= pinbarWickRatio and upperPct <= pinbarMaxUpperPct and close > open
// ● 陽線包み足(bullish engulfing)
prevBearish = close[1] < open[1]
isEngulfingBull = close > open and prevBearish and close >= open[1] and open <= close[1]
// ● 5EMA・13EMAを貫く大陽線
crossFast = open < emaFast and close > emaFast
crossMid = open < emaMid and close > emaMid
isBigBody = bodyPct >= bigBodyPct
isBigBull = close > open and (crossFast or crossMid) and isBigBody
// D条件:どれか1つでOK
condCandle = isBullPinbar or isEngulfingBull or isBigBull
// ======================================================
// ■ 7. E:価格帯(押し目位置 & レジスタンスブレイク)
// ======================================================
// 7. 押し目 -5〜15%
condPullback = drawdownPct >= pullbackMinPct and drawdownPct <= pullbackMaxPct
// 8. レジスタンス突破 → 押し目 → 再上昇
// 直近 pullbackLookback 本の高値をレジスタンスとみなす(現在足除く)
resistance = ta.highest(close[1], pullbackLookback)
// レジスタンスブレイクが起きたバーからの経過本数
brokeAbove = ta.barssince(close > resistance)
// ブレイク後に一度レジ上まで戻したか
pulledBack = brokeAbove != na ? ta.lowest(low, brokeAbove + 1) < resistance : false
// 現在は再上昇方向か
reRising = close > close[1]
condBreakPull = (brokeAbove != na) and (brokeAbove <= pullbackLookback) and pulledBack and reRising
// ======================================================
// ■ 8. 最終 8条件 & 三点シグナル
// ======================================================
// 8つの掟
condA = condTrendUp and condGolden and condAboveSlow2
condB = condMACD
condC = condVolume
condD = condCandle
condE = condPullback and condBreakPull
all_conditions = condA and condB and condC and condD and condE
// 🟩 最終三点シグナル
// 1. 長い下ヒゲ 2. MACDゼロライン上GC 3. 出来高1.5倍以上
threePoint = isBullPinbar and macdZeroCrossUp and condVolStrong
// 「買い確定」= 8条件すべて + 三点シグナル
buy_confirmed = all_conditions and threePoint
// ======================================================
// ■ 9. チャート表示 & スクリーナー用出力
// ======================================================
// EMA表示
plot(emaFast, color = color.orange, title = "EMA 5")
plot(emaMid, color = color.new(color.blue, 10), title = "EMA 13")
plot(emaSlow, color = color.new(color.green, 20), title = "EMA 26")
// 初動シグナル
plotshape(
all_conditions and not buy_confirmed,
title = "初動シグナル(掟8条件クリア)",
style = shape.labelup,
color = color.new(color.yellow, 0),
text = "初動",
location = location.belowbar,
size = size.small)
// 三点フルシグナル(買い確定)
plotshape(
buy_confirmed,
title = "三点フルシグナル(買い確定)",
style = shape.labelup,
color = color.new(color.lime, 0),
text = "買い",
location = location.belowbar,
size = size.large)
// スクリーナー用 series 出力(非表示)
plot(all_conditions ? 1 : 0, title = "all_conditions (8掟クリア)", display = display.none)
plot(buy_confirmed ? 1 : 0, title = "buy_confirmed (三点+8掟)", display = display.none)
indicator("猛の掟・初動スクリーナーGPT", overlay = true, timeframe = "", timeframe_gaps = true)
// ======================================================
// ■ 1. パラメータ設定
// ======================================================
// EMA長
emaFastLen = input.int(5, "短期EMA (5)", minval = 1)
emaMidLen = input.int(13, "中期EMA (13)", minval = 1)
emaSlowLen = input.int(26, "長期EMA (26)", minval = 1)
// 出来高
volMaLen = input.int(5, "出来高平均期間", minval = 1)
volMultInitial = input.float(1.3, "出来高 初動ライン (×)", minval = 1.0, step = 0.1)
volMultStrong = input.float(1.5, "出来高 本物ライン (×)", minval = 1.0, step = 0.1)
// 押し目・レジスタンス
pullbackLookback = input.int(20, "直近高値の探索期間", minval = 5)
pullbackMinPct = input.float(5.0, "押し目下限 (%)", minval = 0.0, step = 0.1)
pullbackMaxPct = input.float(15.0, "押し目上限 (%)", minval = 0.0, step = 0.1)
// ピンバー判定パラメータ
pinbarWickRatio = input.float(2.0, "ピンバー下ヒゲ/実体 比率", minval = 1.0, step = 0.5)
pinbarMaxUpperPct = input.float(25.0, "ピンバー上ヒゲ比率上限 (%)", minval = 0.0, step = 1.0)
// 大陽線判定
bigBodyPct = input.float(2.0, "大陽線の最低値幅 (%)", minval = 0.1, step = 0.1)
// ======================================================
// ■ 2. 基本テクニカル計算
// ======================================================
emaFast = ta.ema(close, emaFastLen)
emaMid = ta.ema(close, emaMidLen)
emaSlow = ta.ema(close, emaSlowLen)
// MACD
[macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9)
// 出来高
volMa = ta.sma(volume, volMaLen)
// 直近高値(押し目判定用)
recentHigh = ta.highest(high, pullbackLookback)
drawdownPct = (recentHigh > 0) ? (recentHigh - close) / recentHigh * 100.0 : na
// ======================================================
// ■ 3. A:トレンド(初動)条件
// ======================================================
// 1. 5EMA↑ 13EMA↑ 26EMA↑
emaUpFast = emaFast > emaFast[1]
emaUpMid = emaMid > emaMid[1]
emaUpSlow = emaSlow > emaSlow[1]
condTrendUp = emaUpFast and emaUpMid and emaUpSlow
// 2. 黄金並び 5EMA > 13EMA > 26EMA
condGolden = emaFast > emaMid and emaMid > emaSlow
// 3. ローソク足が 26EMA 上に2日定着
condAboveSlow2 = close > emaSlow and close[1] > emaSlow[1]
// ======================================================
// ■ 4. B:モメンタム(MACD)条件
// ======================================================
// ヒストグラム縮小+上向き
histShrinkingUp = (math.abs(histLine) < math.abs(histLine[1])) and (histLine > histLine[1])
// ゼロライン直下〜直上での上向き
nearZeroRange = 0.5 // ゼロライン±0.5
macdNearZero = math.abs(macdLine) <= nearZeroRange
// MACDが上向き
macdTurningUp = macdLine > macdLine[1]
// MACDゼロライン上でゴールデンクロス
macdZeroCrossUp = macdLine > signalLine and macdLine[1] <= signalLine[1] and macdLine > 0
// B条件:すべて
condMACD = histShrinkingUp and macdNearZero and macdTurningUp and macdZeroCrossUp
// ======================================================
// ■ 5. C:需給(出来高)条件
// ======================================================
condVolInitial = volume > volMa * volMultInitial // 1.3倍〜 初動点灯
condVolStrong = volume > volMa * volMultStrong // 1.5倍〜 本物初動
condVolume = condVolInitial // 「8掟」では1.3倍以上で合格
// ======================================================
// ■ 6. D:ローソク足パターン
// ======================================================
body = math.abs(close - open)
upperWick = high - math.max(close, open)
lowerWick = math.min(close, open) - low
rangeAll = high - low
// 安全対策:0除算回避
rangeAllSafe = rangeAll == 0.0 ? 0.0000001 : rangeAll
bodyPct = body / close * 100.0
// ● 長い下ヒゲ(ピンバー)
lowerToBodyRatio = (body > 0) ? lowerWick / body : 0.0
upperPct = upperWick / rangeAllSafe * 100.0
isBullPinbar = lowerToBodyRatio >= pinbarWickRatio and upperPct <= pinbarMaxUpperPct and close > open
// ● 陽線包み足(bullish engulfing)
prevBearish = close[1] < open[1]
isEngulfingBull = close > open and prevBearish and close >= open[1] and open <= close[1]
// ● 5EMA・13EMAを貫く大陽線
crossFast = open < emaFast and close > emaFast
crossMid = open < emaMid and close > emaMid
isBigBody = bodyPct >= bigBodyPct
isBigBull = close > open and (crossFast or crossMid) and isBigBody
// D条件:どれか1つでOK
condCandle = isBullPinbar or isEngulfingBull or isBigBull
// ======================================================
// ■ 7. E:価格帯(押し目位置 & レジスタンスブレイク)
// ======================================================
// 7. 押し目 -5〜15%
condPullback = drawdownPct >= pullbackMinPct and drawdownPct <= pullbackMaxPct
// 8. レジスタンス突破 → 押し目 → 再上昇
// 直近 pullbackLookback 本の高値をレジスタンスとみなす(現在足除く)
resistance = ta.highest(close[1], pullbackLookback)
// レジスタンスブレイクが起きたバーからの経過本数
brokeAbove = ta.barssince(close > resistance)
// ブレイク後に一度レジ上まで戻したか
pulledBack = brokeAbove != na ? ta.lowest(low, brokeAbove + 1) < resistance : false
// 現在は再上昇方向か
reRising = close > close[1]
condBreakPull = (brokeAbove != na) and (brokeAbove <= pullbackLookback) and pulledBack and reRising
// ======================================================
// ■ 8. 最終 8条件 & 三点シグナル
// ======================================================
// 8つの掟
condA = condTrendUp and condGolden and condAboveSlow2
condB = condMACD
condC = condVolume
condD = condCandle
condE = condPullback and condBreakPull
all_conditions = condA and condB and condC and condD and condE
// 🟩 最終三点シグナル
// 1. 長い下ヒゲ 2. MACDゼロライン上GC 3. 出来高1.5倍以上
threePoint = isBullPinbar and macdZeroCrossUp and condVolStrong
// 「買い確定」= 8条件すべて + 三点シグナル
buy_confirmed = all_conditions and threePoint
// ======================================================
// ■ 9. チャート表示 & スクリーナー用出力
// ======================================================
// EMA表示
plot(emaFast, color = color.orange, title = "EMA 5")
plot(emaMid, color = color.new(color.blue, 10), title = "EMA 13")
plot(emaSlow, color = color.new(color.green, 20), title = "EMA 26")
// 初動シグナル
plotshape(
all_conditions and not buy_confirmed,
title = "初動シグナル(掟8条件クリア)",
style = shape.labelup,
color = color.new(color.yellow, 0),
text = "初動",
location = location.belowbar,
size = size.small)
// 三点フルシグナル(買い確定)
plotshape(
buy_confirmed,
title = "三点フルシグナル(買い確定)",
style = shape.labelup,
color = color.new(color.lime, 0),
text = "買い",
location = location.belowbar,
size = size.large)
// スクリーナー用 series 出力(非表示)
plot(all_conditions ? 1 : 0, title = "all_conditions (8掟クリア)", display = display.none)
plot(buy_confirmed ? 1 : 0, title = "buy_confirmed (三点+8掟)", display = display.none)
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.