OPEN-SOURCE SCRIPT
takeshi MNO_2Step_Screener_MOU_MOUB_KAKU

//version=5
indicator("MNO_2Step_Screener_MOU_MOUB_KAKU", overlay=true, max_labels_count=500, max_lines_count=500)
// =========================
// Inputs
// =========================
emaSLen = input.int(5, "EMA Short (5)", minval=1)
emaMLen = input.int(13, "EMA Mid (13)", minval=1)
emaLLen = input.int(26, "EMA Long (26)", minval=1)
macdFast = input.int(12, "MACD Fast", minval=1)
macdSlow = input.int(26, "MACD Slow", minval=1)
macdSignal = input.int(9, "MACD Signal", minval=1)
macdZeroTh = input.float(0.2, "MOU: MACD near-zero threshold", step=0.05)
volDays = input.int(5, "Volume avg (days equivalent)", minval=1)
volMinRatio = input.float(1.3, "MOU: Volume ratio min", step=0.1)
volStrong = input.float(1.5, "Strong volume ratio (MOU-B/KAKU)", step=0.1)
volMaxRatio = input.float(3.0, "Volume ratio max (filter)", step=0.1)
wickBodyMult = input.float(2.0, "Pinbar: lowerWick >= body*x", step=0.1)
pivotLen = input.int(20, "Resistance lookback", minval=5)
pullMinPct = input.float(5.0, "Pullback min (%)", step=0.1)
pullMaxPct = input.float(15.0, "Pullback max (%)", step=0.1)
breakLookbackBars = input.int(5, "Valid bars after break", minval=1)
showEMA = input.bool(true, "Plot EMAs")
showLabels = input.bool(true, "Show labels (猛/猛B/確)")
showShapes = input.bool(true, "Show shapes (猛/猛B/確)")
confirmOnClose = input.bool(true, "Signal only on bar close (recommended)")
locChoice = input.string("Below", "Label location", options=["Below","Above"])
lblLoc = locChoice == "Below" ? location.belowbar : location.abovebar
// =========================
// EMA
// =========================
emaS = ta.ema(close, emaSLen)
emaM = ta.ema(close, emaMLen)
emaL = ta.ema(close, emaLLen)
plot(showEMA ? emaS : na, color=color.new(color.yellow, 0), title="EMA 5")
plot(showEMA ? emaM : na, color=color.new(color.blue, 0), title="EMA 13")
plot(showEMA ? emaL : na, color=color.new(color.orange, 0), title="EMA 26")
emaUpS = emaS > emaS[1]
emaUpM = emaM > emaM[1]
emaUpL = emaL > emaL[1]
goldenOrder = emaS > emaM and emaM > emaL
above26_2bars = close > emaL and close[1] > emaL[1]
baseTrendOK = (emaUpS and emaUpM and emaUpL) and goldenOrder and above26_2bars
// =========================
// MACD
// =========================
[macdLine, macdSig, macdHist] = ta.macd(close, macdFast, macdSlow, macdSignal)
macdGC = ta.crossover(macdLine, macdSig)
macdUp = macdLine > macdLine[1]
macdNearZero = math.abs(macdLine) <= macdZeroTh
macdGCAboveZero = macdGC and macdLine > 0 and macdSig > 0
macdMouOK = macdGC and macdNearZero and macdUp
macdKakuOK = macdGCAboveZero
// =========================
// Volume (days -> bars)
// =========================
sec = timeframe.in_seconds(timeframe.period)
barsPerDay = (sec > 0 and sec < 86400) ? math.round(86400 / sec) : 1
volLookbackBars = math.max(1, volDays * barsPerDay)
volMA = ta.sma(volume, volLookbackBars)
volRatio = volMA > 0 ? (volume / volMA) : na
volumeMouOK = not na(volRatio) and volRatio >= volMinRatio and volRatio <= volMaxRatio
volumeStrongOK = not na(volRatio) and volRatio >= volStrong and volRatio <= volMaxRatio
// =========================
// Candle patterns
// =========================
body = math.abs(close - open)
upperWick = high - math.max(open, close)
lowerWick = math.min(open, close) - low
pinbar = (body > 0) and (lowerWick >= wickBodyMult * body) and (lowerWick > upperWick) and (close >= open)
bullEngulf = close > open and close[1] < open[1] and close >= open[1] and open <= close[1]
bigBull = close > open and open < emaM and close > emaS and (body > ta.sma(body, 20))
candleOK = pinbar or bullEngulf or bigBull
// =========================
// Resistance / Pullback route
// =========================
res = ta.highest(high, pivotLen)
pullbackPct = res > 0 ? (res - close) / res * 100.0 : na
pullbackOK = not na(pullbackPct) and pullbackPct >= pullMinPct and pullbackPct <= pullMaxPct
brokeRes = ta.crossover(close, res[1])
barsSinceBreak = ta.barssince(brokeRes)
afterBreakZone = (barsSinceBreak >= 0) and (barsSinceBreak <= breakLookbackBars)
pullbackRouteOK = afterBreakZone and pullbackOK
// =========================
// Signals (猛 / 猛B / 確)
// =========================
mou_pullback = baseTrendOK and volumeMouOK and candleOK and macdMouOK and pullbackRouteOK
mou_breakout = baseTrendOK and ta.crossover(close, res[1]) and volumeStrongOK and macdKakuOK
cond1 = emaUpS and emaUpM and emaUpL
cond2 = goldenOrder
cond3 = above26_2bars
cond4 = macdKakuOK
cond5 = volumeMouOK
cond6 = candleOK
cond7 = pullbackOK
cond8 = pullbackRouteOK
all8 = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 and cond7 and cond8
final3 = pinbar and macdKakuOK and volumeStrongOK
kaku = all8 and final3
// 確優先(同一足は確だけ出す)
confirmed = confirmOnClose ? barstate.isconfirmed : true
sigKAKU = kaku and confirmed
sigMOU = mou_pullback and not kaku and confirmed
sigMOUB = mou_breakout and not kaku and confirmed
// =========================
// Visualization
// =========================
if showLabels and sigMOU
label.new(bar_index, low, "猛", style=label.style_label_up, color=color.new(color.lime, 0), textcolor=color.black)
if showLabels and sigMOUB
label.new(bar_index, low, "猛B", style=label.style_label_up, color=color.new(color.green, 0), textcolor=color.black)
if showLabels and sigKAKU
label.new(bar_index, low, "確", style=label.style_label_up, color=color.new(color.yellow, 0), textcolor=color.black)
plotshape(showShapes and sigMOU, title="MOU", style=shape.labelup, text="猛", color=color.new(color.lime, 0), textcolor=color.black, location=lblLoc, size=size.tiny)
plotshape(showShapes and sigMOUB, title="MOUB", style=shape.labelup, text="猛B", color=color.new(color.green, 0), textcolor=color.black, location=lblLoc, size=size.tiny)
plotshape(showShapes and sigKAKU, title="KAKU", style=shape.labelup, text="確", color=color.new(color.yellow, 0), textcolor=color.black, location=lblLoc, size=size.small)
// =========================
// Alerts
// =========================
alertcondition(sigMOU, title="MNO_MOU", message="MNO: 猛(押し目)")
alertcondition(sigMOUB, title="MNO_MOU_BREAKOUT", message="MNO: 猛B(ブレイク)")
alertcondition(sigKAKU, title="MNO_KAKU", message="MNO: 確(最終)")
alertcondition(sigMOU or sigMOUB or sigKAKU, title="MNO_ALL", message="MNO: 猛/猛B/確 いずれか")
indicator("MNO_2Step_Screener_MOU_MOUB_KAKU", overlay=true, max_labels_count=500, max_lines_count=500)
// =========================
// Inputs
// =========================
emaSLen = input.int(5, "EMA Short (5)", minval=1)
emaMLen = input.int(13, "EMA Mid (13)", minval=1)
emaLLen = input.int(26, "EMA Long (26)", minval=1)
macdFast = input.int(12, "MACD Fast", minval=1)
macdSlow = input.int(26, "MACD Slow", minval=1)
macdSignal = input.int(9, "MACD Signal", minval=1)
macdZeroTh = input.float(0.2, "MOU: MACD near-zero threshold", step=0.05)
volDays = input.int(5, "Volume avg (days equivalent)", minval=1)
volMinRatio = input.float(1.3, "MOU: Volume ratio min", step=0.1)
volStrong = input.float(1.5, "Strong volume ratio (MOU-B/KAKU)", step=0.1)
volMaxRatio = input.float(3.0, "Volume ratio max (filter)", step=0.1)
wickBodyMult = input.float(2.0, "Pinbar: lowerWick >= body*x", step=0.1)
pivotLen = input.int(20, "Resistance lookback", minval=5)
pullMinPct = input.float(5.0, "Pullback min (%)", step=0.1)
pullMaxPct = input.float(15.0, "Pullback max (%)", step=0.1)
breakLookbackBars = input.int(5, "Valid bars after break", minval=1)
showEMA = input.bool(true, "Plot EMAs")
showLabels = input.bool(true, "Show labels (猛/猛B/確)")
showShapes = input.bool(true, "Show shapes (猛/猛B/確)")
confirmOnClose = input.bool(true, "Signal only on bar close (recommended)")
locChoice = input.string("Below", "Label location", options=["Below","Above"])
lblLoc = locChoice == "Below" ? location.belowbar : location.abovebar
// =========================
// EMA
// =========================
emaS = ta.ema(close, emaSLen)
emaM = ta.ema(close, emaMLen)
emaL = ta.ema(close, emaLLen)
plot(showEMA ? emaS : na, color=color.new(color.yellow, 0), title="EMA 5")
plot(showEMA ? emaM : na, color=color.new(color.blue, 0), title="EMA 13")
plot(showEMA ? emaL : na, color=color.new(color.orange, 0), title="EMA 26")
emaUpS = emaS > emaS[1]
emaUpM = emaM > emaM[1]
emaUpL = emaL > emaL[1]
goldenOrder = emaS > emaM and emaM > emaL
above26_2bars = close > emaL and close[1] > emaL[1]
baseTrendOK = (emaUpS and emaUpM and emaUpL) and goldenOrder and above26_2bars
// =========================
// MACD
// =========================
[macdLine, macdSig, macdHist] = ta.macd(close, macdFast, macdSlow, macdSignal)
macdGC = ta.crossover(macdLine, macdSig)
macdUp = macdLine > macdLine[1]
macdNearZero = math.abs(macdLine) <= macdZeroTh
macdGCAboveZero = macdGC and macdLine > 0 and macdSig > 0
macdMouOK = macdGC and macdNearZero and macdUp
macdKakuOK = macdGCAboveZero
// =========================
// Volume (days -> bars)
// =========================
sec = timeframe.in_seconds(timeframe.period)
barsPerDay = (sec > 0 and sec < 86400) ? math.round(86400 / sec) : 1
volLookbackBars = math.max(1, volDays * barsPerDay)
volMA = ta.sma(volume, volLookbackBars)
volRatio = volMA > 0 ? (volume / volMA) : na
volumeMouOK = not na(volRatio) and volRatio >= volMinRatio and volRatio <= volMaxRatio
volumeStrongOK = not na(volRatio) and volRatio >= volStrong and volRatio <= volMaxRatio
// =========================
// Candle patterns
// =========================
body = math.abs(close - open)
upperWick = high - math.max(open, close)
lowerWick = math.min(open, close) - low
pinbar = (body > 0) and (lowerWick >= wickBodyMult * body) and (lowerWick > upperWick) and (close >= open)
bullEngulf = close > open and close[1] < open[1] and close >= open[1] and open <= close[1]
bigBull = close > open and open < emaM and close > emaS and (body > ta.sma(body, 20))
candleOK = pinbar or bullEngulf or bigBull
// =========================
// Resistance / Pullback route
// =========================
res = ta.highest(high, pivotLen)
pullbackPct = res > 0 ? (res - close) / res * 100.0 : na
pullbackOK = not na(pullbackPct) and pullbackPct >= pullMinPct and pullbackPct <= pullMaxPct
brokeRes = ta.crossover(close, res[1])
barsSinceBreak = ta.barssince(brokeRes)
afterBreakZone = (barsSinceBreak >= 0) and (barsSinceBreak <= breakLookbackBars)
pullbackRouteOK = afterBreakZone and pullbackOK
// =========================
// Signals (猛 / 猛B / 確)
// =========================
mou_pullback = baseTrendOK and volumeMouOK and candleOK and macdMouOK and pullbackRouteOK
mou_breakout = baseTrendOK and ta.crossover(close, res[1]) and volumeStrongOK and macdKakuOK
cond1 = emaUpS and emaUpM and emaUpL
cond2 = goldenOrder
cond3 = above26_2bars
cond4 = macdKakuOK
cond5 = volumeMouOK
cond6 = candleOK
cond7 = pullbackOK
cond8 = pullbackRouteOK
all8 = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 and cond7 and cond8
final3 = pinbar and macdKakuOK and volumeStrongOK
kaku = all8 and final3
// 確優先(同一足は確だけ出す)
confirmed = confirmOnClose ? barstate.isconfirmed : true
sigKAKU = kaku and confirmed
sigMOU = mou_pullback and not kaku and confirmed
sigMOUB = mou_breakout and not kaku and confirmed
// =========================
// Visualization
// =========================
if showLabels and sigMOU
label.new(bar_index, low, "猛", style=label.style_label_up, color=color.new(color.lime, 0), textcolor=color.black)
if showLabels and sigMOUB
label.new(bar_index, low, "猛B", style=label.style_label_up, color=color.new(color.green, 0), textcolor=color.black)
if showLabels and sigKAKU
label.new(bar_index, low, "確", style=label.style_label_up, color=color.new(color.yellow, 0), textcolor=color.black)
plotshape(showShapes and sigMOU, title="MOU", style=shape.labelup, text="猛", color=color.new(color.lime, 0), textcolor=color.black, location=lblLoc, size=size.tiny)
plotshape(showShapes and sigMOUB, title="MOUB", style=shape.labelup, text="猛B", color=color.new(color.green, 0), textcolor=color.black, location=lblLoc, size=size.tiny)
plotshape(showShapes and sigKAKU, title="KAKU", style=shape.labelup, text="確", color=color.new(color.yellow, 0), textcolor=color.black, location=lblLoc, size=size.small)
// =========================
// Alerts
// =========================
alertcondition(sigMOU, title="MNO_MOU", message="MNO: 猛(押し目)")
alertcondition(sigMOUB, title="MNO_MOU_BREAKOUT", message="MNO: 猛B(ブレイク)")
alertcondition(sigKAKU, title="MNO_KAKU", message="MNO: 確(最終)")
alertcondition(sigMOU or sigMOUB or sigKAKU, title="MNO_ALL", message="MNO: 猛/猛B/確 いずれか")
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.