OPEN-SOURCE SCRIPT
8menutakeshi

//version=5
indicator("猛の掟・初動スクリーナー(完全版:8項目コメント表示)", overlay=true, max_labels_count=50)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Inputs
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
showPanel = input.bool(true, "コメント表示")
panelPos = input.string("右上", "コメント位置", options=["右上","左上","右下","左下"])
lastBarOnly = input.bool(true, "最後の足だけ更新(推奨)")
// EMA
lenEma1 = input.int(5, "EMA 5", minval=1)
lenEma2 = input.int(13, "EMA 13", minval=1)
lenEma3 = input.int(26, "EMA 26", minval=1)
// MACD
macdFast = input.int(12, "MACD fast", minval=1)
macdSlow = input.int(26, "MACD slow", minval=1)
macdSig = input.int(9, "MACD signal", minval=1)
// Volume
volMaLen = input.int(5, "出来高平均(N日)", minval=1)
volMinMul = input.float(1.3, "出来高倍率Min", step=0.1)
volMaxMul = input.float(2.0, "出来高倍率Max", step=0.1)
volFinalMul = input.float(1.5, "最終三点:出来高倍率(>=)", step=0.1)
// Candle
wickBodyMult = input.float(1.8, "下ヒゲ判定:下ヒゲ/実体 >=", step=0.1)
atrLen = input.int(14, "ATR長", minval=1)
bigBodyATR = input.float(1.2, "大陽線判定:実体 >= ATR×", step=0.1)
// Breakout / Pullback
resLookback = input.int(20, "レジスタンス:過去N日高値", minval=5)
pullMinPct = input.float(5.0, "押し目Min(%)", step=0.5)
pullMaxPct = input.float(15.0, "押し目Max(%)", step=0.5)
retestAllowPct = input.float(1.0, "ブレイク価格の許容下抜け(%)", step=0.1)
stateExpireBars = input.int(30, "ブレイク状態の期限(本数)", minval=5)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Series
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ema5 = ta.ema(close, lenEma1)
ema13 = ta.ema(close, lenEma2)
ema26 = ta.ema(close, lenEma3)
[macdLine, macdSignal, macdHist] = ta.macd(close, macdFast, macdSlow, macdSig)
volAvg = ta.sma(volume, volMaLen)
volMul = volAvg == 0 ? na : (volume / volAvg)
atr = ta.atr(atrLen)
// Candle parts
body = math.abs(close - open)
upperWick = high - math.max(open, close)
lowerWick = math.min(open, close) - low
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 1-3: トレンド
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ema5Up = ema5 > ema5[1]
ema13Up = ema13 > ema13[1]
ema26Up = ema26 > ema26[1]
allEmaUp = ema5Up and ema13Up and ema26Up
golden = (ema5 > ema13) and (ema13 > ema26)
above26_2days = (close > ema26) and (close[1] > ema26[1])
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 4: MACD(ゼロライン上GC)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
macdZeroGC = ta.crossover(macdLine, macdSignal) and (macdLine > 0)
histShrinkToUp = (macdHist > macdHist[1]) and (macdHist[1] < macdHist[2]) // 参考表示
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 5: 出来高
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
volOK = not na(volMul) and (volMul >= volMinMul) and (volMul <= volMaxMul)
volStrongOK = not na(volMul) and (volMul >= volFinalMul) // 最終三点用
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 6: ローソク(ピンバー/包み/大陽線)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
longLowerWick = (body > 0) and ((lowerWick / body) >= wickBodyMult) and (upperWick <= lowerWick * 0.6) and (close > open)
bullEngulf = (close[1] < open[1]) and (close > open) and (open <= close[1]) and (close >= open[1])
bigBull = (close > open) and (body >= atr * bigBodyATR) and (open < ema13) and (close > ema5)
candleOK = longLowerWick or bullEngulf or bigBull
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 7-8: ブレイク後押し目(押し目 -5〜15%)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
res = ta.highest(high, resLookback)[1]
breakout = ta.crossover(close, res)
var bool inBreak = false
var float breakPrice = na
var int breakBar = na
var float postBreakHigh = na
if breakout
inBreak := true
breakPrice := res
breakBar := bar_index
postBreakHigh := high
if inBreak
postBreakHigh := na(postBreakHigh) ? high : math.max(postBreakHigh, high)
pullPct = (inBreak and not na(postBreakHigh) and postBreakHigh != 0) ? (postBreakHigh - close) / postBreakHigh * 100.0 : na
pullOK = not na(pullPct) and (pullPct >= pullMinPct) and (pullPct <= pullMaxPct)
retestOK = inBreak and not na(breakPrice) and (close >= breakPrice * (1 - retestAllowPct/100.0))
breakoutPullbackOK = inBreak and retestOK and pullOK
if inBreak and not na(breakBar) and (bar_index - breakBar > stateExpireBars)
inBreak := false
breakPrice := na
breakBar := na
postBreakHigh := na
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 8項目チェック(1つでも欠けたら見送り)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
chk1 = allEmaUp
chk2 = golden
chk3 = above26_2days
chk4 = macdZeroGC
chk5 = volOK
chk6 = candleOK
chk7 = pullOK
chk8 = breakoutPullbackOK
all8 = chk1 and chk2 and chk3 and chk4 and chk5 and chk6 and chk7 and chk8
// 最終三点(ヒゲ×出来高×MACD)
// ※「成立時は買い確定」の定義に合わせて、all8に加えてfinal3も必須にしている
final3 = longLowerWick and volStrongOK and macdZeroGC
judge = (all8 and final3) ? "判定:買い" : "判定:見送り"
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// コメント文字列(←txt を必ず先に定義)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
fMark(x) => x ? "達成" : "未達"
txt =
"【8項目チェック】\n" +
"1 EMA全上向き: " + fMark(chk1) + "\n" +
"2 黄金隊列: " + fMark(chk2) + "\n" +
"3 26EMA上2日: " + fMark(chk3) + "\n" +
"4 MACDゼロ上GC: " + fMark(chk4) + "\n" +
"5 出来高" + str.tostring(volMinMul) + "-" + str.tostring(volMaxMul) + ": " + fMark(chk5) + "\n" +
"6 ローソク条件: " + fMark(chk6) + "\n" +
"7 押し目-" + str.tostring(pullMinPct) + "〜" + str.tostring(pullMaxPct) + "%: " + fMark(chk7) + "\n" +
"8 ブレイク後押し目: " + fMark(chk8) + "\n\n" +
"最終三点(ヒゲ×出来高×MACD): " + (final3 ? "成立" : "未成立") + "\n" +
judge + "\n\n" +
"(参考)出来高倍率=" + (na(volMul) ? "na" : str.tostring(volMul, "#.00")) +
" / 押し目率=" + (na(pullPct) ? "na" : str.tostring(pullPct, "#.0")) + "%" +
" / hist転換=" + (histShrinkToUp ? "YES" : "NO")
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Table(位置は if で確定。三項演算子で改行しない)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
var pos = position.top_right
if panelPos == "右上"
pos := position.top_right
else if panelPos == "左上"
pos := position.top_left
else if panelPos == "右下"
pos := position.bottom_right
else
pos := position.bottom_left
var table t = table.new(pos, 1, 1)
// 描画条件
drawNow = showPanel and (lastBarOnly ? barstate.islast : true)
bg = (all8 and final3) ? color.new(color.lime, 80) : color.new(color.gray, 15)
fg = color.white
if drawNow
table.cell(t, 0, 0, txt, text_color=fg, bgcolor=bg, text_size=size.small)
else
table.cell(t, 0, 0, "", text_color=fg, bgcolor=color.new(color.black, 100))
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 視覚補助
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
plot(ema5, color=color.new(color.yellow, 0), title="EMA5")
plot(ema13, color=color.new(color.orange, 0), title="EMA13")
plot(ema26, color=color.new(color.red, 0), title="EMA26")
plotshape(all8 and final3, title="BUY", style=shape.triangleup, location=location.belowbar,
color=color.new(color.lime, 0), size=size.tiny, text="BUY")
indicator("猛の掟・初動スクリーナー(完全版:8項目コメント表示)", overlay=true, max_labels_count=50)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Inputs
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
showPanel = input.bool(true, "コメント表示")
panelPos = input.string("右上", "コメント位置", options=["右上","左上","右下","左下"])
lastBarOnly = input.bool(true, "最後の足だけ更新(推奨)")
// EMA
lenEma1 = input.int(5, "EMA 5", minval=1)
lenEma2 = input.int(13, "EMA 13", minval=1)
lenEma3 = input.int(26, "EMA 26", minval=1)
// MACD
macdFast = input.int(12, "MACD fast", minval=1)
macdSlow = input.int(26, "MACD slow", minval=1)
macdSig = input.int(9, "MACD signal", minval=1)
// Volume
volMaLen = input.int(5, "出来高平均(N日)", minval=1)
volMinMul = input.float(1.3, "出来高倍率Min", step=0.1)
volMaxMul = input.float(2.0, "出来高倍率Max", step=0.1)
volFinalMul = input.float(1.5, "最終三点:出来高倍率(>=)", step=0.1)
// Candle
wickBodyMult = input.float(1.8, "下ヒゲ判定:下ヒゲ/実体 >=", step=0.1)
atrLen = input.int(14, "ATR長", minval=1)
bigBodyATR = input.float(1.2, "大陽線判定:実体 >= ATR×", step=0.1)
// Breakout / Pullback
resLookback = input.int(20, "レジスタンス:過去N日高値", minval=5)
pullMinPct = input.float(5.0, "押し目Min(%)", step=0.5)
pullMaxPct = input.float(15.0, "押し目Max(%)", step=0.5)
retestAllowPct = input.float(1.0, "ブレイク価格の許容下抜け(%)", step=0.1)
stateExpireBars = input.int(30, "ブレイク状態の期限(本数)", minval=5)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Series
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ema5 = ta.ema(close, lenEma1)
ema13 = ta.ema(close, lenEma2)
ema26 = ta.ema(close, lenEma3)
[macdLine, macdSignal, macdHist] = ta.macd(close, macdFast, macdSlow, macdSig)
volAvg = ta.sma(volume, volMaLen)
volMul = volAvg == 0 ? na : (volume / volAvg)
atr = ta.atr(atrLen)
// Candle parts
body = math.abs(close - open)
upperWick = high - math.max(open, close)
lowerWick = math.min(open, close) - low
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 1-3: トレンド
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ema5Up = ema5 > ema5[1]
ema13Up = ema13 > ema13[1]
ema26Up = ema26 > ema26[1]
allEmaUp = ema5Up and ema13Up and ema26Up
golden = (ema5 > ema13) and (ema13 > ema26)
above26_2days = (close > ema26) and (close[1] > ema26[1])
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 4: MACD(ゼロライン上GC)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
macdZeroGC = ta.crossover(macdLine, macdSignal) and (macdLine > 0)
histShrinkToUp = (macdHist > macdHist[1]) and (macdHist[1] < macdHist[2]) // 参考表示
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 5: 出来高
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
volOK = not na(volMul) and (volMul >= volMinMul) and (volMul <= volMaxMul)
volStrongOK = not na(volMul) and (volMul >= volFinalMul) // 最終三点用
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 6: ローソク(ピンバー/包み/大陽線)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
longLowerWick = (body > 0) and ((lowerWick / body) >= wickBodyMult) and (upperWick <= lowerWick * 0.6) and (close > open)
bullEngulf = (close[1] < open[1]) and (close > open) and (open <= close[1]) and (close >= open[1])
bigBull = (close > open) and (body >= atr * bigBodyATR) and (open < ema13) and (close > ema5)
candleOK = longLowerWick or bullEngulf or bigBull
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 7-8: ブレイク後押し目(押し目 -5〜15%)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
res = ta.highest(high, resLookback)[1]
breakout = ta.crossover(close, res)
var bool inBreak = false
var float breakPrice = na
var int breakBar = na
var float postBreakHigh = na
if breakout
inBreak := true
breakPrice := res
breakBar := bar_index
postBreakHigh := high
if inBreak
postBreakHigh := na(postBreakHigh) ? high : math.max(postBreakHigh, high)
pullPct = (inBreak and not na(postBreakHigh) and postBreakHigh != 0) ? (postBreakHigh - close) / postBreakHigh * 100.0 : na
pullOK = not na(pullPct) and (pullPct >= pullMinPct) and (pullPct <= pullMaxPct)
retestOK = inBreak and not na(breakPrice) and (close >= breakPrice * (1 - retestAllowPct/100.0))
breakoutPullbackOK = inBreak and retestOK and pullOK
if inBreak and not na(breakBar) and (bar_index - breakBar > stateExpireBars)
inBreak := false
breakPrice := na
breakBar := na
postBreakHigh := na
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 8項目チェック(1つでも欠けたら見送り)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
chk1 = allEmaUp
chk2 = golden
chk3 = above26_2days
chk4 = macdZeroGC
chk5 = volOK
chk6 = candleOK
chk7 = pullOK
chk8 = breakoutPullbackOK
all8 = chk1 and chk2 and chk3 and chk4 and chk5 and chk6 and chk7 and chk8
// 最終三点(ヒゲ×出来高×MACD)
// ※「成立時は買い確定」の定義に合わせて、all8に加えてfinal3も必須にしている
final3 = longLowerWick and volStrongOK and macdZeroGC
judge = (all8 and final3) ? "判定:買い" : "判定:見送り"
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// コメント文字列(←txt を必ず先に定義)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
fMark(x) => x ? "達成" : "未達"
txt =
"【8項目チェック】\n" +
"1 EMA全上向き: " + fMark(chk1) + "\n" +
"2 黄金隊列: " + fMark(chk2) + "\n" +
"3 26EMA上2日: " + fMark(chk3) + "\n" +
"4 MACDゼロ上GC: " + fMark(chk4) + "\n" +
"5 出来高" + str.tostring(volMinMul) + "-" + str.tostring(volMaxMul) + ": " + fMark(chk5) + "\n" +
"6 ローソク条件: " + fMark(chk6) + "\n" +
"7 押し目-" + str.tostring(pullMinPct) + "〜" + str.tostring(pullMaxPct) + "%: " + fMark(chk7) + "\n" +
"8 ブレイク後押し目: " + fMark(chk8) + "\n\n" +
"最終三点(ヒゲ×出来高×MACD): " + (final3 ? "成立" : "未成立") + "\n" +
judge + "\n\n" +
"(参考)出来高倍率=" + (na(volMul) ? "na" : str.tostring(volMul, "#.00")) +
" / 押し目率=" + (na(pullPct) ? "na" : str.tostring(pullPct, "#.0")) + "%" +
" / hist転換=" + (histShrinkToUp ? "YES" : "NO")
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// Table(位置は if で確定。三項演算子で改行しない)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
var pos = position.top_right
if panelPos == "右上"
pos := position.top_right
else if panelPos == "左上"
pos := position.top_left
else if panelPos == "右下"
pos := position.bottom_right
else
pos := position.bottom_left
var table t = table.new(pos, 1, 1)
// 描画条件
drawNow = showPanel and (lastBarOnly ? barstate.islast : true)
bg = (all8 and final3) ? color.new(color.lime, 80) : color.new(color.gray, 15)
fg = color.white
if drawNow
table.cell(t, 0, 0, txt, text_color=fg, bgcolor=bg, text_size=size.small)
else
table.cell(t, 0, 0, "", text_color=fg, bgcolor=color.new(color.black, 100))
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 視覚補助
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
plot(ema5, color=color.new(color.yellow, 0), title="EMA5")
plot(ema13, color=color.new(color.orange, 0), title="EMA13")
plot(ema26, color=color.new(color.red, 0), title="EMA26")
plotshape(all8 and final3, title="BUY", style=shape.triangleup, location=location.belowbar,
color=color.new(color.lime, 0), size=size.tiny, text="BUY")
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.