Strategy · Pine Script v6 · On the chart

PF OCA Probe 02 Multi-Bracket Isolation

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

A test strategy from a reference corpus that checks independent exit brackets.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code46
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

46 lines of Pine Script v6 from validation/oca-multi-bracket-isolation-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
//
// OCA probe 02 — multi-bracket via strategy.exit (internal CANCEL)
//
// Purpose: two strategy.exit brackets attached to same long entry,
// different ATR widths + different oca_name. Tests cross-bracket
// isolation: tight bracket fills first → only its own TP/SL cancel,
// the wider bracket continues running. Pine v6 strategy.exit uses
// internal OCA-CANCEL between TP and SL within the SAME oca_name.
// Different oca_name → independent.
//
// strategy.exit is close-only → no leaked-short trap.
//
// Trade shape: long-only RSI/EMA confluence, qty=2 entry, two brackets
// each qty=1.
//
// TV setup: 15m chart, ETH-USDT-USDT.
//@version=6
strategy("PF OCA probe 02 - multi-bracket isolation", shorttitle="OCA_p02_MGP", overlay=true,
     initial_capital=1000000,
     commission_type=strategy.commission.percent, commission_value=0, slippage=0,
     default_qty_type=strategy.fixed, default_qty_value=2, pyramiding=1,
     process_orders_on_close=false)

rsiVal  = ta.rsi(close, 14)
atrVal  = ta.atr(14)
emaFast = ta.ema(close, 9)
emaSlow = ta.ema(close, 21)

bool entryCond = ta.crossover(emaFast, emaSlow) and rsiVal < 60

if entryCond and strategy.position_size == 0
    strategy.entry("L", strategy.long, qty=2, comment="entry")

if strategy.position_size > 0
    entry = strategy.position_avg_price
    // Bracket A: tight ATR — hits more often
    strategy.exit("X_A", from_entry="L", qty=1,
         limit=entry + atrVal * 1.0, stop=entry - atrVal * 1.0,
         oca_name="GRP_A")
    // Bracket B: wider ATR — independent group
    strategy.exit("X_B", from_entry="L", qty=1,
         limit=entry + atrVal * 2.0, stop=entry - atrVal * 2.0,
         oca_name="GRP_B")

Overview

PF OCA Probe 02 Multi-Bracket Isolation goes long two units when a 9-period EMA crosses above a 21-period EMA and RSI is below 60. Two exit orders each handle one unit, one with a stop and target one ATR from the average entry and the other two ATR away, using separate order groups. The tighter bracket can close without cancelling the wider one. It is a code example for engine testing, with zero commission.

Details

Published by

pineforge-4pass on GitHub

Code credit

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

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

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

This overlay strategy offers two selectable entry modes: a Bollinger squeeze on typical price and a simple moving-average cross. It filters trades by weekday, session, date range, and an optional news window, and can restrict direction or invert the side. Risk

Strategy v5 Volatility & bandsMoving averages
Updated yesterday · None stated GitHub repository of Boilerplate Configurable Strategy [Yosiet]
257 stars

This overlay strategy targets one-minute ES futures and plots volume-weighted moving-average bands from the open, scaled by a standard-deviation multiple, plus a slower band from ten-minute opens. A higher-timeframe exponential moving average can filter trades

Strategy v6 Moving averagesVolatility & bands
Updated 6 weeks ago · None stated GitHub repository of ES - Futures 1M No Repaint
228 stars

The Mean Reversion Strategy Template calculates a baseline mean using SMA, EMA, or VWAP alongside upper and lower deviation bands based on standard deviation, ATR, or percentage offsets. It generates long and short entries when price touches, bounces from, or

Strategy v6 Mean reversionMoving averages
Updated 3 months ago · None stated GitHub repository of Mean Reversion Strategy Template

STRG-BBForce

by harryguiacorn
220 stars

STRG-BBForce is a Bollinger Bands trend-following strategy. It calculates standard Bollinger Bands and tracks directional alignment across the upper, lower, and basis lines. When all three lines slope upward, it opens a long position and closes short positions

Strategy v5 TrendVolatility & bands
Updated 1 year ago · None stated GitHub repository of STRG-BBForce

Bollinger Breakout

by hackingthemarkets
189 stars

This price-chart strategy plots a simple moving average and upper and lower bands built from the standard deviation of close, scaled by separate offset inputs. It enters a fixed quantity long when close crosses above the upper band and a fixed quantity short w

Strategy v4 Volatility & bandsBreakout
Updated 3 years ago · None stated GitHub repository of Bollinger Breakout

More Volatility & bands scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers