Strategy · Pine Script v6 · On the chart

PineForge — Crosscurrent Market Pair

by pineforge-4pass· code credited to PineForge

This strategy uses RSI with bull and bear threshold crossovers to trade opposite market pairs.

View on GitHub

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

44 lines of Pine Script v6 from validation/order-crosscurrent-opposite-market-pair-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
//@version=6
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 PineForge
// PineForge Corporate Strategy: Crosscurrent Market Pair
// Independently authored to isolate a close-plus-opposite MARKET pair while a
// position is live.
strategy("PineForge — Crosscurrent Market Pair", overlay=true,
     initial_capital=100000,
     default_qty_type=strategy.percent_of_equity, default_qty_value=8,
     pyramiding=0, commission_type=strategy.commission.percent,
     commission_value=0.05, slippage=1,
     margin_long=100, margin_short=100,
     process_orders_on_close=false, calc_on_order_fills=false)

rsiLength = input.int(17, "RSI Length", minval=2, group="Signal")
upperTurn = input.float(58.0, "Bull Threshold", minval=50, maxval=90, group="Signal")
lowerTurn = input.float(42.0, "Bear Threshold", minval=10, maxval=50, group="Signal")
atrLength = input.int(14, "ATR Length", minval=2, group="Risk")
stopAtr = input.float(2.4, "Stop ATR", minval=0.5, step=0.1, group="Risk")

rsiValue = ta.rsi(close, rsiLength)
atrValue = ta.atr(atrLength)
bullTurn = ta.crossover(rsiValue, upperTurn)
bearTurn = ta.crossunder(rsiValue, lowerTurn)

if bullTurn
    if strategy.position_size < 0
        strategy.close("Crosscurrent Short", comment="Close before opposite market entry")
    strategy.entry("Crosscurrent Long", strategy.long)

if bearTurn
    if strategy.position_size > 0
        strategy.close("Crosscurrent Long", comment="Close before opposite market entry")
    strategy.entry("Crosscurrent Short", strategy.short)

if strategy.position_size > 0
    strategy.exit("Crosscurrent Long Guard", from_entry="Crosscurrent Long",
         stop=strategy.position_avg_price - atrValue * stopAtr)

if strategy.position_size < 0
    strategy.exit("Crosscurrent Short Guard", from_entry="Crosscurrent Short",
         stop=strategy.position_avg_price + atrValue * stopAtr)

plot(rsiValue, "RSI", display=display.data_window)

Overview

PineForge — Crosscurrent Market Pair enters long when RSI crosses above 58 and short when below 42, automatically closing the opposite position first. Entry size is 8 percent of equity with 0.05 percent commissions. Stops are placed using ATR(14) multiplied by 2.4 from the average entry price. The script draws RSI in a separate pane for signal visibility.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge, as written in the script's header

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Oscillators & momentum, Trend, Mean reversion

Markets

Forex

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

Settings

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

SettingTypeDefaultVariable
RSI Lengthint17rsiLength
Bull Thresholdfloat58.0upperTurn
Bear Thresholdfloat42.0lowerTurn
ATR Lengthint14atrLength
Stop ATRfloat2.4stopAtr
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

285 stars

Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish

Strategy v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Strategy

ADX + RSI Strat

by hasnocool
106 stars

This strategy combines a 7-period RSI with an ADX filter to trade market regimes on the price chart. When the ADX indicates ranging conditions below a set threshold, it triggers entries on RSI overbought or oversold extremes. By default, the entry logic is inv

Strategy v4 Oscillators & momentumTrend
Updated 2 years ago · GPL-3.0 GitHub repository of ADX + RSI Strat

ADX Trend Filter

by latentwill
4 stars

This strategy enters long when a series labeled ADX is above a threshold and RSI is below 40, and enters short when that series is above the threshold and RSI is above 60. Both series are calculated with the RSI function, so the trend filter is not a true ADX.

Strategy v5 TrendOscillators & momentum
Updated 6 days ago · None stated GitHub repository of ADX Trend Filter
4 stars

This strategy trades pullbacks in the direction of a moving-average trend and draws on the price chart. An uptrend requires the 50-period EMA above the 200-period EMA with price above the slower average, and a downtrend is the reverse. It enters long or short

Strategy v6 TrendOscillators & momentum

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