PROTECTED SOURCE SCRIPT
チェリーボーイ

//version=6
indicator("チェリーボーイ", overlay=true, precision=2, max_labels_count=500, max_lines_count=500)
// ===================== GLOBAL HELPERS ===================== //
ma_func(_source, _length, _type) =>
switch _type
"SMA" => ta.sma(_source, _length)
"SMA + Bollinger Bands" => ta.sma(_source, _length)
"EMA" => ta.ema(_source, _length)
"SMMA (RMA)" => ta.rma(_source, _length)
"WMA" => ta.wma(_source, _length)
"VWMA" => ta.vwma(_source, _length)
=> na
// ===================== Display / Placement ===================== //
grpDisp = "Display"
showOscPlots = input.bool(false, "内部(Stoch/RCI/RVI/RSI)のプロットを表示", group=grpDisp, tooltip="価格スケールを壊す可能性があるため既定OFF")
showTextLabels = input.bool(true, "R/B/BUY/SELLラベルを表示", group=grpDisp)
// ===================== Master Toggles ===================== //
grpMain = "Modules"
useStoch = input.bool(true, "Enable Stoch→EMA(20/50/70)", group=grpMain)
useRCI = input.bool(true, "Enable RCI→EMA(20/50/70)", group=grpMain)
useRVI = input.bool(true, "Enable RVI→EMA(20/50/70)", group=grpMain)
usePrice3 = input.bool(true, "Enable Price 3EMA(10/50/200)", group=grpMain)
useRSI = input.bool(true, "Enable RSI→EMA(20/50/70)", group=grpMain)
// ===================== Reach Settings ===================== //
grpReach = "Reach Settings"
reachMode = input.string("On Enter", "Signal Mode", options=["On Enter","While True"], group=grpReach)
needCount = input.int(4, "必要個数(N of M)", minval=1, maxval=5, group=grpReach)
// ===================== BINGO水平線(価格に描画) ===================== //
grpHL = "BINGO Horizontal Line"
drawHL = input.bool(true, "BINGO時に水平線を描く", group=grpHL)
hlHours = input.float(2.0, "水平線の長さ(時間)", minval=0.1, maxval=48.0, step=0.1, group=grpHL)
hlPriceSrc = input.string("Close", "ライン価格の基準", options=["Close","Open","High","Low","HL2","HLC3"], group=grpHL)
hlW = input.int(2, "水平線の太さ", minval=1, maxval=5, group=grpHL)
// ライン価格
priceVal() =>
switch hlPriceSrc
"Close" => close
"Open" => open
"High" => high
"Low" => low
"HL2" => (high + low) / 2
"HLC3" => (high + low + close) / 3
=> close
// =====================================================
// 0) Price 3EMA → PO
// =====================================================
grpP = "Price 3EMA (internal)"
srcP = input.source(close, "Source", group=grpP)
len10 = input.int(10, "EMA10 Length", minval=1, group=grpP)
len50 = input.int(50, "EMA50 Length", minval=1, group=grpP)
len200 = input.int(200, "EMA200 Length", minval=1, group=grpP)
ema10 = ta.ema(srcP, len10)
ema50 = ta.ema(srcP, len50)
ema200 = ta.ema(srcP, len200)
poUp_price = usePrice3 and (ema10 > ema50 and ema50 > ema200)
poDown_price = usePrice3 and (ema10 < ema50 and ema50 < ema200)
sigUp_price = poUp_price and not poUp_price[1]
sigDown_price = poDown_price and not poDown_price[1]
// =====================================================
// 1) Stochastic → EMA PO
// =====================================================
periodK_s = 9
smoothK_s = 15
periodD_s = 3
k_raw_s = ta.stoch(high, low, close, periodK_s)
k_s = ta.sma(k_raw_s, smoothK_s)
d_s = ta.sma(k_s, periodD_s)
kE20_s = ta.ema(k_s, 20)
kE50_s = ta.ema(k_s, 50)
kE70_s = ta.ema(k_s, 70)
poUp_s = useStoch and (kE20_s > kE50_s and kE50_s > kE70_s)
poDown_s = useStoch and (kE20_s < kE50_s and kE50_s < kE70_s)
sigUp_s = ta.change(poUp_s) and poUp_s
sigDown_s = ta.change(poDown_s) and poDown_s
plot(showOscPlots and useStoch ? kE20_s : na, title="[Stoch] EMA20", color=color.lime, linewidth=2)
plot(showOscPlots and useStoch ? kE50_s : na, title="[Stoch] EMA50", color=color.orange, linewidth=2)
plot(showOscPlots and useStoch ? kE70_s : na, title="[Stoch] EMA70", color=color.fuchsia, linewidth=2)
plot(showOscPlots and useStoch ? k_s : na, title="[Stoch] %K", color=color.new(color.blue, 70))
plot(showOscPlots and useStoch ? d_s : na, title="[Stoch] %D", color=color.new(color.red, 70))
// =====================================================
// 2) RCI → EMA PO
// =====================================================
grpRCI = "RCI Settings"
srcInput_r = input.source(close, "RCI Source", group=grpRCI)
lenRCI_r = input.int(10, "RCI Length", minval=1, group=grpRCI)
rci_r = ta.rci(srcInput_r, lenRCI_r)
lenE1_r = input.int(20, "EMA20", minval=1, group=grpRCI)
lenE2_r = input.int(50, "EMA50", minval=1, group=grpRCI)
lenE3_r = input.int(70, "EMA70", minval=1, group=grpRCI)
e20_r = ta.ema(rci_r, lenE1_r)
e50_r = ta.ema(rci_r, lenE2_r)
e70_r = ta.ema(rci_r, lenE3_r)
plot(showOscPlots and useRCI ? rci_r : na, title="[RCI] RCI", color=color.blue)
plot(showOscPlots and useRCI ? e20_r : na, title="[RCI] EMA20", color=color.orange, linewidth=2)
plot(showOscPlots and useRCI ? e50_r : na, title="[RCI] EMA50", color=color.fuchsia, linewidth=2)
plot(showOscPlots and useRCI ? e70_r : na, title="[RCI] EMA70", color=color.aqua, linewidth=2)
poUp_r = useRCI and (e20_r > e50_r and e50_r > e70_r)
poDown_r = useRCI and (e20_r < e50_r and e50_r < e70_r)
sigUp_r = poUp_r and not poUp_r[1]
sigDown_r = poDown_r and not poDown_r[1]
// =====================================================
// 3) RVI → EMA PO
// =====================================================
grpRVI = "RVI Core"
length_v = input.int(10, "RVI StdDev Length", minval=1, group=grpRVI)
lenEMA_v = input.int(14, "RVI EMA Len", minval=1, group=grpRVI)
src_v = close
stddev_v = ta.stdev(src_v, length_v)
upper_v = ta.ema(ta.change(src_v) <= 0 ? 0 : stddev_v, lenEMA_v)
lower_v = ta.ema(ta.change(src_v) > 0 ? 0 : stddev_v, lenEMA_v)
sumUL_v = upper_v + lower_v
rvi_v = sumUL_v != 0 ? upper_v / sumUL_v * 100.0 : na
lenE1_v = input.int(20, "EMA20 (on RVI)", minval=1, group=grpRVI)
lenE2_v = input.int(50, "EMA50 (on RVI)", minval=1, group=grpRVI)
lenE3_v = input.int(70, "EMA70 (on RVI)", minval=1, group=grpRVI)
rE20_v = ta.ema(rvi_v, lenE1_v)
rE50_v = ta.ema(rvi_v, lenE2_v)
rE70_v = ta.ema(rvi_v, lenE3_v)
plot(showOscPlots and useRVI ? rvi_v : na, title="[RVI] RVI", color=#7E57C2)
plot(showOscPlots and useRVI ? rE20_v : na, "[RVI] EMA20", color=color.lime, linewidth=2)
plot(showOscPlots and useRVI ? rE50_v : na, "[RVI] EMA50", color=color.teal, linewidth=2)
plot(showOscPlots and useRVI ? rE70_v : na, "[RVI] EMA70", color=color.blue, linewidth=2)
poUp_v = useRVI and (rE20_v > rE50_v and rE50_v > rE70_v)
poDown_v = useRVI and (rE20_v < rE50_v and rE50_v < rE70_v)
sigUp_v = poUp_v and not poUp_v[1]
sigDown_v = poDown_v and not poDown_v[1]
// =====================================================
// 4) RSI → EMA PO
// =====================================================
grpRSI = "RSI Settings"
rsiLen = input.int(14, "RSI Length", minval=1, group=grpRSI)
rsiSrc = input.source(close, "RSI Source", group=grpRSI)
chg = ta.change(rsiSrc)
upR = ta.rma(math.max(chg, 0), rsiLen)
downR = ta.rma(-math.min(chg, 0), rsiLen)
rsi = downR == 0 ? 100 : upR == 0 ? 0 : 100 - (100 / (1 + upR / downR))
rsiE20 = ta.ema(rsi, 20)
rsiE50 = ta.ema(rsi, 50)
rsiE70 = ta.ema(rsi, 70)
plot(showOscPlots and useRSI ? rsi : na, title="[RSI] RSI", color=#7E57C2)
plot(showOscPlots and useRSI ? rsiE20 : na, title="[RSI] EMA20", color=color.lime, linewidth=2)
plot(showOscPlots and useRSI ? rsiE50 : na, title="[RSI] EMA50", color=color.orange, linewidth=2)
plot(showOscPlots and useRSI ? rsiE70 : na, title="[RSI] EMA70", color=color.fuchsia, linewidth=2)
poUp_rsi = useRSI and (rsiE20 > rsiE50 and rsiE50 > rsiE70)
poDown_rsi = useRSI and (rsiE20 < rsiE50 and rsiE50 < rsiE70)
sigUp_rsi = poUp_rsi and not poUp_rsi[1]
sigDown_rsi = poDown_rsi and not poDown_rsi[1]
// =====================================================
// 5) REACH (N of M) LOGIC
// =====================================================
activeCount =
(usePrice3 ? 1 : 0) +
(useStoch ? 1 : 0) +
(useRCI ? 1 : 0) +
(useRVI ? 1 : 0) +
(useRSI ? 1 : 0)
upCount =
(poUp_price ? 1 : 0) +
(poUp_s ? 1 : 0) +
(poUp_r ? 1 : 0) +
(poUp_v ? 1 : 0) +
(poUp_rsi ? 1 : 0)
downCount =
(poDown_price ? 1 : 0) +
(poDown_s ? 1 : 0) +
(poDown_r ? 1 : 0) +
(poDown_v ? 1 : 0) +
(poDown_rsi ? 1 : 0)
reachUp_raw = (upCount >= needCount) and (activeCount >= needCount)
reachDown_raw = (downCount >= needCount) and (activeCount >= needCount)
reachUp = reachMode == "On Enter" ? (reachUp_raw and not reachUp_raw[1]) : reachUp_raw
reachDown = reachMode == "On Enter" ? (reachDown_raw and not reachDown_raw[1]) : reachDown_raw
// ---- ラベル(ズレ防止:バー基準) ----
plotshape(showTextLabels and reachUp,
title="[Reach] Up", style=shape.labelup, location=location.belowbar,
text="R↑", textcolor=color.white, color=color.new(#00bcd4, 0), size=size.tiny)
plotshape(showTextLabels and reachDown,
title="[Reach] Down", style=shape.labeldown, location=location.abovebar,
text="R↓", textcolor=color.white, color=color.new(#ff7043, 0), size=size.tiny)
alertcondition(reachUp, title="[REACH] N/M Up", message="Reach Up: >= needCount modules are UP.")
alertcondition(reachDown, title="[REACH] N/M Down", message="Reach Down: >= needCount modules are DOWN.")
// =====================================================
// 6) BINGO (5 of 5) + 価格に水平線
// =====================================================
bingoUp_raw = (upCount == 5) and (activeCount == 5)
bingoDown_raw = (downCount == 5) and (activeCount == 5)
// 表示用(モード反映)
bingoUp = reachMode == "On Enter" ? (bingoUp_raw and not bingoUp_raw[1]) : bingoUp_raw
bingoDown = reachMode == "On Enter" ? (bingoDown_raw and not bingoDown_raw[1]) : bingoDown_raw
// 立ち上がり(水平線&コンボ状態遷移のトリガ)
bingoUp_enter = ta.change(bingoUp_raw) and bingoUp_raw
bingoDown_enter = ta.change(bingoDown_raw) and bingoDown_raw
plotshape(showTextLabels and bingoUp,
title="[BINGO] Up", style=shape.labelup, location=location.belowbar,
text="B↑", textcolor=color.white, color=color.new(color.green, 0), size=size.tiny)
plotshape(showTextLabels and bingoDown,
title="[BINGO] Down", style=shape.labeldown, location=location.abovebar,
text="B↓", textcolor=color.white, color=color.new(color.red, 0), size=size.tiny)
alertcondition(bingoUp, title="[BINGO] 5/5 Up", message="All 5 modules are UP (5/5 BINGO)")
alertcondition(bingoDown, title="[BINGO] 5/5 Down", message="All 5 modules are DOWN (5/5 BINGO)")
// ---- BINGO時に2時間水平線(価格に描画) ----
twoHoursMs = int(math.round(hlHours * 60.0 * 60.0 * 1000.0))
newHL(_isUp) =>
_y = priceVal()
_col = _isUp ? color.new(color.green, 0) : color.new(color.red, 0)
line.new(x1=time, y1=_y, x2=time + twoHoursMs, y2=_y, xloc=xloc.bar_time, extend=extend.none, color=_col, width=hlW)
if drawHL and bingoUp_enter
newHL(true)
if drawHL and bingoDown_enter
newHL(false)
// =====================================================
// 7) コンボ:BINGO後にRSI-POが逆向きで発火
// BINGO↓ → RSI PO↑ = Buy
// BINGO↑ → RSI PO↓ = Sell
// =====================================================
var int lastBingoDir = 0 // +1=Up, -1=Down, 0=None
if bingoUp_enter
lastBingoDir := 1
if bingoDown_enter
lastBingoDir := -1
buySig = (lastBingoDir == -1) and sigUp_rsi
sellSig = (lastBingoDir == 1) and sigDown_rsi
if buySig or sellSig
lastBingoDir := 0
plotshape(showTextLabels and buySig,
title="[COMBO] BUY", style=shape.labelup, location=location.belowbar,
text="BUY", textcolor=color.white, color=color.new(#26a69a, 0), size=size.tiny)
plotshape(showTextLabels and sellSig,
title="[COMBO] SELL", style=shape.labeldown, location=location.abovebar,
text="SELL", textcolor=color.white, color=color.new(#ef5350, 0), size=size.tiny)
alertcondition(buySig, title="[COMBO] BINGO↓ → RSI PO↑ (BUY)", message="BUY: BINGO Down followed by RSI-PO Up")
alertcondition(sellSig, title="[COMBO] BINGO↑ → RSI PO↓ (SELL)", message="SELL: BINGO Up followed by RSI-PO Down")
indicator("チェリーボーイ", overlay=true, precision=2, max_labels_count=500, max_lines_count=500)
// ===================== GLOBAL HELPERS ===================== //
ma_func(_source, _length, _type) =>
switch _type
"SMA" => ta.sma(_source, _length)
"SMA + Bollinger Bands" => ta.sma(_source, _length)
"EMA" => ta.ema(_source, _length)
"SMMA (RMA)" => ta.rma(_source, _length)
"WMA" => ta.wma(_source, _length)
"VWMA" => ta.vwma(_source, _length)
=> na
// ===================== Display / Placement ===================== //
grpDisp = "Display"
showOscPlots = input.bool(false, "内部(Stoch/RCI/RVI/RSI)のプロットを表示", group=grpDisp, tooltip="価格スケールを壊す可能性があるため既定OFF")
showTextLabels = input.bool(true, "R/B/BUY/SELLラベルを表示", group=grpDisp)
// ===================== Master Toggles ===================== //
grpMain = "Modules"
useStoch = input.bool(true, "Enable Stoch→EMA(20/50/70)", group=grpMain)
useRCI = input.bool(true, "Enable RCI→EMA(20/50/70)", group=grpMain)
useRVI = input.bool(true, "Enable RVI→EMA(20/50/70)", group=grpMain)
usePrice3 = input.bool(true, "Enable Price 3EMA(10/50/200)", group=grpMain)
useRSI = input.bool(true, "Enable RSI→EMA(20/50/70)", group=grpMain)
// ===================== Reach Settings ===================== //
grpReach = "Reach Settings"
reachMode = input.string("On Enter", "Signal Mode", options=["On Enter","While True"], group=grpReach)
needCount = input.int(4, "必要個数(N of M)", minval=1, maxval=5, group=grpReach)
// ===================== BINGO水平線(価格に描画) ===================== //
grpHL = "BINGO Horizontal Line"
drawHL = input.bool(true, "BINGO時に水平線を描く", group=grpHL)
hlHours = input.float(2.0, "水平線の長さ(時間)", minval=0.1, maxval=48.0, step=0.1, group=grpHL)
hlPriceSrc = input.string("Close", "ライン価格の基準", options=["Close","Open","High","Low","HL2","HLC3"], group=grpHL)
hlW = input.int(2, "水平線の太さ", minval=1, maxval=5, group=grpHL)
// ライン価格
priceVal() =>
switch hlPriceSrc
"Close" => close
"Open" => open
"High" => high
"Low" => low
"HL2" => (high + low) / 2
"HLC3" => (high + low + close) / 3
=> close
// =====================================================
// 0) Price 3EMA → PO
// =====================================================
grpP = "Price 3EMA (internal)"
srcP = input.source(close, "Source", group=grpP)
len10 = input.int(10, "EMA10 Length", minval=1, group=grpP)
len50 = input.int(50, "EMA50 Length", minval=1, group=grpP)
len200 = input.int(200, "EMA200 Length", minval=1, group=grpP)
ema10 = ta.ema(srcP, len10)
ema50 = ta.ema(srcP, len50)
ema200 = ta.ema(srcP, len200)
poUp_price = usePrice3 and (ema10 > ema50 and ema50 > ema200)
poDown_price = usePrice3 and (ema10 < ema50 and ema50 < ema200)
sigUp_price = poUp_price and not poUp_price[1]
sigDown_price = poDown_price and not poDown_price[1]
// =====================================================
// 1) Stochastic → EMA PO
// =====================================================
periodK_s = 9
smoothK_s = 15
periodD_s = 3
k_raw_s = ta.stoch(high, low, close, periodK_s)
k_s = ta.sma(k_raw_s, smoothK_s)
d_s = ta.sma(k_s, periodD_s)
kE20_s = ta.ema(k_s, 20)
kE50_s = ta.ema(k_s, 50)
kE70_s = ta.ema(k_s, 70)
poUp_s = useStoch and (kE20_s > kE50_s and kE50_s > kE70_s)
poDown_s = useStoch and (kE20_s < kE50_s and kE50_s < kE70_s)
sigUp_s = ta.change(poUp_s) and poUp_s
sigDown_s = ta.change(poDown_s) and poDown_s
plot(showOscPlots and useStoch ? kE20_s : na, title="[Stoch] EMA20", color=color.lime, linewidth=2)
plot(showOscPlots and useStoch ? kE50_s : na, title="[Stoch] EMA50", color=color.orange, linewidth=2)
plot(showOscPlots and useStoch ? kE70_s : na, title="[Stoch] EMA70", color=color.fuchsia, linewidth=2)
plot(showOscPlots and useStoch ? k_s : na, title="[Stoch] %K", color=color.new(color.blue, 70))
plot(showOscPlots and useStoch ? d_s : na, title="[Stoch] %D", color=color.new(color.red, 70))
// =====================================================
// 2) RCI → EMA PO
// =====================================================
grpRCI = "RCI Settings"
srcInput_r = input.source(close, "RCI Source", group=grpRCI)
lenRCI_r = input.int(10, "RCI Length", minval=1, group=grpRCI)
rci_r = ta.rci(srcInput_r, lenRCI_r)
lenE1_r = input.int(20, "EMA20", minval=1, group=grpRCI)
lenE2_r = input.int(50, "EMA50", minval=1, group=grpRCI)
lenE3_r = input.int(70, "EMA70", minval=1, group=grpRCI)
e20_r = ta.ema(rci_r, lenE1_r)
e50_r = ta.ema(rci_r, lenE2_r)
e70_r = ta.ema(rci_r, lenE3_r)
plot(showOscPlots and useRCI ? rci_r : na, title="[RCI] RCI", color=color.blue)
plot(showOscPlots and useRCI ? e20_r : na, title="[RCI] EMA20", color=color.orange, linewidth=2)
plot(showOscPlots and useRCI ? e50_r : na, title="[RCI] EMA50", color=color.fuchsia, linewidth=2)
plot(showOscPlots and useRCI ? e70_r : na, title="[RCI] EMA70", color=color.aqua, linewidth=2)
poUp_r = useRCI and (e20_r > e50_r and e50_r > e70_r)
poDown_r = useRCI and (e20_r < e50_r and e50_r < e70_r)
sigUp_r = poUp_r and not poUp_r[1]
sigDown_r = poDown_r and not poDown_r[1]
// =====================================================
// 3) RVI → EMA PO
// =====================================================
grpRVI = "RVI Core"
length_v = input.int(10, "RVI StdDev Length", minval=1, group=grpRVI)
lenEMA_v = input.int(14, "RVI EMA Len", minval=1, group=grpRVI)
src_v = close
stddev_v = ta.stdev(src_v, length_v)
upper_v = ta.ema(ta.change(src_v) <= 0 ? 0 : stddev_v, lenEMA_v)
lower_v = ta.ema(ta.change(src_v) > 0 ? 0 : stddev_v, lenEMA_v)
sumUL_v = upper_v + lower_v
rvi_v = sumUL_v != 0 ? upper_v / sumUL_v * 100.0 : na
lenE1_v = input.int(20, "EMA20 (on RVI)", minval=1, group=grpRVI)
lenE2_v = input.int(50, "EMA50 (on RVI)", minval=1, group=grpRVI)
lenE3_v = input.int(70, "EMA70 (on RVI)", minval=1, group=grpRVI)
rE20_v = ta.ema(rvi_v, lenE1_v)
rE50_v = ta.ema(rvi_v, lenE2_v)
rE70_v = ta.ema(rvi_v, lenE3_v)
plot(showOscPlots and useRVI ? rvi_v : na, title="[RVI] RVI", color=#7E57C2)
plot(showOscPlots and useRVI ? rE20_v : na, "[RVI] EMA20", color=color.lime, linewidth=2)
plot(showOscPlots and useRVI ? rE50_v : na, "[RVI] EMA50", color=color.teal, linewidth=2)
plot(showOscPlots and useRVI ? rE70_v : na, "[RVI] EMA70", color=color.blue, linewidth=2)
poUp_v = useRVI and (rE20_v > rE50_v and rE50_v > rE70_v)
poDown_v = useRVI and (rE20_v < rE50_v and rE50_v < rE70_v)
sigUp_v = poUp_v and not poUp_v[1]
sigDown_v = poDown_v and not poDown_v[1]
// =====================================================
// 4) RSI → EMA PO
// =====================================================
grpRSI = "RSI Settings"
rsiLen = input.int(14, "RSI Length", minval=1, group=grpRSI)
rsiSrc = input.source(close, "RSI Source", group=grpRSI)
chg = ta.change(rsiSrc)
upR = ta.rma(math.max(chg, 0), rsiLen)
downR = ta.rma(-math.min(chg, 0), rsiLen)
rsi = downR == 0 ? 100 : upR == 0 ? 0 : 100 - (100 / (1 + upR / downR))
rsiE20 = ta.ema(rsi, 20)
rsiE50 = ta.ema(rsi, 50)
rsiE70 = ta.ema(rsi, 70)
plot(showOscPlots and useRSI ? rsi : na, title="[RSI] RSI", color=#7E57C2)
plot(showOscPlots and useRSI ? rsiE20 : na, title="[RSI] EMA20", color=color.lime, linewidth=2)
plot(showOscPlots and useRSI ? rsiE50 : na, title="[RSI] EMA50", color=color.orange, linewidth=2)
plot(showOscPlots and useRSI ? rsiE70 : na, title="[RSI] EMA70", color=color.fuchsia, linewidth=2)
poUp_rsi = useRSI and (rsiE20 > rsiE50 and rsiE50 > rsiE70)
poDown_rsi = useRSI and (rsiE20 < rsiE50 and rsiE50 < rsiE70)
sigUp_rsi = poUp_rsi and not poUp_rsi[1]
sigDown_rsi = poDown_rsi and not poDown_rsi[1]
// =====================================================
// 5) REACH (N of M) LOGIC
// =====================================================
activeCount =
(usePrice3 ? 1 : 0) +
(useStoch ? 1 : 0) +
(useRCI ? 1 : 0) +
(useRVI ? 1 : 0) +
(useRSI ? 1 : 0)
upCount =
(poUp_price ? 1 : 0) +
(poUp_s ? 1 : 0) +
(poUp_r ? 1 : 0) +
(poUp_v ? 1 : 0) +
(poUp_rsi ? 1 : 0)
downCount =
(poDown_price ? 1 : 0) +
(poDown_s ? 1 : 0) +
(poDown_r ? 1 : 0) +
(poDown_v ? 1 : 0) +
(poDown_rsi ? 1 : 0)
reachUp_raw = (upCount >= needCount) and (activeCount >= needCount)
reachDown_raw = (downCount >= needCount) and (activeCount >= needCount)
reachUp = reachMode == "On Enter" ? (reachUp_raw and not reachUp_raw[1]) : reachUp_raw
reachDown = reachMode == "On Enter" ? (reachDown_raw and not reachDown_raw[1]) : reachDown_raw
// ---- ラベル(ズレ防止:バー基準) ----
plotshape(showTextLabels and reachUp,
title="[Reach] Up", style=shape.labelup, location=location.belowbar,
text="R↑", textcolor=color.white, color=color.new(#00bcd4, 0), size=size.tiny)
plotshape(showTextLabels and reachDown,
title="[Reach] Down", style=shape.labeldown, location=location.abovebar,
text="R↓", textcolor=color.white, color=color.new(#ff7043, 0), size=size.tiny)
alertcondition(reachUp, title="[REACH] N/M Up", message="Reach Up: >= needCount modules are UP.")
alertcondition(reachDown, title="[REACH] N/M Down", message="Reach Down: >= needCount modules are DOWN.")
// =====================================================
// 6) BINGO (5 of 5) + 価格に水平線
// =====================================================
bingoUp_raw = (upCount == 5) and (activeCount == 5)
bingoDown_raw = (downCount == 5) and (activeCount == 5)
// 表示用(モード反映)
bingoUp = reachMode == "On Enter" ? (bingoUp_raw and not bingoUp_raw[1]) : bingoUp_raw
bingoDown = reachMode == "On Enter" ? (bingoDown_raw and not bingoDown_raw[1]) : bingoDown_raw
// 立ち上がり(水平線&コンボ状態遷移のトリガ)
bingoUp_enter = ta.change(bingoUp_raw) and bingoUp_raw
bingoDown_enter = ta.change(bingoDown_raw) and bingoDown_raw
plotshape(showTextLabels and bingoUp,
title="[BINGO] Up", style=shape.labelup, location=location.belowbar,
text="B↑", textcolor=color.white, color=color.new(color.green, 0), size=size.tiny)
plotshape(showTextLabels and bingoDown,
title="[BINGO] Down", style=shape.labeldown, location=location.abovebar,
text="B↓", textcolor=color.white, color=color.new(color.red, 0), size=size.tiny)
alertcondition(bingoUp, title="[BINGO] 5/5 Up", message="All 5 modules are UP (5/5 BINGO)")
alertcondition(bingoDown, title="[BINGO] 5/5 Down", message="All 5 modules are DOWN (5/5 BINGO)")
// ---- BINGO時に2時間水平線(価格に描画) ----
twoHoursMs = int(math.round(hlHours * 60.0 * 60.0 * 1000.0))
newHL(_isUp) =>
_y = priceVal()
_col = _isUp ? color.new(color.green, 0) : color.new(color.red, 0)
line.new(x1=time, y1=_y, x2=time + twoHoursMs, y2=_y, xloc=xloc.bar_time, extend=extend.none, color=_col, width=hlW)
if drawHL and bingoUp_enter
newHL(true)
if drawHL and bingoDown_enter
newHL(false)
// =====================================================
// 7) コンボ:BINGO後にRSI-POが逆向きで発火
// BINGO↓ → RSI PO↑ = Buy
// BINGO↑ → RSI PO↓ = Sell
// =====================================================
var int lastBingoDir = 0 // +1=Up, -1=Down, 0=None
if bingoUp_enter
lastBingoDir := 1
if bingoDown_enter
lastBingoDir := -1
buySig = (lastBingoDir == -1) and sigUp_rsi
sellSig = (lastBingoDir == 1) and sigDown_rsi
if buySig or sellSig
lastBingoDir := 0
plotshape(showTextLabels and buySig,
title="[COMBO] BUY", style=shape.labelup, location=location.belowbar,
text="BUY", textcolor=color.white, color=color.new(#26a69a, 0), size=size.tiny)
plotshape(showTextLabels and sellSig,
title="[COMBO] SELL", style=shape.labeldown, location=location.abovebar,
text="SELL", textcolor=color.white, color=color.new(#ef5350, 0), size=size.tiny)
alertcondition(buySig, title="[COMBO] BINGO↓ → RSI PO↑ (BUY)", message="BUY: BINGO Down followed by RSI-PO Up")
alertcondition(sellSig, title="[COMBO] BINGO↑ → RSI PO↓ (SELL)", message="SELL: BINGO Up followed by RSI-PO Down")
Скрипт с защищённым кодом
Этот скрипт опубликован с закрытым исходным кодом. Однако вы можете использовать его свободно и без каких-либо ограничений — читайте подробнее здесь.
Отказ от ответственности
Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.
Скрипт с защищённым кодом
Этот скрипт опубликован с закрытым исходным кодом. Однако вы можете использовать его свободно и без каких-либо ограничений — читайте подробнее здесь.
Отказ от ответственности
Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.