← All scripts
IndicatorOpen sourceVersion 1

Prime / MVP Oscillators - independent

00

Momentum & Money Flow Oscillator combines trend analysis, volume-based pressure readings, divergence detection, and reversal markers in one analytical toolkit.

Prime / MVP Oscillators - independent — screenshot 1 of 1

Screenshot 1 of 1 · Open image to view full size

About this script

Momentum & Money Flow Oscillator Momentum & Money Flow Oscillator combines trend analysis, volume-based pressure readings, divergence detection, and reversal markers in one analytical toolkit. Main Momentum Oscillator The main oscillator uses smoothing designed to limit lag, with green and red coloring to distinguish directional conditions. Its changing shape provides a visual reference for assessing momentum as a move develops. Read the sequence of changes alongside price: a weakening oscillator can raise a question about the current move without establishing that price has already reversed. Money Flow Analysis A dedicated tracker combines price and volume to estimate buying and selling pressure. Green readings indicate positive pressure, while red readings indicate negative pressure. Multi-timeframe tracking adds context beyond the active chart interval. Volume Confirmation The Volume Matrix provides a separate, smoothed view of bullish and bearish volume conditions. Comparing its direction with the main oscillator helps identify agreement or disagreement between momentum and volume-based readings. Trend Strength Assessment Upper and lower Power Bars summarize seven conditions, using brightness to express strength. A separate ranking display condenses trend assessment into categories, making changes easier to follow. Divergence and Momentum Shifts Automatic divergence detection highlights situations where price and the oscillator stop confirming one another: Bullish divergence: Price forms a lower low while the oscillator forms a higher low. Bearish divergence: Price forms a higher high while the oscillator forms a lower high. Money flow divergence markers provide another view of weakening pressure. Diamond-shaped signals identify potential directional shifts, with green marking bullish possibilities and red marking bearish possibilities. These observations describe a change in the relationship between the readings. They provide a reason to examine subsequent price behavior rather than a guaranteed reversal. Overextension and Reversal Markers Volume-informed overbought and oversold signals highlight stretched conditions. Peak Seeker dots combine several analytical inputs around potential turning points, with settings that adapt to the selected timeframe. MVP Oscillator Mode MVP mode presents a volume-focused oscillator on a scale from −100 to +100 . Its position relative to zero provides directional context, while a blue or purple ribbon indicates the current direction of movement. Reading the ribbon together with the zero line adds nuance. A blue ribbon below zero, for example, can indicate improvement within a still-negative reading rather than an established bullish state. Green extension bars and arrow signals draw attention to potentially exhausted moves. Divergences in this mode are assessed manually by comparing oscillator peaks and troughs with price. Dedicated Money Mode Money Mode centers the display on money flow, using green and red waves to represent positive and negative conditions. This provides a focused view when volume-based pressure is the main subject of analysis. Configurable Alerts Available alert conditions include divergences, directional signals, Peak Seekers, overextension, and unusual volume. Select the events relevant to your workflow and create the corresponding TradingView alert. Alerts retain the indicator settings used when they were created. After changing the configuration, recreate the affected alerts so they reflect the intended setup. A practical workflow is to establish directional context first, examine whether volume supports it, and then review any divergence or exhaustion markers. Agreement between components can help organize an analysis, but related calculations should not be treated as independent proof. Use the toolkit to build consistent observations and review potential setups within your own entry, exit, and risk-management rules.

Source code

Read and review the complete source before using it in your account.

script("Prime / MVP Oscillators - independent", kind="indicator")

input mode = 0
input oscillatorLength = 14
input fastLength = 5
input slowLength = 21
input flowLength = 14
input signalLength = 5
input panelHeight = 35
input upperZone = 70
input lowerZone = -70
input pivotStrength = 3
input divergenceMinBars = 5
input divergenceMaxBars = 70
input useVolume = 1
input showMoneyFlow = 1
input showVolumeMatrix = 1
input showPowerBars = 1
input showRank = 1
input rankEveryBars = 8
input showDivergences = 1
input showShifts = 1
input showReversals = 1
input ribbonOpacity = 0.32
input bullColor = "#76F7B8"
input bearColor = "#FF4422"
input mvpBullColor = "#24B8FF"
input mvpBearColor = "#B06CFF"

oscPeriod = math.clamp(math.floor(oscillatorLength), 1, 500)
fastPeriod = math.clamp(math.floor(fastLength), 1, 500)
slowPeriod = math.clamp(math.floor(slowLength), 1, 500)
flowPeriod = math.clamp(math.floor(flowLength), 1, 500)
signalPeriod = math.clamp(math.floor(signalLength), 1, 500)
strength = math.clamp(math.floor(pivotStrength), 1, 50)
rankStride = math.clamp(math.floor(rankEveryBars), 1, 100)
upper = math.clamp(upperZone, 20, 95)
lower = math.clamp(lowerZone, -95, -20)
volumeMissing = na(volume) or volume <= 0
typical = (high + low + close) / 3
rsi = ta.rsi(close, oscPeriod)
wave = ta.wt(typical, fastPeriod, slowPeriod)
fastTrend = ta.ema(close, fastPeriod)
slowTrend = ta.ema(close, slowPeriod)
range = ta.atr(14)
priceChange = barIndex > 0 ? math.abs(close - close[1]) : 0
priceMotion = ta.sum(priceChange, oscPeriod)
rawPrime = not na(rsi) and not na(wave) and not na(priceMotion) ? (priceMotion > 0 ? (rsi - 50) * 1.4 + wave * 1.2 : 0) : na
firstPrime = ta.ema(rawPrime, fastPeriod)
secondPrime = ta.ema(firstPrime, fastPeriod)
prime = na(rawPrime) ? na : math.clamp(2 * firstPrime - secondPrime, -100, 100)
mfi = ta.mfi(flowPeriod)
weightedPrice = ta.vwma(close, flowPeriod)
flowInput = not volumeMissing and not na(mfi) ? (mfi - 50) * 2 : na
flowAverage = ta.ema(flowInput, fastPeriod)
flowSecond = ta.ema(flowAverage, fastPeriod)
flowAvailable = useVolume and not volumeMissing and not na(mfi) and not na(weightedPrice)
flow = flowAvailable ? math.clamp(2 * flowAverage - flowSecond, -100, 100) : na
upVolume = not volumeMissing ? (barIndex > 0 and close > close[1] ? volume : 0) : na
downVolume = not volumeMissing ? (barIndex > 0 and close < close[1] ? volume : 0) : na
smoothedUpVolume = ta.ema(upVolume, flowPeriod)
smoothedDownVolume = ta.ema(downVolume, flowPeriod)
volumeTotal = smoothedUpVolume + smoothedDownVolume
matrix = flowAvailable ? (volumeTotal > 0 ? (smoothedUpVolume - smoothedDownVolume) / volumeTotal * 100 : 0) : na
fairness = flowAvailable ? (range > 0 ? math.clamp((close - weightedPrice) / range * 35, -100, 100) : 0) : na
rawMvp = flowAvailable ? flow * 0.65 + fairness * 0.35 : na
mvpAverage = ta.ema(rawMvp, fastPeriod)
mvpSecond = ta.ema(mvpAverage, fastPeriod)
mvp = flowAvailable ? math.clamp(2 * mvpAverage - mvpSecond, -100, 100) : na
main = mode == 1 and flowAvailable ? mvp : prime
signal = ta.ema(main, signalPeriod)
rising = main > main[1]
confidence = na(main) ? 0 : math.clamp(math.abs(main) / 100, 0, 1)
primeShade = rising ? math.colorGradient(confidence, 0, 1, "#557569", bullColor) : math.colorGradient(confidence, 0, 1, "#795C55", bearColor)
mvpShade = rising ? math.colorGradient(confidence, 0, 1, "#446879", mvpBullColor) : math.colorGradient(confidence, 0, 1, "#68547C", mvpBearColor)
mainShade = na(main) ? na : (mode == 1 and flowAvailable ? mvpShade : primeShade)
flowShade = not flowAvailable ? na : flow >= 0 ? math.colorGradient(math.abs(flow), 0, 100, "#345547", bullColor) : math.colorGradient(math.abs(flow), 0, 100, "#553F38", bearColor)
matrixShade = not flowAvailable ? na : matrix >= 0 ? math.colorGradient(math.abs(matrix), 0, 100, "#345547", bullColor) : math.colorGradient(math.abs(matrix), 0, 100, "#553F38", bearColor)
volumeUnavailable = not flowAvailable

rankReady = not na(prime) and not na(main[1]) and priceMotion > 0
condition1 = rsi > 50 ? 1 : 0
condition2 = wave > 0 ? 1 : 0
condition3 = fastTrend > slowTrend ? 1 : 0
condition4 = close > fastTrend ? 1 : 0
condition5 = rising ? 1 : 0
condition6 = flowAvailable and flow > 0 ? 1 : 0
condition7 = flowAvailable and matrix > 0 ? 1 : 0
rankAvailable = flowAvailable ? 7 : 5
bullVotes = condition1 + condition2 + condition3 + condition4 + condition5 + condition6 + condition7
bearVotes = rankAvailable - bullVotes
rankScore = rankReady ? bullVotes - bearVotes : na
bullPowerShade = rankReady ? math.colorGradient(bullVotes / rankAvailable, 0, 1, "#24332C", bullColor) : na
bearPowerShade = rankReady ? math.colorGradient(bearVotes / rankAvailable, 0, 1, "#332724", bearColor) : na
powerTop = showPowerBars and rankReady ? 118 : na
powerTopBase = 112
powerBottom = -112
powerBottomBase = showPowerBars and rankReady ? -118 : na
matrixTop = showVolumeMatrix and flowAvailable ? -100 : na
matrixBottom = -106
tracker = showMoneyFlow and flowAvailable ? flow * 0.6 : na
zero = 0
zoneUpper = upper
zoneLower = lower
outerUpper = 100
outerLower = -100

pane(title="Prime / MVP Suite · independent", height=panelHeight, min=-125, max=125, note="Volume components inactive; price oscillator active", noteWhen=volumeUnavailable)
fill(outerUpper, zoneUpper, color=bearColor, opacity=0.06)
fill(zoneLower, outerLower, color=bullColor, opacity=0.06)
fill(tracker, zero, colorSeries=flowShade, opacity=0.2)
fill(main, signal, colorSeries=mainShade, opacity=ribbonOpacity)
fill(powerTop, powerTopBase, colorSeries=bullPowerShade, style="cells", opacity=0.95)
fill(powerBottom, powerBottomBase, colorSeries=bearPowerShade, style="cells", opacity=0.95)
fill(matrixTop, matrixBottom, colorSeries=matrixShade, style="cells", opacity=0.95)
plot(tracker, title="Money Flow Tracker", colorSeries=flowShade, width=1, opacity=0.6)
plot(signal, title="Signal ribbon", colorSeries=mainShade, width=1, opacity=0.6)
plot(main, title="Prime / MVP oscillator", colorSeries=mainShade, width=3)
hline(0, color="#999999", style="dotted", opacity=0.4)
rankLabelBar = barIndex - math.floor(barIndex / rankStride) * rankStride == 0
plotText(zero, when=showRank and rankReady and rankLabelBar, text="" + bullVotes + "/" + rankAvailable, color=rankScore >= 0 ? bullColor : bearColor, position="center", fontSize=8)

upperLevel = upper
lowerLevel = lower
fairnessReverseUp = ta.crossover(fairness, lowerLevel)
fairnessReverseDown = ta.crossunder(fairness, upperLevel)
plotShape(main, when=showMoneyFlow and flowAvailable and fairnessReverseUp, shape="square", color=bullColor, position="below", size=4)
plotShape(main, when=showMoneyFlow and flowAvailable and fairnessReverseDown, shape="square", color=bearColor, position="above", size=4)
alertcondition(flowAvailable and fairnessReverseUp, title="Volume-weighted discount recovered")
alertcondition(flowAvailable and fairnessReverseDown, title="Volume-weighted premium reversed")
reverseUp = ta.crossover(main, lowerLevel)
reverseDown = ta.crossunder(main, upperLevel)
plotShape(main, when=showReversals and reverseUp, shape="triangleUp", color=bullColor, position="below", size=6)
plotShape(main, when=showReversals and reverseDown, shape="triangleDown", color=bearColor, position="above", size=6)
overextension = mode == 1 and flowAvailable and math.abs(main) > 75 and math.abs(fairness) > 60 ? (main > 0 ? 100 : -100) : na
plot(overextension, title="MVP extension warnings", style="histogram", color=bullColor, opacity=0.45)
shiftUp = isClosed and rankReady and rankScore > 0 and nz(rankScore[1]) <= 0 and main > signal
shiftDown = isClosed and rankReady and rankScore < 0 and nz(rankScore[1]) >= 0 and main < signal
plotShape(main, when=showShifts and shiftUp, shape="diamond", color=mvpBullColor, position="center", size=6)
plotShape(main, when=showShifts and shiftDown, shape="diamond", color=mvpBearColor, position="center", size=6)

oscLowPivot = ta.pivotlow(main, strength, strength)
oscHighPivot = ta.pivothigh(main, strength, strength)
oscLastLow = barIndex > 0 ? oscLastLow[1] : na
oscLastLowPrice = barIndex > 0 ? oscLastLowPrice[1] : na
oscLastLowBar = barIndex > 0 ? oscLastLowBar[1] : 0
oscLastHigh = barIndex > 0 ? oscLastHigh[1] : na
oscLastHighPrice = barIndex > 0 ? oscLastHighPrice[1] : na
oscLastHighBar = barIndex > 0 ? oscLastHighBar[1] : 0
oscBullDivergence = 0
oscBearDivergence = 0
if isClosed and not na(oscLowPivot) {
    oscLowBar = barIndex - strength
    oscLowGap = oscLowBar - oscLastLowBar
    oscBullDivergence = not na(oscLastLow) and oscLowGap >= math.max(1, divergenceMinBars) and oscLowGap <= math.max(divergenceMinBars, divergenceMaxBars) and low[strength] < oscLastLowPrice and oscLowPivot > oscLastLow
    if showDivergences and oscBullDivergence {
        draw.label("oscBull" + barIndex, oscLowBar, main[strength], "D", color=mvpBullColor, fontSize=9, position="below")
    }
    oscLastLow = oscLowPivot
    oscLastLowPrice = low[strength]
    oscLastLowBar = oscLowBar
}
if isClosed and not na(oscHighPivot) {
    oscHighBar = barIndex - strength
    oscHighGap = oscHighBar - oscLastHighBar
    oscBearDivergence = not na(oscLastHigh) and oscHighGap >= math.max(1, divergenceMinBars) and oscHighGap <= math.max(divergenceMinBars, divergenceMaxBars) and high[strength] > oscLastHighPrice and oscHighPivot < oscLastHigh
    if showDivergences and oscBearDivergence {
        draw.label("oscBear" + barIndex, oscHighBar, main[strength], "D", color=mvpBullColor, fontSize=9, position="above")
    }
    oscLastHigh = oscHighPivot
    oscLastHighPrice = high[strength]
    oscLastHighBar = oscHighBar
}
alertcondition(oscBullDivergence, title="Oscillator bullish divergence")
alertcondition(oscBearDivergence, title="Oscillator bearish divergence")

moneyLowPivot = ta.pivotlow(flow, strength, strength)
moneyHighPivot = ta.pivothigh(flow, strength, strength)
moneyLastLow = barIndex > 0 ? moneyLastLow[1] : na
moneyLastLowPrice = barIndex > 0 ? moneyLastLowPrice[1] : na
moneyLastLowBar = barIndex > 0 ? moneyLastLowBar[1] : 0
moneyLastHigh = barIndex > 0 ? moneyLastHigh[1] : na
moneyLastHighPrice = barIndex > 0 ? moneyLastHighPrice[1] : na
moneyLastHighBar = barIndex > 0 ? moneyLastHighBar[1] : 0
moneyBullDivergence = 0
moneyBearDivergence = 0
if isClosed and not na(moneyLowPivot) {
    moneyLowBar = barIndex - strength
    moneyLowGap = moneyLowBar - moneyLastLowBar
    moneyBullDivergence = not na(moneyLastLow) and moneyLowGap >= math.max(1, divergenceMinBars) and moneyLowGap <= math.max(divergenceMinBars, divergenceMaxBars) and low[strength] < moneyLastLowPrice and moneyLowPivot > moneyLastLow
    if showDivergences and moneyBullDivergence {
        draw.label("moneyBull" + barIndex, moneyLowBar, main[strength], "MF", color=mvpBullColor, fontSize=9, position="below")
    }
    moneyLastLow = moneyLowPivot
    moneyLastLowPrice = low[strength]
    moneyLastLowBar = moneyLowBar
}
if isClosed and not na(moneyHighPivot) {
    moneyHighBar = barIndex - strength
    moneyHighGap = moneyHighBar - moneyLastHighBar
    moneyBearDivergence = not na(moneyLastHigh) and moneyHighGap >= math.max(1, divergenceMinBars) and moneyHighGap <= math.max(divergenceMinBars, divergenceMaxBars) and high[strength] > moneyLastHighPrice and moneyHighPivot < moneyLastHigh
    if showDivergences and moneyBearDivergence {
        draw.label("moneyBear" + barIndex, moneyHighBar, main[strength], "MF", color=mvpBullColor, fontSize=9, position="above")
    }
    moneyLastHigh = moneyHighPivot
    moneyLastHighPrice = high[strength]
    moneyLastHighBar = moneyHighBar
}
alertcondition(moneyBullDivergence, title="Money flow bullish divergence")
alertcondition(moneyBearDivergence, title="Money flow bearish divergence")

plotShape(main, when=showDivergences and (oscBullDivergence or oscBearDivergence), shape="circle", color=mvpBullColor, size=4, position="center")
alertcondition(reverseUp, title="Oscillator left lower zone")
alertcondition(reverseDown, title="Oscillator left upper zone")
alertcondition(shiftUp, title="Bullish confluence shift")
alertcondition(shiftDown, title="Bearish confluence shift")

Version history

  1. Version 1
    View this version →

Discussion · 0

Support this script and join the discussion from your broker’s trading terminal using your author profile.

    No comments yet.