// This Pine Script® code is subject to the terms of the Mozilla Public License 2.
0
at https://mozilla.org/MPL/2.0/
// © TradeMisterio1
//@version=6
indicator('TM23 Confirmation Pro', overlay = false)
// === INPUTS ===
src = close
mfiLen = input.int(14, 'MFI Period')
cmfLen = input.int(20, 'CMF Period')
volOscShort = input.int(14, 'Vol Osc Short')
volOscLong = input.int(28, 'Vol Osc Long')
// === CUSTOM ALERT PARAMETERS ===
alertLevelStrongBuy = input.int(20, 'Bullish Confirmation Level')
alertLevelBuy = input.int(10, 'Possible Bullish Entry Level')
alertLevelSell = input.int(-10, 'Possible Bearish Entry Level')
alertLevelStrongSell = input.int(-20, 'Bearish Confirmation Level')
// === SIGNAL FUNCTION ===
signal(r) =>
r > 0 ? 1 : r < 0 ? -1 : 0
// === 1. TREND ===
ema50 = ta.ema(src, 50)
ema200 = ta.ema(src, 200)
emaCross = signal(ema50 - ema200)
supertrendFactor = 3.0
atr = ta.atr(10)
upperBasic = (high + low) / 2 + supertrendFactor * atr
lowerBasic = (high + low) / 2 - supertrendFactor * atr
supertrend = close > upperBasic ? 1 : close < lowerBasic ? -1 : 0
ichimokuBase = (ta.highest(high, 26) + ta.lowest(low, 26)) / 2
ichimokuSignal = signal(close - ichimokuBase)
hma = ta.hma(src, 55)
hmaSignal = signal(close - hma)
tema = 3 * ta.ema(src, 9) - 3 * ta.ema(ta.ema(src, 9), 9) +
ta.ema(ta.ema(ta.ema(src, 9), 9), 9)
temaSignal = signal(close - tema)
// === 2. MOMENTUM ===
rsi = ta.rsi(src, 14)
rsiSignal = rsi > 70 ? -1 : rsi < 30 ? 1 : 0
macdLine = ta.ema(src, 12) - ta.ema(src, 26)
signalLine = ta.ema(macdLine, 9)
macdSignal = signal(macdLine - signalLine)
stochK = ta.stoch(close, high, low, 14)
stochSignal = stochK > 80 ? -1 : stochK < 20 ? 1 : 0
cci = ta.cci(src, 20)
cciSignal = cci > 100 ? 1 : cci < -100 ? -1 : 0
roc = ta.roc(close, 10)
rocSignal = signal(roc)
mom = ta.mom(close, 10)
momSignal = signal(mom)
// === 3. ADX AND DI ===
length = 14
tr = math.max(high - low, math.max(math.abs(high - close[1]), math.abs(low -
close[1])))
plusDM = high - high[1] > low[1] - low ? math.max(high - high[1], 0) : 0
minusDM = low[1] - low > high - high[1] ? math.max(low[1] - low, 0) : 0
plusDI = ta.sma(plusDM, length) / ta.sma(tr, length) * 100
minusDI = ta.sma(minusDM, length) / ta.sma(tr, length) * 100
adx = ta.sma(math.abs(plusDI - minusDI) / (plusDI + minusDI) * 100, length)
adxSignal = adx > 20 ? plusDI > minusDI ? 1 : -1 : 0
// === 4. VOLUME ===
var float pvi = 1000.0
pvi := volume > volume[1] ? pvi[1] * (1 + (close - close[1]) / close[1]) : pvi[1]
var float nvi = 1000.0
nvi := volume < volume[1] ? nvi[1] * (1 + (close - close[1]) / close[1]) : nvi[1]
obv = ta.cum(volume)
mfi = ta.mfi(close, mfiLen)
volOsc = ta.sma(volume, volOscShort) - ta.sma(volume, volOscLong)
cmf = math.sum((close - low - (high - close)) / (high - low) * volume, cmfLen) /
math.sum(volume, cmfLen)
mfiSignal = mfi > 50 ? 1 : mfi < 50 ? -1 : 0
obvSignal = obv > ta.sma(obv, 20) ? 1 : -1
volSignal = volume > ta.ema(volume, 20) ? 1 : -1
cmfSignal = cmf > 0 ? 1 : -1
volOscSignal = volOsc > 0 ? 1 : -1
// === 5. VOLATILITY ===
basis = ta.sma(src, 20)
deviation = 2 * ta.stdev(src, 20)
upperBB = basis + deviation
lowerBB = basis - deviation
bbSignal = close > upperBB ? -1 : close < lowerBB ? 1 : 0
atrChange = signal(ta.atr(14) - ta.atr(14)[1])
// === 6. CANDLES/PRICE ===
var float haOpen = na
haClose = (open + high + low + close) / 4
haOpen := na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2
haSignal = signal(haClose - haOpen)
prevHigh = high[1]
prevLow = low[1]
priceBreakout = close > prevHigh ? 1 : close < prevLow ? -1 : 0
// === 7. PATTERNS ===
crossUp = ta.crossover(ema50, ema200)
crossDown = ta.crossunder(ema50, ema200)
crossSignal = crossUp ? 1 : crossDown ? -1 : 0
pivotHigh = ta.pivothigh(high, 5, 5)
pivotLow = ta.pivotlow(low, 5, 5)
pivotSignal = na(pivotHigh) and na(pivotLow) ? 0 : not na(pivotLow) ? 1 : -1
// === TOTAL SCORE ===
totalScore = emaCross + supertrend + ichimokuSignal + hmaSignal + temaSignal +
rsiSignal + macdSignal + stochSignal + cciSignal + rocSignal + momSignal +
adxSignal + mfiSignal + obvSignal + volSignal + volOscSignal + cmfSignal + bbSignal
+ atrChange + haSignal + priceBreakout + crossSignal + pivotSignal
// === UNIFIED SIGNAL ===
buyCount = 0
sellCount = 0
confirmSignals = array.new_int(0)
array.push(confirmSignals, emaCross)
array.push(confirmSignals, supertrend)
array.push(confirmSignals, ichimokuSignal)
array.push(confirmSignals, hmaSignal)
array.push(confirmSignals, temaSignal)
array.push(confirmSignals, rsiSignal)
array.push(confirmSignals, macdSignal)
array.push(confirmSignals, stochSignal)
array.push(confirmSignals, cciSignal)
array.push(confirmSignals, rocSignal)
array.push(confirmSignals, momSignal)
array.push(confirmSignals, adxSignal)
array.push(confirmSignals, mfiSignal)
array.push(confirmSignals, obvSignal)
array.push(confirmSignals, volSignal)
array.push(confirmSignals, volOscSignal)
array.push(confirmSignals, cmfSignal)
array.push(confirmSignals, bbSignal)
array.push(confirmSignals, atrChange)
array.push(confirmSignals, haSignal)
array.push(confirmSignals, priceBreakout)
array.push(confirmSignals, crossSignal)
array.push(confirmSignals, pivotSignal)
for i = 0 to array.size(confirmSignals) - 1 by 1
val = array.get(confirmSignals, i)
buyCount := buyCount + (val == 1 ? 1 : 0)
sellCount := sellCount + (val == -1 ? 1 : 0)
sellCount
signalText = totalScore >= alertLevelStrongBuy ? '🔥 Strong Buy' : totalScore >=
alertLevelBuy ? 'Buy' : totalScore <= alertLevelStrongSell ? '❌ Strong Sell' :
totalScore <= alertLevelSell ? 'Sell' : 'Neutral'
// === TABLE ===
var table confirmTable = table.new(position.top_right, 4, 4, border_width = 1)
if barstate.islast
table.cell(confirmTable, 0, 0, 'Buy', text_color = color.green)
table.cell(confirmTable, 0, 1, str.tostring(buyCount), text_color =
color.green)
table.cell(confirmTable, 1, 0, 'Sell', text_color = color.red)
table.cell(confirmTable, 1, 1, str.tostring(sellCount), text_color = color.red)
table.cell(confirmTable, 2, 0, 'Score', text_color = color.white)
table.cell(confirmTable, 2, 1, str.tostring(totalScore), text_color =
color.white)
table.cell(confirmTable, 3, 0, 'Signal', text_color = color.yellow)
table.cell(confirmTable, 3, 1, signalText, text_color = color.yellow)
// === MAIN PLOT ===
barColor = totalScore >= alertLevelStrongBuy ? color.green : totalScore >=
alertLevelBuy ? color.lime : totalScore <= alertLevelStrongSell ? color.maroon :
totalScore <= alertLevelSell ? color.red : color.gray
// Apply Color to Main Candles
barcolor(barColor)
plot(totalScore, title = 'Confirmation Oscillator', style = plot.style_columns,
color = barColor)
hline(0, 'Neutral', color = color.gray)
hline(alertLevelBuy, '+Bullish Entry', color = color.lime)
hline(alertLevelSell, '-Bearish Entry', color = color.red)
// === BUY/SELL SIGNALS ===
buySignal = ta.crossover(totalScore, alertLevelBuy)
strongBuySignal = ta.crossover(totalScore, alertLevelStrongBuy)
sellSignal = ta.crossunder(totalScore, alertLevelSell)
strongSellSignal = ta.crossunder(totalScore, alertLevelStrongSell)
plotshape(buySignal and not strongBuySignal, 'Buy', shape.triangleup,
location.belowbar, color.lime, size = size.tiny, force_overlay = true)
plotshape(strongBuySignal, 'Strong Buy', shape.triangleup, location.belowbar,
color.green, size = size.normal, force_overlay = true)
plotshape(sellSignal and not strongSellSignal, 'Sell', shape.triangledown,
location.abovebar, color.red, size = size.tiny, force_overlay = true)
plotshape(strongSellSignal, 'Strong Sell', shape.triangledown, location.abovebar,
color.maroon, size = size.normal, force_overlay = true)
// === ALERTS ===
alertcondition(totalScore >= alertLevelStrongBuy, title = 'Bullish Confirmation',
message = '🔥 Bullish Confirmation: Score = {{plot("Confirmation Oscillator")}}')
alertcondition(totalScore >= alertLevelBuy and totalScore < alertLevelStrongBuy,
title = 'Possible Bullish Entry', message = '🔼 Possible Bullish Entry: Score =
{{plot("Confirmation Oscillator")}}')
alertcondition(totalScore <= alertLevelSell and totalScore > alertLevelStrongSell,
title = 'Possible Bearish Entry', message = '🔽 Possible Bearish Entry: Score =
{{plot("Confirmation Oscillator")}}')
alertcondition(totalScore <= alertLevelStrongSell, title = 'Bearish Confirmation',
message = '❌ Bearish Confirmation: Score = {{plot("Confirmation Oscillator")}}')
// === Ribbon Visualization ===
ribbonValue = ta.hma(close, 20)
ribbonColor = totalScore >= alertLevelStrongBuy ? color.green : totalScore >=
alertLevelBuy ? color.lime : totalScore <= alertLevelStrongSell ? color.maroon :
totalScore <= alertLevelSell ? color.red : color.gray
plot(ribbonValue, title = 'Trend Ribbon', color = ribbonColor, linewidth = 2, style
= plot.style_line, force_overlay = true)