0bps

Strategy vault / Momentum

Positive Volume Index Strategy

The Positive Volume Index strategy compares the volume of yesterday and today. It calculates price change on days when volume expands to form the positive volume index, and compares it to its moving average to…

Author
ChaoZhang
Complexity
Starter · 43 lines
Parameters
2
Backtest bar
3h · intraday
Tested on
BTC/USDT · futures

Overview

The Positive Volume Index strategy compares the volume of yesterday and today. It calculates price change on days when volume expands to form the positive volume index, and compares it to its moving average to generate trading signals. The strategy follows the market principle of concurrent volume and price expansion.

Strategy Logic

The strategy first calculates the daily price change xROC. It then compares today's volume with yesterday's volume[1]. If today's volume is greater, the positive volume index nRes today is yesterday's index nRes[1] plus xROC. If today's volume is less than or equal to yesterday's, today's index remains the same as yesterday's nRes[1].

After calculating the positive volume index nRes, it is compared to its N-day moving average nResEMA. If nRes is greater than nResEMA, it is a long signal. If nRes is less than nResEMA, it is a short signal.

The strategy follows the relationship between the positive volume index and its moving average to generate trading signals. When the index crosses above the moving average, it is a buy signal. When the index crosses below, it is a sell signal.

Advantage Analysis

The advantages of this strategy include:

  1. It captures market momentum by observing volume change.

  2. It has some trend following capability. Index rise suggests potential bull market.

  3. The logic is simple for implementation and backtesting.

  4. Trading frequency can be controlled by adjusting the moving average parameter.

Risk Analysis

The main risks of this strategy are:

  1. Volume expansion does not necessarily mean price expansion. Divergence may happen.

  2. Reasonable stop loss should be set to control losses.

  3. Signals from index and moving average lag price changes.

  4. Abnormal volume or over-optimization can lead to false signals.

Optimization Directions

The strategy can be optimized in the following aspects:

  1. Test adding other technical indicators like MACD, KDJ for signal filtration.

  2. Optimize the moving average parameter for best balance.

  3. Add stop loss mechanisms like trailing stop to control risks.

  4. Consider partial position exits to gradually reduce risks.

  5. Optimize parameters for specific products to improve robustness.

Conclusion

The positive volume index strategy designs trades based on volume change, with some market following capability. But divergence between volume and price should be noted. By optimizing parameters, setting stop loss, adding indicators etc, the strategy can be improved to control risks and enhance performance. It is suitable for exploring price-volume relationship and assisting market timing.

Parameters

NameDefaultWhat it controls
v_input_1255EMA_Len
v_input_2falseTrade reverse

Source Pine Script

/*backtest
start: 2023-08-18 00:00:00
end: 2023-09-17 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 11/10/2017
// The theory behind the indexes is as follows: On days of increasing volume, 
// you can expect prices to increase, and on days of decreasing volume, you can 
// expect prices to decrease. This goes with the idea of the market being in-gear 
// and out-of-gear. Both PVI and NVI work in similar fashions: Both are a running 
// cumulative of values, which means you either keep adding or subtracting price 
// rate of change each day to the previous day`s sum. In the case of PVI, if today`s 
// volume is less than yesterday`s, don`t add anything; if today`s volume is greater, 
// then add today`s price rate of change. For NVI, add today`s price rate of change 
// only if today`s volume is less than yesterday`s.
//
// You can change long to short in the Input Settings
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="Positive Volume Index", shorttitle="Positive Volume Index")
EMA_Len = input(255, minval=1)
reverse = input(false, title="Trade reverse")
xROC = roc(close, 1)
nRes = iff(volume > volume[1], nz(nRes[1], 0) + xROC, nz(nRes[1], 0))
nResEMA = ema(nRes, EMA_Len)
pos = iff(nRes > nResEMA, 1,
	   iff(nRes < nResEMA, -1, nz(pos[1], 0))) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1, 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	   	    
barcolor(possig == -1 ? red: possig == 1 ? green : blue )  
plot(nRes, color=red, title="PVI")
plot(nResEMA, color=blue, title="EMA")

Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-18. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Positive-Volume-Index-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open