Pine Script v5 · Strategy
I11L - Better Buy Low Volatility or High Volatility-
A Pine Script v5 strategy built on ATR (14) and SMA (atr, atrLength*5). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits use a profit target and no stop loss. Each trade commits 1000000 in cash and pays no commission. 4 settings; defaults include Volatility Target Ratio 1, ATR Length 14 and Sell After NBars Length 5.
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 I11L - Better Buy Low Volatility or High Volatility- repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 28 of 28 trades.
- How did I11L - Better Buy Low Volatility or High Volatility- do on BTCUSDT 1D with default settings?
- +19.25%
- From 26 Jan 2024 to 21 Oct 2026, over 83 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does I11L - Better Buy Low Volatility or High Volatility- run in Pine Script v6?
- No
- The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 83 before, 2 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does I11L - Better Buy Low Volatility or High Volatility- use a stop loss?
- No
- Its exits set a profit target but no stop.
- Does I11L - Better Buy Low Volatility or High Volatility- run in Zeal Terminal?
- Yes
- It compiles in 17 ms and runs 1,000 bars in 34 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +19.25%
- $192,487.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 83
- 43 won · 40 lost
- Profitable
- 51.8%
- of closed trades
- Profit factor
- 1.11
- gross profit ÷ gross loss
- Max drawdown
- 37.43%
- −$414,811.00
One run with the author's default settings, $1,000,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
strategy.exit is used without a stop, loss or trailing stop.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
4 settings have no label
In the settings dialog mode (line 5), volatilityTargetRatio (line 6), atrLength (line 7), sellAfterNBarsLength (line 11) show an empty name. The labels on this page come from the variable names.
-
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 |
|---|---|---|---|
| Mode (no label in the script) | Buy low Volatility | string · options ["Buy low Volatility","Buy high Volatility"] | line 16 |
| Volatility Target Ratio (no label in the script)1 equals the average atr for the security, a lower value means that the volatility is lower | 1 | float · min 0 · max 100 · step 0.1 | isBuy |
| ATR Length (no label in the script) | 14 | int | atr avg_atr |
| Sell After NBars Length (no label in the script) | 5 | int · min 0 · step 5 | isClose |
What it calculates
- ATRATR Length (14)
atr · line 8 - SMAatr, atrLength*5
avg_atr · line 9
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 Buy long | (isBuy) | On | 22 |
| Exit Close limit | (isClose) | On | 25 |
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, and the live replay matched history.
- 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 timingOrders fill at the next bar's open, after the signal bar has closed.
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 | +19.2% | +102.5% | 83 | 52% | 1.11 | 37.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +12.4% | +5.5% | 91 | 52% | 1.22 | 16.8% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +83.8% | +9.8% | 84 | 52% | 1.39 | 41.8% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +1.3% | +8.4% | 90 | 48% | 1.02 | 23.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +65.7% | +16.7% | 81 | 48% | 1.23 | 30.8% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +15.9% | +21.5% | 88 | 50% | 1.18 | 12.5% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +6.1% | +148.3% | 79 | 51% | 1.04 | 52.8% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +7.0% | +17.1% | 91 | 46% | 1.12 | 16.4% | 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 | 27 | 48% | $270,400.00 |
| Sideways market | 39 | 54% | −$397,671.00 |
| Falling market | 17 | 53% | $319,758.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
52.1%
The 95th percentile of the worst drawdown when the same 83 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 27.4% to 52.1%; the tick is what actually happened, 33.9%. Order luck alone moves it this much.
All 83 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 29 Apr 2024 63,118.60 | 5 May 2024 63,892.00 | 6 | $12,253.40 |
| long | 6 May 2024 64,012.00 | 12 May 2024 60,826.00 | 6 | −$49,772.10 |
| long | 13 May 2024 61,484.00 | 19 May 2024 66,915.20 | 6 | $88,335.20 |
| long | 20 May 2024 66,274.00 | 26 May 2024 69,290.60 | 6 | $45,516.60 |
| long | 27 May 2024 68,507.70 | 2 Jun 2024 67,766.90 | 6 | −$10,813.70 |
| long | 3 Jun 2024 67,765.60 | 9 Jun 2024 69,310.50 | 6 | $22,796.80 |
| long | 10 Jun 2024 69,648.10 | 16 Jun 2024 66,228.30 | 6 | −$49,102.50 |
| long | 17 Jun 2024 66,676.90 | 23 Jun 2024 64,262.00 | 6 | −$36,217.20 |
| long | 24 Jun 2024 63,210.00 | 30 Jun 2024 60,986.70 | 6 | −$35,173.70 |
| long | 1 Jul 2024 62,772.00 | 7 Jul 2024 58,230.10 | 6 | −$72,355.20 |
| long | 29 Jul 2024 68,249.90 | 4 Aug 2024 60,698.00 | 6 | −$110,651.00 |
| long | 3 Sep 2024 59,132.10 | 9 Sep 2024 54,869.90 | 6 | −$72,078.70 |
| long | 11 Sep 2024 57,636.00 | 17 Sep 2024 58,214.00 | 6 | $10,028.50 |
| long | 18 Sep 2024 60,314.00 | 24 Sep 2024 63,340.00 | 6 | $50,170.80 |
| long | 25 Sep 2024 64,262.70 | 1 Oct 2024 63,327.60 | 6 | −$14,551.20 |
| long | 2 Oct 2024 60,804.90 | 8 Oct 2024 62,224.00 | 6 | $23,338.10 |
| long | 9 Oct 2024 62,160.50 | 15 Oct 2024 66,084.00 | 6 | $63,118.90 |
| long | 16 Oct 2024 67,074.10 | 22 Oct 2024 67,377.50 | 6 | $4,522.76 |
| long | 23 Oct 2024 67,426.00 | 29 Oct 2024 69,962.20 | 6 | $37,614.60 |
| long | 30 Oct 2024 72,736.40 | 5 Nov 2024 67,850.00 | 6 | −$67,179.60 |
| long | 6 Nov 2024 69,372.00 | 12 Nov 2024 88,648.00 | 6 | $277,864.00 |
| long | 5 Jan 2025 98,220.50 | 11 Jan 2025 94,726.10 | 6 | −$35,577.10 |
| long | 12 Jan 2025 94,600.00 | 18 Jan 2025 104,077.00 | 6 | $100,185.00 |
| long | 19 Jan 2025 104,556.00 | 25 Jan 2025 104,871.00 | 6 | $3,005.85 |
| long | 31 Jan 2025 104,723.00 | 6 Feb 2025 96,612.40 | 6 | −$77,447.20 |
| long | 13 Feb 2025 97,870.00 | 19 Feb 2025 95,671.70 | 6 | −$22,461.00 |
| long | 20 Feb 2025 96,644.40 | 26 Feb 2025 88,680.40 | 6 | −$82,404.90 |
| long | 24 Mar 2025 86,082.50 | 30 Mar 2025 82,648.50 | 6 | −$39,891.50 |
| long | 31 Mar 2025 82,390.00 | 6 Apr 2025 83,538.00 | 6 | $13,933.60 |
| long | 17 Apr 2025 84,030.40 | 23 Apr 2025 93,443.00 | 6 | $112,014.00 |
| long | 24 Apr 2025 93,691.10 | 30 Apr 2025 94,256.80 | 6 | $6,038.46 |
| long | 1 May 2025 94,172.00 | 7 May 2025 96,834.00 | 6 | $28,267.60 |
| long | 8 May 2025 97,030.50 | 14 May 2025 104,104.00 | 6 | $72,896.90 |
| long | 15 May 2025 103,508.00 | 21 May 2025 106,850.00 | 6 | $32,289.10 |
| long | 22 May 2025 109,644.00 | 28 May 2025 108,938.00 | 6 | −$6,437.38 |
| long | 29 May 2025 107,782.00 | 4 Jun 2025 105,377.00 | 6 | −$22,312.50 |
| long | 5 Jun 2025 104,697.00 | 11 Jun 2025 110,274.00 | 6 | $53,273.10 |
| long | 12 Jun 2025 108,645.00 | 18 Jun 2025 104,551.00 | 6 | −$37,682.00 |
| long | 19 Jun 2025 104,887.00 | 25 Jun 2025 106,083.00 | 6 | $11,404.80 |
| long | 26 Jun 2025 107,341.00 | 2 Jul 2025 105,681.00 | 6 | −$15,459.70 |
| long | 3 Jul 2025 108,850.00 | 9 Jul 2025 108,923.00 | 6 | $674.33 |
| long | 10 Jul 2025 111,234.00 | 16 Jul 2025 117,758.00 | 6 | $58,651.90 |
| long | 17 Jul 2025 118,630.00 | 23 Jul 2025 119,954.00 | 6 | $11,160.60 |
| long | 24 Jul 2025 118,756.00 | 30 Jul 2025 117,951.00 | 6 | −$6,780.63 |
| long | 31 Jul 2025 117,840.00 | 6 Aug 2025 114,130.00 | 6 | −$31,487.90 |
| long | 7 Aug 2025 114,992.00 | 13 Aug 2025 120,134.00 | 6 | $44,714.50 |
| long | 14 Aug 2025 123,306.00 | 20 Aug 2025 112,873.00 | 6 | −$84,614.30 |
| long | 21 Aug 2025 114,271.00 | 27 Aug 2025 111,763.00 | 6 | −$21,947.90 |
| long | 8 Sep 2025 111,137.00 | 14 Sep 2025 115,918.00 | 6 | $43,018.30 |
| long | 15 Sep 2025 115,268.00 | 21 Sep 2025 115,686.00 | 6 | $3,623.03 |
| long | 22 Sep 2025 115,232.00 | 28 Sep 2025 109,636.00 | 6 | −$48,566.60 |
| long | 29 Sep 2025 112,164.00 | 5 Oct 2025 122,391.00 | 6 | $91,179.40 |
| long | 6 Oct 2025 123,482.00 | 12 Oct 2025 110,644.00 | 6 | −$103,966.00 |
| long | 14 Dec 2025 90,240.00 | 20 Dec 2025 88,136.90 | 6 | −$23,305.10 |
| long | 21 Dec 2025 88,360.90 | 27 Dec 2025 87,369.60 | 6 | −$11,219.30 |
| long | 28 Dec 2025 87,877.00 | 3 Jan 2026 89,995.10 | 6 | $24,103.50 |
| long | 4 Jan 2026 90,628.00 | 10 Jan 2026 90,641.30 | 6 | $146.42 |
| long | 11 Jan 2026 90,504.70 | 17 Jan 2026 95,550.90 | 6 | $55,756.70 |
| long | 18 Jan 2026 95,147.80 | 24 Jan 2026 89,600.30 | 6 | −$58,304.20 |
| long | 25 Jan 2026 89,225.30 | 31 Jan 2026 84,260.50 | 6 | −$55,643.80 |
| long | 16 Mar 2026 72,815.30 | 22 Mar 2026 68,918.10 | 6 | −$53,520.80 |
| long | 23 Mar 2026 67,859.00 | 29 Mar 2026 66,377.00 | 6 | −$21,838.80 |
| long | 30 Mar 2026 66,010.90 | 5 Apr 2026 67,300.40 | 6 | $19,534.50 |
| long | 6 Apr 2026 69,034.20 | 12 Apr 2026 73,043.20 | 6 | $58,072.40 |
| long | 13 Apr 2026 70,741.60 | 19 Apr 2026 75,691.80 | 6 | $69,976.40 |
| long | 20 Apr 2026 73,801.80 | 26 Apr 2026 77,625.00 | 6 | $51,803.60 |
| long | 27 Apr 2026 78,657.60 | 3 May 2026 78,686.90 | 6 | $372.50 |
| long | 4 May 2026 78,568.60 | 10 May 2026 80,678.40 | 6 | $26,853.40 |
| long | 11 May 2026 82,210.10 | 17 May 2026 78,148.10 | 6 | −$49,410.20 |
| long | 18 May 2026 77,457.70 | 24 May 2026 76,752.00 | 6 | −$9,110.27 |
| long | 25 May 2026 77,065.00 | 31 May 2026 73,884.40 | 6 | −$41,271.40 |
| long | 1 Jun 2026 73,674.40 | 7 Jun 2026 60,884.60 | 6 | −$173,599.00 |
| long | 12 Jul 2026 63,819.00 | 18 Jul 2026 63,931.70 | 6 | $1,765.31 |
| long | 19 Jul 2026 64,834.20 | 25 Jul 2026 64,140.00 | 6 | −$10,707.50 |
| long | 26 Jul 2026 64,375.00 | 1 Aug 2026 62,887.90 | 6 | −$23,101.00 |
| long | 2 Aug 2026 62,823.70 | 8 Aug 2026 64,923.20 | 6 | $33,419.70 |
| long | 9 Aug 2026 64,962.60 | 15 Aug 2026 63,043.60 | 6 | −$29,540.70 |
| long | 16 Aug 2026 63,086.00 | 22 Aug 2026 78,338.00 | 6 | $241,765.00 |
| long | 23 Aug 2026 77,074.90 | 29 Aug 2026 77,845.90 | 6 | $10,002.50 |
| long | 14 Sep 2026 76,842.00 | 20 Sep 2026 81,250.00 | 6 | $57,364.20 |
| long | 28 Sep 2026 84,472.00 | 4 Oct 2026 84,753.60 | 6 | $3,333.18 |
| long | 5 Oct 2026 86,530.00 | 11 Oct 2026 82,988.40 | 6 | −$40,929.60 |
| long | 12 Oct 2026 83,773.10 | 18 Oct 2026 81,491.00 | 6 | −$27,241.20 |
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 |
|---|---|---|---|---|---|
| I11L - Better Buy Low Volatility or High Volatility- this page | — | v5 strategy | +19.2% | 83 | 37.4% |
| Vortex Cross w-MA Confirmation by DraftVenture | atr sma | v5 strategy | +2.4% | 52 | 4.7% |
| Configurable Multi MA Crossover Voting System by levieux | sma atr | v5 strategy | +28.5% | 5 | 39.4% |
| Swing Trend Strategy by Inkedlau | sma atr | v5 strategy | +11.2% | 5 | 16.2% |
| SSL Backtester With ATR SL TP and Money Management by JBTrippin | sma atr | v4 strategy | +8.5% | 55 | 3.9% |
| Baseline Cross Qualifier Volatility Strategy with HMA Trend Bias by sevencampbell | sma atr | v5 strategy | −1.4% | 214 | 1.8% |
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?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 83 before, 2 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © I11L-//@version=5+//@version=6strategy("I11L - Better Buy Low Volatility or High Volatility?", overlay=false, pyramiding=1, default_qty_value=1000000, initial_capital=1000000, default_qty_type=strategy.cash,process_orders_on_close=false, calc_on_every_tick=false)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 17 ms | Yes 1,000 bars in 34 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/// © I11L//@version=5strategy("I11L - Better Buy Low Volatility or High Volatility?", overlay=false, pyramiding=1, default_qty_value=1000000, initial_capital=1000000, default_qty_type=strategy.cash,process_orders_on_close=false, calc_on_every_tick=false)mode = input.string("Buy low Volatility",options = ["Buy low Volatility","Buy high Volatility"])volatilityTargetRatio = input.float(1,minval = 0, maxval = 100,step=0.1, tooltip="1 equals the average atr for the security, a lower value means that the volatility is lower")atrLength = input.int(14)atr = ta.atr(atrLength) / closeavg_atr = ta.sma(atr,atrLength*5)ratio = atr / avg_atrsellAfterNBarsLength = input.int(5, step=5, minval=0)var holdingBarsCounter = 0if(strategy.opentrades > 0) holdingBarsCounter := holdingBarsCounter + 1isBuy = falseif(mode == "Buy low Volatility") isBuy := ratio < volatilityTargetRatioelse isBuy := ratio > volatilityTargetRatioisClose = holdingBarsCounter > sellAfterNBarsLengthif(isBuy) strategy.entry("Buy",strategy.long)if(isClose) holdingBarsCounter := 0 strategy.exit("Close",limit=close)plot(ratio, color=isBuy[1] ? color.green : isClose[1] ? color.red : color.white)plot(1, color=color.white)