OPEN-SOURCE SCRIPT

MC² Daily Candidates (v1.0 SAFE)

33
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// © mason_fibkins

//version=5
indicator("MC² Daily Candidates (v1.0 SAFE)", overlay=true)

// ──────────────────────────────────────────
// INTERNAL DAILY DATA (NO TIMEFRAME ARGUMENT)
// ──────────────────────────────────────────
getDaily(_src) =>
request.security(syminfo.tickerid, "D", _src)

// Daily values
d_close = getDaily(close)
d_open = getDaily(open)
d_high = getDaily(high)
d_low = getDaily(low)
d_vol = getDaily(volume)

// ──────────────────────────────────────────
// Parameters
// ──────────────────────────────────────────
lookbackVol = input.int(10, "Vol Lookback (days)")
atrLength = input.int(14, "ATR Length")
emaLen = input.int(20, "EMA Length")
smaLen = input.int(50, "SMA Length")

// ──────────────────────────────────────────
// Core Calculations (DAILY)
// ──────────────────────────────────────────

// Relative Volume
relVol = d_vol / request.security(syminfo.tickerid, "D", ta.sma(volume, lookbackVol))

// Momentum — last 2 daily bullish candles
twoGreen = (d_close > d_open) and (request.security(syminfo.tickerid, "D", close[1]) > request.security(syminfo.tickerid, "D", open[1]))

// Trend filters
emaTrend = d_close > request.security(syminfo.tickerid, "D", ta.ema(close, emaLen))
smaTrend = d_close > request.security(syminfo.tickerid, "D", ta.sma(close, smaLen))

// ATR Expansion
d_atr = request.security(syminfo.tickerid, "D", ta.atr(atrLength))
atrExpand = d_atr > request.security(syminfo.tickerid, "D", ta.atr(atrLength))[1]

// Strong Close
dayRange = d_high - d_low
closePos = dayRange > 0 ? (d_close - d_low) / dayRange : 0.5
strongClose = closePos > 0.70

// MASTER CONDITION
candidate = relVol > 2.0 and twoGreen and emaTrend and smaTrend and atrExpand and strongClose


// ──────────────────────────────────────────
// PLOT — GREEN CIRCLE BELOW DAILY BARS
// ──────────────────────────────────────────
plotshape(candidate, title="Daily Candidate", style=shape.circle, size=size.large, color=color.new(color.green, 0), location=location.belowbar, text="MC²")

// ──────────────────────────────────────────
// END
// ──────────────────────────────────────────

plot(candidate ? 1 : 0, title="MC2_Signal", display=display.none)

免責事項

この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。