Strategy · Pine Script v6 · Own pane

TN Matrix OLS Stat Arb Sovereign v6

by raybird

This statistical arbitrage strategy uses matrix algebra to calculate dynamic Ordinary Least Squares regression parameters between the chart symbol and a secondary asset.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code86
Settings3inputs
LicenceNone stated
Last update2 months ago15 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
  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

The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.

Overview

TN Matrix OLS Stat Arb Sovereign v6 constructs a synthetic spread and calculates its Z-score. The strategy enters a long position when the Z-score falls below a negative threshold and enters a short position when it rises above a positive threshold. Trades exit when the Z-score reverts back to zero. Key inputs select the secondary asset, OLS lookback length, and sensitivity mode. The script plots the Z-score in a separate pane and does not employ a stop loss.

Details

Published by

raybird on GitHub

Type

Strategy, Pine Script v6

Draws

Separate pane below the chart

Category

Mean reversion, Screeners & dashboards

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Settings

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

SettingTypeDefaultVariable
套利規訓等級enumArbitrageMode.Standardmode
對沖資產 (Asset 2)symbolBINANCE:ETHUSDTpairSym
OLS 矩陣回顧長度int60lookback
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 strategy calculates intraday volatility mean reversion using session VWAP standard deviation bands, RSI overbought and oversold levels, and candle wick exhaustion ratios. It enters trades when price reaches statistical extremes filtered by RSI and wick co

Strategy v6 Mean reversionVolatility & bands
Updated 7 months ago · MIT GitHub repository of Intraday Volatility Reversion Z-Score
106 stars

Automatic Grid Bot Strategy simulates a grid trading system directly on the main price chart. It sets upper and lower price range boundaries and splits the defined range into grid levels to trade long, short, or both directions simultaneously. Users can config

Strategy v5 Support & resistanceMean reversion
Updated 2 years ago · GPL-3.0 GitHub repository of Automatic Grid Bot Strategy
7 stars

This strategy plots RSI on the price chart and enters a long when RSI falls below the oversold level or a short when it rises above the overbought level, only while flat. It exits with a take profit and stop loss measured in pips from the current close. Inputs

Strategy v6 Oscillators & momentumScalping
Updated 3 months ago · None stated GitHub repository of XAUUSD 1-Minute Scalping Strategy

升级版的马丁 -- DCA

by wynnforthework
2 stars

This Dollar-Cost Averaging (DCA) strategy enters trades using signal triggers from MACD, MFI, RSI, or Stochastic RSI. When price moves against the position, it executes Martingale safety orders using customizable volume multipliers and step percentages. Exits

Strategy v5 Oscillators & momentumMean reversion Repaints
Updated 1 year ago · None stated GitHub repository of 升级版的马丁 -- DCA

Grid Bot [psyll]

by cullyk
2 stars

Grid Bot places a configurable number of long and short orders between a user-set grid top and bottom and draws those levels on the price chart. Direction can be longs, shorts, or both, with default or burst entry and an optional instant first fill. Exits use

Strategy v5 Mean reversionSupport & resistance
Updated 8 months ago · MIT GitHub repository of Grid Bot [psyll]
2 stars

This strategy fades liquidity sweeps of confirmed swing highs and lows. It enters a reversal only after price sweeps a prior swing and closes back inside the range. The stop sits an ATR multiple beyond the sweep wick, the target is a fixed reward-to-risk multi

Strategy v6 SMC / ICT / price actionMean reversion
Updated 2 months ago · Custom licence GitHub repository of Liquidity Sweep Reversal [Vantrade]

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