This statistical arbitrage strategy uses matrix algebra to calculate dynamic Ordinary Least Squares regression parameters between the chart symbol and a secondary asset.
1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
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.
Matrix OLS regression for dynamic alpha and beta estimation
Z-Score statistical arbitrage entry and exit signals
Preset arbitrage modes for scalp, standard, and tight thresholds
Secondary symbol pair integration via security calls
On-screen dashboard displaying current beta and alpha values
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
套利規訓等級
enum
ArbitrageMode.Standard
mode
對沖資產 (Asset 2)
symbol
BINANCE:ETHUSDT
pairSym
OLS 矩陣回顧長度
int
60
lookback
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.
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
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
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
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
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
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