Strategy · Pine Script v6 · On the chart

VWMA vs SMA Divergence

by pineforge-4pass· code credited to PineForge contributors 2026

This strategy tracks the difference between a Volume-Weighted Moving Average (VWMA) and a Simple Moving Average (SMA) of identical lengths.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code33
Settings1inputs
LicenceApache-2.0
Last update5 days ago23 Oct 2026

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

33 lines of Pine Script v6 from validation/ta-vwma-vs-sma-divergence-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// PF probe 14 — VWMA vs SMA divergence
// Purpose: parity test for ta.vwma() (volume-weighted MA) against ta.sma() with
// zero-cross of their difference as the entry trigger.
//
//@version=6
strategy("VWMA vs SMA Divergence", overlay=true, initial_capital=1000000, process_orders_on_close=false, pyramiding=1, commission_type=strategy.commission.percent, commission_value=0, slippage=0, default_qty_type=strategy.fixed, default_qty_value=1)

// === Inputs ===
len = input.int(20, "Length", minval=5)

// === VWMA vs SMA ===
vwmaVal = ta.vwma(close, len)
smaVal  = ta.sma(close, len)

// === Divergence: VWMA > SMA = volume-weighted buying pressure ===
vwmaDiff = vwmaVal - smaVal

// === Signals ===
longCond  = ta.crossover(vwmaDiff, 0)
shortCond = ta.crossunder(vwmaDiff, 0)

// === Strategy ===
if longCond
    strategy.entry("Long", strategy.long)
if shortCond
    strategy.entry("Short", strategy.short)

plot(vwmaVal, "VWMA", color=color.blue, linewidth=2)
plot(smaVal, "SMA", color=color.orange, linewidth=2)

Overview

VWMA vs SMA Divergence enters a long position when the VWMA crosses above the SMA, and enters a short position when the VWMA crosses below the SMA, reversing any existing position. The indicator plots both moving average lines directly on the price chart. It features no defined stop-loss, take-profit, or trailing stop exits.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge contributors 2026, as written in the script's header

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Moving averages, Volume

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

Settings

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

SettingTypeDefaultVariable
Lengthint20len
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

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
218 stars

This strategy enters long when a faster moving average crosses above a slower one and short when it crosses below, unless long-only mode is on. An optional volume filter requires volume above a 20-bar average times a multiplier. Exits use a percentage stop los

Strategy v6 TrendMoving averages
Updated 3 months ago · None stated GitHub repository of MA Cross Strategy Template

4x EMA + Volume

by hasnocool
106 stars

This strategy plots four exponential moving averages on the price chart and filters trades with a smoothed Ease of Movement oscillator. In the default mode it opens a long when price and the four averages are stacked upward and Ease of Movement is positive, th

Strategy v4 TrendMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of 4x EMA + Volume
39 stars

This intraday strategy implements Mark Fisher's Opening Range Breakout (ORB) methodology tailored for index futures like ES and NQ. It calculates session opening ranges, volume z-scores, and VWAP bands to plot support, resistance, and confirmation levels on th

Strategy v6 BreakoutSessions & time Repaints
Updated 4 days ago · MIT GitHub repository of Futures Intraday Pro (ES/NQ) Strategy

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

This strategy enters long or short when eight conditions align over the last two bars. It requires EMA 10 and EMA 55 alignment on the one-hour, four-hour and daily charts, a positive ADX slope, matching monitor direction, and price relative to a 400-bar point

Strategy v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of Ruckard ABCBitcoin TradingLatino B002

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