Strategy · Pine Script v6 · Own pane

OBV EMA Cross

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

A minimal strategy that compares On Balance Volume with a 21-period EMA of itself.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code24
Settings0inputs
LicenceApache-2.0
Last update6 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

24 lines of Pine Script v6 from validation/ta-obv-ema-cross-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 TA-isolate probe — On-Balance Volume (ta.obv) vs its EMA(21) signal cross.
// Isolates ta.obv, the cumulative volume-flow SERIES built-in (used WITHOUT
// parens, as a property — obv = ta.obv). OBV is an unbounded running sum that
// adds/subtracts the full bar volume on every close tick, so the raw magnitude
// and the cumulative-from-first-bar seeding are exactly the kind of thing that
// only a TradingView export can adjudicate against the engine's ta::OBV.
//@version=6
strategy("PF TA isolate - OBV EMA(21) cross", shorttitle="TAI_OBV",
     overlay=false, initial_capital=1000000,
     commission_type=strategy.commission.percent, commission_value=0, slippage=0,
     default_qty_type=strategy.fixed, default_qty_value=1, pyramiding=1,
     process_orders_on_close=false)

obv = ta.obv
sig = ta.ema(obv, 21)

if ta.crossover(obv, sig)
    strategy.entry("L", strategy.long, comment="obv cross up")
if ta.crossunder(obv, sig)
    strategy.entry("S", strategy.short, comment="obv cross dn")

Overview

OBV EMA Cross enters long when OBV crosses above the average and short when it crosses below, reversing the position each time. It has no adjustable inputs, no stop loss and no take profit. It is written as an isolated test of the OBV calculation and shows its strategy output in a separate pane.

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

Separate pane below the chart

Category

Volume

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

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

Q-Trend + KVO Strategy

by TradersPost
218 stars

This strategy combines the ATR-banded Q-Trend indicator with the Klinger Volume Oscillator (KVO) to execute confluence trades. It enters long when a Q-Trend buy trigger aligns with a positive KVO value and a bullish candle confirmation, taking short trades und

Strategy v6 TrendVolume
Updated 3 months ago · None stated GitHub repository of Q-Trend + KVO Strategy
106 stars

This strategy calculates and plots aggregated Bitcoin volume collected across multiple exchanges, along with two volume moving averages in a separate pane. It enters long positions when price crosses above a fast EMA while remaining above a slow EMA, and enter

Strategy v4 TrendMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of Aggregate BTC Volume + EMA Strat

BTC Futures MACD

by iamrichardD
57 stars

This strategy plots a MACD oscillator in a separate pane and trades Bitcoin futures from zero-line and signal-line crosses. Optional early momentum signals, a volume filter, and a trend moving-average filter can confirm entries. It sizes positions as fixed con

Strategy v6 Oscillators & momentumMoving averages Repaints
Updated 1 year ago · Apache-2.0 GitHub repository of BTC Futures MACD

RSI-VWAP Indicator

by oguzhandilber
47 stars

This strategy calculates a Relative Strength Index (RSI) applied to the Volume Weighted Average Price (VWAP) rather than standard close values. It plots dedicated long and short RSI-VWAP lines with customizable overbought and oversold thresholds, alongside an

Strategy v4 Oscillators & momentumVolume
Updated 5 years ago · None stated GitHub repository of RSI-VWAP Indicator

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