Strategy · Pine Script v5 · On the chart

Version Kappa: Composite Momo + Volume + Price Strategy

by jawauntb

Version Kappa: Composite Momo + Volume + Price Strategy evaluates trend, momentum, and volume dynamics to generate trading signals on the price chart.

View on GitHub

Repaints

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code184
Settings10inputs
LicenceGPL-3.0
Last update2 years ago22 May 2024

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

184 lines of Pine Script v5 from momentum-volume-price-strat.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

momentum-volume-price-strat.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jawauntb

//@version=5
strategy("Version Kappa: Composite Momo + Volume + Price Strategy", overlay=true, calc_on_every_tick=true)

// Define constants for milliseconds conversion
MS_IN_MIN = 60 * 1000
MS_IN_HOUR = MS_IN_MIN * 60
MS_IN_DAY = MS_IN_HOUR * 24

// Function to determine higher timeframe
htfStep() =>
    tfInMs = timeframe.in_seconds() * 1000
    string result = na
    if tfInMs <= MS_IN_MIN
        result := "60"
    else if tfInMs < MS_IN_HOUR * 3
        result := "D"
    else if tfInMs <= MS_IN_HOUR * 12
        result := "W"
    else if tfInMs < MS_IN_DAY * 7
        result := "M"
    else
        result := "12M"
    result

// Inputs
rsiPeriod = input.int(14, "RSI Period")
emaPeriod = input.int(15, "EMA Period")
maPeriod = input.int(32, "MA Period")
vwapPeriod = input.int(10, "VWAP Period")
vwapBandMultiplier = input.float(0.5, "VWAP Band Multiplier")
tprInput = input.int(8, "VRVP Ticks Per Row")
cvdPersistencePeriods = input.int(4, "CVD Persistence Periods")
higherTimeframe = htfStep()

// CVD calculations
[cvdUp, cvdDown] = request.security(syminfo.tickerid, timeframe.period, expression=[high, low], lookahead=barmerge.lookahead_on)
cvd = cvdUp - cvdDown
cvdStdev = ta.stdev(cvd, 20)
cvdBrightThreshold = cvdStdev * 2
cvdBright = (cvd > cvdBrightThreshold) or (cvd < -cvdBrightThreshold)
cvdPersistent = ta.barssince(not cvdBright) >= cvdPersistencePeriods

// Composite RSI and Starc Bands calculations
rsiSource = close
rsiDelta = ta.rsi(rsiSource, rsiPeriod) - ta.rsi(rsiSource, rsiPeriod)[9]
rsiSma = ta.sma(ta.rsi(rsiSource, 3), 3)
compRsi = rsiDelta + rsiSma
starcBandMultiplier = input.float(2.0, "Starc Band Multiplier")
starcBasis = ta.sma(compRsi, rsiPeriod)
starcDev = starcBandMultiplier * ta.stdev(compRsi, rsiPeriod)
starcUpper = starcBasis + starcDev
starcLower = starcBasis - starcDev

// Composite RSI conditions
compRsiUpperThreshold = input.int(110, "Composite RSI Upper Threshold")
compRsiLowerThreshold = input.int(18, "Composite RSI Lower Threshold")
compRsiBottomed = compRsi < compRsi[1] and compRsi > starcLower
compRsiTopped = compRsi > compRsi[1] and compRsi < starcUpper
compRsiCrossingUp = ta.crossover(compRsi, starcLower)
compRsiCrossingDown = ta.crossunder(compRsi, starcUpper)

// Higher Timeframe Confirmation
[compRsiHigher, _] = request.security(syminfo.tickerid, higherTimeframe, [compRsi, close], lookahead=barmerge.lookahead_on)
starcUpperHigher = ta.sma(compRsiHigher, rsiPeriod) + starcBandMultiplier * ta.stdev(compRsiHigher, rsiPeriod)
starcLowerHigher = ta.sma(compRsiHigher, rsiPeriod) - starcBandMultiplier * ta.stdev(compRsiHigher, rsiPeriod)
compRsiBottomedHigher = compRsiHigher < compRsiHigher[1] and compRsiHigher > starcLowerHigher
compRsiToppedHigher = compRsiHigher > compRsiHigher[1] and compRsiHigher < starcUpperHigher

// EMA/MA calculations
ema = ta.ema(close, emaPeriod)
ma = ta.sma(close, maPeriod)
emaBullish = ema > ma * 1.01
emaBearish = ema < ma * 0.99

// VWAP calculation
[vwap, vwapUpper, vwapLower] = ta.vwap(hlc3, true, vwapBandMultiplier)

// VRVP calculation
[poc, _, _] = request.security(syminfo.tickerid, timeframe.period, expression=[close, high, low], lookahead=barmerge.lookahead_on)
[totalVolume, _, _] = request.security(syminfo.tickerid, timeframe.period, expression=[volume, high, low], lookahead=barmerge.lookahead_on)
tpr = tprInput/syminfo.mintick
vrvpUpperBound = poc + tpr * 1.2
vrvpLowerBound = poc - tpr * 1.2

// Footprint calculations
fpAbovePriceBuy = request.security(syminfo.tickerid, timeframe.period, high, lookahead=barmerge.lookahead_on)
fpAbovePriceSell = request.security(syminfo.tickerid, timeframe.period, low, lookahead=barmerge.lookahead_on)
fpBelowPriceBuy = request.security(syminfo.tickerid, timeframe.period, high, lookahead=barmerge.lookahead_on)
fpBelowPriceSell = request.security(syminfo.tickerid, timeframe.period, low, lookahead=barmerge.lookahead_on)
fpAbovePrice = fpAbovePriceBuy - fpAbovePriceSell
fpBelowPrice = fpBelowPriceBuy - fpBelowPriceSell
fpAbovePriceDecreasing = fpAbovePrice < fpAbovePrice[1]
fpBelowPriceDecreasing = fpBelowPrice > fpBelowPrice[1]

// Volume Confirmation
volumeMA = ta.sma(volume, 15)
volumeConfirmation = volume > volumeMA

// Market Regime
maLong = ta.sma(close, 105)
maShort = ta.sma(close, 24)
maMedium = ta.sma(close, 50)
trendingUp = maShort > maMedium and maMedium > maLong
trendingDown = maShort < maMedium and maMedium < maLong

// Signal conditions
compRsiLongCondition = (compRsiBottomed and (compRsiCrossingUp or compRsi < compRsiUpperThreshold))
compRsiShortCondition = (compRsiTopped and compRsiCrossingDown) or compRsi > (compRsiLowerThreshold*4)
compRsiHigherLongCondition = compRsiBottomedHigher and compRsiHigher < (compRsiUpperThreshold*1.1)
compRsiHigherShortCondition = compRsiToppedHigher and compRsiHigher > (compRsiLowerThreshold*2.8)

// Composite RSI momentum conditions
compRsiMomentumLongCondition = compRsiLongCondition or (compRsiHigherLongCondition and (compRsi > 67)) or ((compRsi > rsiSma) and compRsi > 46)
compRsiMomentumShortCondition = compRsiShortCondition or compRsiHigherShortCondition

// Trend condition
trendCondition = (trendingUp or emaBullish) or (trendingDown and emaBearish)
// Volume condition
volumeCondition = (cvd > 0 and volumeConfirmation) or (volumeConfirmation and cvd < 0)

// Price condition
priceCondition = (close > (0.95* vwap)) or (close < 0.7*vwap)

// Signal conditions
// longCondition = compRsiMomentumLongCondition and volumeCondition and (priceCondition or trendCondition)  
// shortCondition = compRsiMomentumShortCondition and volumeCondition and (priceCondition or trendCondition)
// -------
// longCondition = compRsiMomentumLongCondition and (volumeCondition or (trendCondition and priceCondition))
// shortCondition = compRsiMomentumShortCondition and (volumeCondition or (trendCondition and priceCondition))

longCondition = (compRsiMomentumLongCondition and volumeCondition and (priceCondition or trendCondition)) or (volumeCondition and compRsiCrossingUp and (priceCondition and trendCondition)) or (compRsi > rsiSma*1.15 and volumeCondition and (compRsi > 40 or (priceCondition or trendCondition)))
shortCondition = (compRsiMomentumShortCondition and volumeCondition and trendCondition) or (volumeCondition and (trendCondition and (priceCondition or compRsiShortCondition)))  or (compRsi < rsiSma*.85 and volumeCondition and rsiSma <60 and (priceCondition or trendCondition))

// Dynamic Stop Loss and Take Profit calculations
atrPeriod = 13
atrMultiplier = 2.0
atr = ta.atr(atrPeriod)
longStopLoss = strategy.position_avg_price - atrMultiplier * atr
longTakeProfit = strategy.position_avg_price + atrMultiplier * atr
shortStopLoss = strategy.position_avg_price + atrMultiplier * atr
shortTakeProfit = strategy.position_avg_price - atrMultiplier * atr

// Plotting signals
plotshape(series=longCondition, title="Long Signal", location=location.belowbar, color=color.rgb(58, 255, 170), style=shape.triangleup, size=size.small)
plotshape(series=shortCondition, title="Short Signal", location=location.abovebar, color=color.rgb(183, 12, 69), style=shape.triangledown, size=size.small)

// Function to plot individual condition confirmations or breaks
plotCondition(series, condition, labelTrue, labelFalse, yOffset) =>
    var label myLabel = na
    labelText = condition ? labelTrue : labelFalse
    labelColor = condition ? color.new(color.green, 0) : color.new(color.red, 0)
    
    // Detect changes in the condition value
    conditionChanged = ta.change(condition)
    
    if conditionChanged or barstate.islast
        if (na(myLabel))
            myLabel := label.new(x=time, y=series + yOffset, text=labelText, style=label.style_label_down, color=labelColor, size=size.small, textcolor=color.white, xloc=xloc.bar_time, yloc=yloc.price)
        else
            label.set_xy(myLabel, x=time, y=series + yOffset)
            label.set_text(myLabel, text=labelText)
            label.set_color(myLabel, color=labelColor)
            label.set_textcolor(myLabel, color.white)
    myLabel
// Assuming atr is already calculated somewhere in your script
atrl = ta.atr(14)

// Check and plot each condition separately
plotCondition(close, compRsiMomentumLongCondition, "Bullish Momentum Confirmed", "Momentum Broken: Bearish", atrl * 2.25)
plotCondition(close, volumeCondition, "Bullish Volume Confirmed", "Volume Broken: Bearish", atrl * 1.75)
plotCondition(close, priceCondition, "Bullish Price Confirmed", "Price Broken: Bearish", atrl * 1.2)
plotCondition(close, trendCondition, "Bullish Trend Confirmed", "Trend Broken: Bearish", atrl * 0.75)

// Strategy execution
if (longCondition)
    strategy.entry("Long", strategy.long)
    strategy.exit("Exit Long", "Long", stop=longStopLoss, limit=longTakeProfit)
    
if (shortCondition)
    strategy.entry("Short", strategy.short)
    strategy.exit("Exit Short", "Short", stop=shortStopLoss, limit=shortTakeProfit)

Overview

Version Kappa: Composite Momo + Volume + Price Strategy calculates a composite RSI wrapped in Starc Bands, tracking momentum across both current and higher timeframes. Trend confirmation is derived from EMA and SMA relationships alongside VWAP bands and cumulative volume delta calculations. Key settings control indicator periods, threshold boundaries, and band multipliers. Because the strategy queries higher-timeframe data using lookahead mode and calculates on every tick, historical results suffer from lookahead bias and repainting.

Details

Published by

jawauntb on GitHub

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Oscillators & momentum, Volume, Moving averages, Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)
  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time
  • The strategy enters trades without a stop loss

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
RSI Periodint14rsiPeriod
EMA Periodint15emaPeriod
MA Periodint32maPeriod
VWAP Periodint10vwapPeriod
VWAP Band Multiplierfloat0.5vwapBandMultiplier
VRVP Ticks Per Rowint8tprInput
CVD Persistence Periodsint4cvdPersistencePeriods
Starc Band Multiplierfloat2.0starcBandMultiplier
Composite RSI Upper Thresholdint110compRsiUpperThreshold
Composite RSI Lower Thresholdint18compRsiLowerThreshold
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

BB+RSI+OBV

by hasnocool
106 stars

This strategy combines Bollinger Bands, the Relative Strength Index (RSI), and On-Balance Volume (OBV) to generate trade signals directly on the price chart. Long entries trigger when price is above the middle SMA band, RSI is over 50, and OBV is rising. Short

Strategy v4 Volatility & bandsOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of BB+RSI+OBV

CombinedBinHAndClucV8

by viktors1982
36 stars

This strategy trades on the price chart using multiple indicators. It enters long positions when price dips meet conditions on Bollinger Bands 40 and 20, RSI, MFI, volume and other thresholds. It exits at custom ROI profit levels based on RSI or after timeout

Strategy v4 Oscillators & momentumMoving averages Repaints
Updated 2 years ago · None stated GitHub repository of CombinedBinHAndClucV8
4 stars

The Simpleton STEPFUN Strategy combines signals from multiple technical indicators including RSI-2, MACD crossover, Bollinger Band squeeze, volume spikes, triple EMA, and Ichimoku cloud. It generates buy signals when the weighted ensemble meets or exceeds the

Strategy v5 Oscillators & momentumVolatility & bands
1 stars

TnSovereignSignalForgeV20 is a price-chart strategy that combines seven directional votes from RSI, EMA, MACD, volume, VWAP, Bollinger Bands, and a volume oscillator. A long condition requires the vote total to meet a minimum agreement setting. A thermodynamic

Strategy v6 Oscillators & momentumMoving averages
Updated 2 months ago · None stated GitHub repository of TnSovereignSignalForgeV20
330 stars

This strategy plots MACD line, signal line, Bollinger Bands, and RSI on the price chart. It signals long entries on MACD crossover above signal with RSI below 50 and price below BB basis, plus optional DMI filter. Short entries are available but disabled by de

Strategy v5 Oscillators & momentumVolatility & bands
Updated 2 months ago · None stated GitHub repository of MACD + BB + RSI [Alorse]
257 stars

This overlay strategy is built for ES futures on the one-minute chart. It plots a volume-weighted moving average of price opens and standard-deviation bands at Fibonacci ratios, plus a second longer volume-weighted average from a higher-timeframe open. Call an

Strategy v5 Volatility & bandsMoving averages
Updated 6 weeks ago · None stated GitHub repository of ES Futures 1M No Repaint

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers