Strategy · Pine Script v6 · On the chart

PF probe kanuck-probe-03-max-bars-back-500

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

This strategy is a validation probe that forces a 500-bar history buffer.

View on GitHub

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

67 lines of Pine Script v6 from validation/composite-kanuck-max-bars-back-500-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 probe kanuck-probe-03-max-bars-back-500 — deep-history reference chain
// Clean-room: written from validation goal, not from source.
//
// Purpose: isolates `max_bars_back=500`. The engine surface under test is
// the runtime's deep-history buffer: a chain that combines `ta.sma(close,
// 400)`, `ta.rsi(close[200], 14)`, and a raw `close[450]` reference forces
// the runtime to retain at least 500 bars of every series touched. Verifies
// that the engine handles the deep buffer without truncation artefacts and
// matches TradingView's broker emulator on the bars where these terms first
// become non-na.
//
// Validation goal: bit-exact entries on `close > close[450]` (long) and
// `close < close[450]` (short) — a state-flipping condition off the
// deep-history buffer that fires many times across the 36k-bar window.
// `ta.sma(close, 400)` and `ta.rsi(close[200], 14)` are computed on
// every bar (and would also be plotted in TV) so the engine still has
// to retain the 500-bar buffer for those terms — they are the deep-
// history terms under test even though they no longer gate entries.
// (The earlier triple-AND form is statistically far too rare on 15m
// crypto to produce a meaningful trade-list parity check.)
// Pass = identical trade list vs TradingView.
//
// TV setup: 15m chart, ETH-USDT-USDT (Binance USDT-M Perpetual). Full window
// matching corpus/data/ohlcv_ETH-USDT-USDT_15m.csv. Strategy properties:
// leave defaults from script header. Export "List of trades" → tv_trades.csv.
//@version=6
strategy("PF probe kanuck-probe-03-max-bars-back-500", shorttitle="PF_kan03_MBB",
     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,
     max_bars_back=500)

// ---- inputs --------------------------------------------------------
int i_sma_len    = input.int(400, "Long SMA length",         minval=50)
int i_rsi_offset = input.int(200, "RSI source offset",       minval=1)
int i_deep_lag   = input.int(450, "Close-reference lookback", minval=1)

// ---- deep-history terms -------------------------------------------
// All three are computed every bar and force the runtime to retain
// the 500-bar buffer. `long_sma` and `deep_rsi` are the corroborating
// deep-buffer terms; `deep_close` is the entry trigger.
float long_sma   = ta.sma(close, i_sma_len)
float deep_rsi   = ta.rsi(close[i_rsi_offset], 14)
float deep_close = close[i_deep_lag]

// Plot the corroborating deep-history terms so the engine has to keep
// them resolved even though they no longer gate entries.
plot(long_sma, "deep SMA", color=color.new(color.blue,   0))
plot(deep_rsi, "deep RSI", color=color.new(color.purple, 0), display=display.data_window)

// ---- composite condition ------------------------------------------
bool deep_ready = not na(long_sma) and not na(deep_rsi) and not na(deep_close)

bool long_trigger  = deep_ready and close > deep_close
bool short_trigger = deep_ready and close < deep_close

// ---- order routing -------------------------------------------------
if long_trigger and strategy.position_size <= 0
    strategy.entry("L", strategy.long, qty=1, comment="deep-history long")

if short_trigger and strategy.position_size >= 0
    strategy.entry("S", strategy.short, qty=1, comment="deep-history short")

Overview

PF probe kanuck-probe-03-max-bars-back-500 calculates a long simple moving average of close, an RSI of close shifted by a configurable offset, and a lagged close. Those first two series are plotted but do not gate trades. It enters long when close is above the lagged close and short when close is below it, reversing only from a flat or opposite position. Quantity is fixed at one. There is no stop loss or take profit. The moving average plots on the price chart and the RSI appears in the data window.

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

Moving averages, Oscillators & momentum

Markets

Crypto

Timeframes

M15-H1

Risk Notes

  • The strategy enters trades without a stop loss

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
Long SMA lengthint400i_sma_len
RSI source offsetint200i_rsi_offset
Close-reference lookbackint450i_deep_lag
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

2 EMA/SMA + RSI Strategy [Alorse] combines three configurable moving averages with a short-period Relative Strength Index filter. It plots fast, slow, and trend moving averages on the price chart. Long entries trigger when the fast moving average is above the

Strategy v4 TrendOscillators & momentum
Updated 2 months ago · None stated GitHub repository of 2 EMA/SMA + RSI Strategy [Alorse]

Acrypto - Weighted Strategy

by AlbertoCuadra
318 stars

This strategy plots on the price chart and opens long or short positions when a weighted score from MACD, Stochastic RSI, RSI, Supertrend and a moving-average crossover exceeds a user-set trigger. Each component has its own weight and candle delay. Entries can

Strategy v5 TrendOscillators & momentum
Updated 3 years ago · Custom licence GitHub repository of Acrypto - Weighted Strategy

This strategy combines Arnaud Legoux Moving Average percentage price change calculations with an adaptive Gaussian Moving Average to generate trend-following signals. Long and short entries are triggered when the ALMA change calculation crosses above or below

Strategy v5 Moving averagesOscillators & momentum
Updated 6 weeks ago · None stated GitHub repository of ESM2024 - ALMA Smoothed Gaussian Moving Average

MACD Strategy

by TradersPost
218 stars

This overlay strategy is built around MACD inputs for a fast average, a slow average, and a signal line. Comments say the script keeps MACD values available and can draw a histogram and zero line in a separate pane, with an optional overlay on price. Settings

Strategy v6 Oscillators & momentumMoving averages
Updated 3 months ago · None stated GitHub repository of MACD Strategy

255 EMA Strategy

by hasnocool
106 stars

255 EMA Strategy combines an exponential moving average with Average True Range bands and standard MACD crossovers to generate entry signals. Drawn directly on the price chart, it plots the central 255 EMA along with upper and lower volatility envelopes. Trade

Strategy v4 Moving averagesOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 255 EMA Strategy
104 stars

This overlay strategy combines a machine-learning distance model with a MACD oscillator to open trades on the price chart. It compares recent history using cosine similarity or Euclidean and Lorentzian distance, then filters direction with selectable moving-av

Strategy v5 AI / machine learningOscillators & momentum
Updated 3 years ago · MIT GitHub repository of MLCEL and MACD Strategy

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