Pine Script v5 · Strategy
Volatility System
A Pine Script v5 strategy built on ATR (14) and Change (close, 1). It has 2 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays no commission. 2 settings; defaults include Average length 14 and Multiplier 2.0.
Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.
- Does Volatility System repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Volatility System do on BTCUSDT 1D with default settings?
- +150.22%
- From 26 Jan 2024 to 21 Oct 2026, over 2 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Volatility System run in Pine Script v6?
- Yes
- Same 2 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
- Does Volatility System use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Volatility System run in Zeal Terminal?
- Yes
- It compiles in 11 ms and runs 1,000 bars in 30 ms, in the browser.
BTCUSDT · 1D · default settings
- ATR
- Absolute close change
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +150.22%
- $30,042.90
- Buy and hold
- +102.5%
- same period
- Closed trades
- 2
- 2 won · 0 lost
- Profitable
- 100.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 21.51%
- −$4,302.95
One run with the author's default settings, $20,000 starting capital, commission as the script sets it. A long position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Average length | 14 | int | atr |
| Multiplier | 2.0 | float · step 0.1 | atr |
What it calculates
- ATRAverage length (14)
atr · line 10 - Changeclose, 1
closingChange · line 11
Signal flow
How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open strategy.direction.long long | (longCondition) | On | 18 |
| Open strategy.direction.short short | (shortCondition) | On | 20 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
No
No repainting patterns in the source.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- ClearOrder timingprocess_orders_on_close = true: orders fill at the signal bar's close.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +150.2% | +102.5% | 2 | 100% | — | 21.5% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −12.3% | +5.5% | 10 | 40% | 0.64 | 27.5% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −23.2% | +9.8% | 6 | 50% | 0.68 | 65.7% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +23.9% | +8.4% | 10 | 50% | 1.67 | 24.2% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +13.9% | +16.7% | 4 | 50% | 1.39 | 50.8% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +72.6% | +21.5% | 4 | 75% | 13.48 | 12.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +67.1% | +148.3% | 4 | 75% | 2.08 | 61.2% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −20.0% | +17.1% | 10 | 30% | 0.39 | 29.6% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 1 | 100% | $16,127.10 |
| Sideways market | 1 | 100% | $13,915.80 |
| Falling market | 0 | — | $0.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
0.0%
The 95th percentile of the worst drawdown when the same 2 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 0.0% to 0.0%; the tick is what actually happened, 0.0%. Order luck alone moves it this much.
All 2 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 28 Feb 2024 62,432.10 | 10 Oct 2025 112,775.00 | 590 | $16,127.10 |
| short | 10 Oct 2025 112,775.00 | 19 Aug 2026 69,334.80 | 313 | $13,915.80 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Volatility System this page | — | v5 strategy | +150.2% | 2 | 21.5% |
| SOJA PIVOT by ParaBellum68 | atr | v4 strategy | +3.3% | 9 | 18.2% |
| ATR Stop Buy Strategy by phobo3s | atr | v4 strategy | No trades on this market | ||
| VBand Strategy by Saravanan_Ragavan | atr | v4 strategy | No trades on this market | ||
| Volatility Breakout Strategy [Angel Algo] by AngelAlgo | atr | v5 strategy | +3.1% | 18 | 3.6% |
| ATR Mean Reversion Strategy V1 by Bcullen175 | atr | v5 strategy | −20.0% | 79 | 59.6% |
Upgrade and export
Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.
- No v6-only features. v6 is not needed to run this script.
Clean v5
VerifiedNothing to change.
Does it run in Pine Script v6?
Yes
Same 2 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.
⋯// © EduardoMattje-//@version=5+//@version=6strategy("Volatility System", overlay=false, margin_long=0, margin_short=0, default_qty_type=strategy.percent_of_equity, ⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 11 ms | Yes 1,000 bars in 30 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © EduardoMattje//@version=5strategy("Volatility System", overlay=false, margin_long=0, margin_short=0, default_qty_type=strategy.percent_of_equity, default_qty_value=100, process_orders_on_close=true, initial_capital=20000)// Inputsvar averageLength = input.int(14, "Average length", 2)var multiplier = input.float(2.0, "Multiplier", 0.0, step=0.1)// Calculationsatr = ta.atr(averageLength) * multiplierclosingChange = ta.change(close, 1)atrPenetration(int signal) => res = closingChange * signal > atr[1]longCondition = atrPenetration(1)shortCondition = atrPenetration(-1)// Order callsif (longCondition) strategy.entry(strategy.direction.long, strategy.long)if (shortCondition) strategy.entry(strategy.direction.short, strategy.short)// Visualsplot(atr, "ATR", color.white, 2)plot(math.abs(closingChange), "Absolute close change", color.red)