Strategy · Pine Script v6 · On the chart

PF OCA probe 01 - exit bracket cancel

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

This strategy detects RSI momentum crossovers to enter long positions with fixed size.

View on GitHub

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

39 lines of Pine Script v6 from validation/oca-exit-bracket-internal-cancel-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 01 — strategy.exit bracket (internal CANCEL semantics)
//
// Purpose: pin strategy.exit's built-in OCA-CANCEL bracket behavior.
// Pine v6 strategy.exit does not expose oca_type; the TP/SL pair it
// places is internally OCA-CANCEL (one fills → other cancels in same
// or next bar). This probe verifies engine bracket cancel timing
// matches TV.
//
// strategy.exit is intrinsically close-only, so once position is flat
// any unfilled bracket auto-cancels — no leaked-short trap.
//
// Trade shape: long-only RSI<30 cross-up, qty=1, ATR-wide bracket so
// volatile bars routinely sweep both sides.
//
// TV setup: 15m chart, ETH-USDT-USDT.
//@version=6
strategy("PF OCA probe 01 - exit bracket cancel", shorttitle="OCA_p01_3WAY", overlay=true,
     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)

rsiVal = ta.rsi(close, 14)
atrVal = ta.atr(14)

bool entryCond = ta.crossover(rsiVal, 30)

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

if strategy.position_size > 0
    entry = strategy.position_avg_price
    strategy.exit("X", from_entry="L", qty=1,
         limit=entry + atrVal * 1.5, stop=entry - atrVal * 1.5,
         oca_name="GRP")

Overview

When holding a position it places a bracket exit using ATR-based stop and limit levels. The OCA name ensures any filled side cancels the other. The script verifies that strategy.exit bracket cancel timing matches TradingView behavior on the same bar feed. It draws directly on the price chart with overlay mode and uses no additional panes.

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

Oscillators & momentum, Volatility & bands

Markets

Crypto

Timeframes

M15-H1

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

330 stars

Alert BB + RSI [Alorse] is a multi-symbol mean-reversion strategy designed for cryptocurrency trading. It evaluates Bollinger Bands and the Relative Strength Index (RSI) across up to 20 user-defined ticker symbols simultaneously. The strategy enters long posit

Strategy v4 Oscillators & momentumVolatility & bands
Updated 2 months ago · None stated GitHub repository of Alert BB + RSI [Alorse]
106 stars

This strategy identifies trend-following entries using a triple exponential moving average alignment and ATR-based exits on the main price chart. Long signals trigger when the fast EMA is above the medium EMA and medium is above slow, accompanied by a close ab

Strategy v4 Moving averagesVolatility & bands Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of 3 EMA + Stochastic RSI + ATR
105 stars

This overlay strategy looks for gold scalps from break of structure and change of character. It enters long when a bullish break, a bullish character change, and an optional volume filter align, and short on the opposite set. Optional RSI levels can block trad

Strategy v6 SMC / ICT / price actionOscillators & momentum Repaints
104 stars

This strategy combines Bollinger Bands with a short RSI to fade moves that leave the bands and then return. A long requires the prior bar below the lower band and oversold, then a close back inside the band while RSI is between 30 and 50. Shorts mirror that at

Strategy v5 Oscillators & momentumVolatility & bands
Updated 3 years ago · MIT GitHub repository of Bollinger Bands and RSI Strategy

Take Profits & Stop Losses

by PythonForForex
64 stars

This educational strategy demonstrates moving average crossovers filtered by RSI momentum, incorporating ATR-based risk management. It calculates a 10-period SMA, a 30-period SMA, a 14-period RSI, and a 14-period ATR. Long entries trigger when the fast SMA cro

Strategy v5 Moving averagesOscillators & momentum
Updated 4 years ago · None stated GitHub repository of Take Profits & Stop Losses

Momentum Rider DAILY FINAL

by greenpeas007
58 stars

This strategy combines exponential moving averages (EMA 9, 21, 50), RSI, MACD, and Supertrend indicators to enter long positions. It triggers trades using six dynamic setups based on momentum breakouts, EMA crossovers, and pullbacks. Position sizing is compute

Strategy v6 TrendOscillators & momentum Repaints
Updated 4 months ago · Custom licence GitHub repository of Momentum Rider DAILY FINAL

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