Strategy · Pine Script v6 · Own pane

PineForge Atlas Array Rotation

by pineforge-4pass· code credited to PineForge

This strategy computes a rolling mean return over the last sampleCount bars and a price percent rank over rankLength bars.

View on GitHub

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

45 lines of Pine Script v6 from validation/array-atlas-momentum-rotation-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: Atlas Array Rotation
// Independently authored to exercise a bounded rolling array and momentum rank.
strategy("PineForge — Atlas Array Rotation", overlay=false,
     initial_capital=100000,
     default_qty_type=strategy.percent_of_equity, default_qty_value=7,
     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)

sampleCount = input.int(8, "Return Samples", minval=3, maxval=30, group="Signal")
rankLength = input.int(55, "Rank Window", minval=10, group="Signal")
rsiLength = input.int(14, "RSI Length", minval=2, group="Signal")
entryRank = input.float(78.0, "Entry Rank", minval=50, maxval=99, group="Signal")
exitRank = input.float(46.0, "Exit Rank", minval=1, maxval=70, group="Signal")
atrLength = input.int(17, "ATR Length", minval=2, group="Risk")
stopAtr = input.float(2.4, "Stop ATR", minval=0.5, step=0.1, group="Risk")

var array<float> returns = array.new_float()
oneBarReturn = na(close[1]) ? 0.0 : 100.0 * (close / close[1] - 1.0)
array.push(returns, oneBarReturn)
if array.size(returns) > sampleCount
    array.shift(returns)

rollingImpulse = array.size(returns) == sampleCount ? array.avg(returns) : na
priceRank = ta.percentrank(close, rankLength)
rsiValue = ta.rsi(close, rsiLength)
atrValue = ta.atr(atrLength)

enterLong = ta.crossover(priceRank, entryRank) and rollingImpulse > 0 and rsiValue > 54
leaveLong = ta.crossunder(priceRank, exitRank) or rollingImpulse < 0 or rsiValue < 44

if enterLong
    strategy.entry("Atlas Long", strategy.long)
if strategy.position_size > 0 and leaveLong
    strategy.close("Atlas Long", comment="Momentum rank cooled")
if strategy.position_size > 0
    strategy.exit("Atlas Guard", from_entry="Atlas Long",
         stop=strategy.position_avg_price - atrValue * stopAtr)

plot(priceRank, "Price Percent Rank", color=color.blue)
plot(rollingImpulse, "Array Mean Return", color=color.orange)

Overview

PineForge Atlas Array Rotation also calculates RSI and ATR values. Long entries trigger when the price rank crosses above the entry rank threshold while the rolling return and RSI remain positive. Positions exit when the price rank drops below the exit rank or when the rolling return or RSI cross their respective thresholds. A trailing stop is placed using the ATR indicator. All plots appear in a separate pane below the price chart. Key inputs allow tuning of sample count, rank window length, RSI period, rank thresholds, ATR length, and stop distance.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge, as written in the script's header

Type

Strategy, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Trend, Mean reversion

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

Settings

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

SettingTypeDefaultVariable
Return Samplesint8sampleCount
Rank Windowint55rankLength
RSI Lengthint14rsiLength
Entry Rankfloat78.0entryRank
Exit Rankfloat46.0exitRank
ATR Lengthint17atrLength
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

106 stars

Buy The Dips - MA200 Optimised is a mean-reversion strategy that measures short-term percentage price changes alongside a simple moving average trend filter. It opens long positions when price experiences a steep drop exceeding three percent while remaining ab

Strategy v4 Oscillators & momentumTrend
Updated 2 years ago · GPL-3.0 GitHub repository of Buy The Dips - MA200 Optimised
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 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