Pine Script v4 · Strategy
eswaran ab
A Pine Script v4 strategy built on Lowest (20), Highest (20) and Crossover (close, upper[1]). It has 3 order rules, 1 entry among them, and trades long only 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 Length 20 and Exit Option 1.
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 eswaran ab repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 3 of 3 trades.
- How did eswaran ab do on BTCUSDT 1D with default settings?
- +8.38%
- From 26 Jan 2024 to 21 Oct 2026, over 13 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can eswaran ab be converted to Pine Script v5?
- No
- The automatic step from v4 to v5 changes the results, so no v5 download is offered; the edits are shown below.
- Does eswaran ab use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does eswaran ab run in Zeal Terminal?
- Yes
- It compiles in 9 ms and runs 1,000 bars in 20 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +8.38%
- $8,384.47
- Buy and hold
- +102.5%
- same period
- Closed trades
- 13
- 6 won · 7 lost
- Profitable
- 46.2%
- of closed trades
- Profit factor
- 1.12
- gross profit ÷ gross loss
- Max drawdown
- 39.59%
- −$52,549.80
One run with the author's default settings, $100,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
1 setting has no label
In the settings dialog length (line 5) shows 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.
Upgrade and export
Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.
- Upgrading to v5 renames lowest → ta.lowest, highest → ta.highest, avg → math.avg, crossover → ta.crossover, crossunder → ta.crossunder.
v4 → v5
DiffersTrades differ: 13 before, 13 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 7: lowest → ta.lowest
- Line 8: highest → ta.highest
- Line 9: avg → math.avg
- Line 14: crossover → ta.crossover
- Line 18: crossunder → ta.crossunder
- Line 21: crossunder → ta.crossunder
⋯//Break out trading system works best in a weekly chart and daily chart of Nifty and BankNifty-//@version=4+//@version=5strategy("Eswar New",shorttitle = "ESW",default_qty_type = strategy.percent_of_equity,default_qty_value = 100, overlay=true)⋯exit = input(1, minval=1, maxval=2,title = "Exit Option") // Use Option 1 to exit using lower band; Use Option 2 to exit using basis line-lower = lowest(length)+lower = ta.lowest(length)-upper = highest(length)+upper = ta.highest(length)-basis = avg(upper, lower)+basis = math.avg(upper, lower)l = plot(lower, color=color.blue)⋯fill(u, l, color=color.blue)-longCondition = crossover(close,upper[1])+longCondition = ta.crossover(close,upper[1])if (longCondition)⋯if(exit==1)- if (crossunder(close,lower[1]))+ if (ta.crossunder(close,lower[1])) strategy.close("Long")if(exit==2) - if (crossunder(close,basis[1]))+ if (ta.crossunder(close,basis[1])) strategy.close("Long")Clean v5
VerifiedSame 13 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 5: input() → input.int()
- Line 6: input() → input.int()
⋯strategy("Eswar New",shorttitle = "ESW",default_qty_type = strategy.percent_of_equity,default_qty_value = 100, overlay=true)-length = input(20, minval=1)+length = input.int(20, minval=1)-exit = input(1, minval=1, maxval=2,title = "Exit Option") // Use Option 1 to exit using lower band; Use Option 2 to exit using basis line+exit = input.int(1, minval=1, maxval=2,title = "Exit Option") // Use Option 1 to exit using lower band; Use Option 2 to exit using basis linelower = ta.lowest(length)⋯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: 13 before, 11 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.
⋯//Break out trading system works best in a weekly chart and daily chart of Nifty and BankNifty-//@version=5+//@version=6strategy("Eswar New",shorttitle = "ESW",default_qty_type = strategy.percent_of_equity,default_qty_value = 100, overlay=true)⋯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 |
|---|---|---|---|
| Length (no label in the script) | 20 | int · min 1 | lower upper |
| Exit Option | 1 | int · min 1 · max 2 | line 17 line 20 |
What it calculates
- Lowest (
lowest,ta.lowestin v5)Length (20)lower · line 7 - Highest (
highest,ta.highestin v5)Length (20)upper · line 8 - Crossover (
crossover,ta.crossoverin v5)close, upper[1]longCondition · line 14
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 Long long | (longCondition) | On | 16 |
| Close Long | (crossunder(close,lower[1])) | On | 19 |
| Close Long | (crossunder(close,basis[1])) | On | 22 |
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 | +8.4% | +102.5% | 13 | 46% | 1.12 | 39.6% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +10.6% | +5.5% | 9 | 33% | 1.63 | 6.6% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +11.1% | +9.8% | 9 | 44% | 1.12 | 43.8% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +10.1% | +8.4% | 10 | 40% | 1.42 | 11.5% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −32.1% | +16.7% | 11 | 36% | 0.75 | 53.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +33.0% | +21.5% | 9 | 33% | 2.64 | 16.2% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +25.0% | +148.3% | 10 | 30% | 1.31 | 31.5% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −5.4% | +17.1% | 13 | 31% | 0.76 | 21.0% | 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 | 3 | 67% | $9,293.07 |
| Sideways market | 8 | 38% | $573.75 |
| Falling market | 2 | 50% | −$1,482.34 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
44.6%
The 95th percentile of the worst drawdown when the same 13 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 22.6% to 44.6%; the tick is what actually happened, 32.5%. Order luck alone moves it this much.
All 13 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 27 Feb 2024 54,476.50 | 2 May 2024 58,365.00 | 65 | $7,137.93 |
| long | 16 May 2024 66,206.50 | 15 Jun 2024 66,044.00 | 30 | −$263.00 |
| long | 16 Jul 2024 64,724.10 | 5 Aug 2024 58,161.00 | 20 | −$10,837.20 |
| long | 24 Aug 2024 64,037.20 | 7 Sep 2024 53,963.00 | 14 | −$15,108.60 |
| long | 19 Sep 2024 61,760.00 | 25 Feb 2025 91,552.90 | 159 | $39,040.10 |
| long | 23 Apr 2025 93,443.00 | 6 Jun 2025 101,509.00 | 44 | $10,355.40 |
| long | 10 Jul 2025 111,234.00 | 2 Aug 2025 113,298.00 | 23 | $2,418.14 |
| long | 14 Aug 2025 123,306.00 | 26 Aug 2025 110,112.00 | 12 | −$14,204.20 |
| long | 17 Sep 2025 116,789.00 | 26 Sep 2025 108,994.00 | 9 | −$7,911.24 |
| long | 2 Oct 2025 118,595.00 | 5 Nov 2025 101,497.00 | 34 | −$15,949.10 |
| long | 5 Jan 2026 91,529.70 | 26 Jan 2026 86,670.40 | 21 | −$5,026.54 |
| long | 5 Mar 2026 72,666.80 | 23 May 2026 75,539.50 | 79 | $3,544.20 |
| long | 15 Jul 2026 65,044.00 | 16 Sep 2026 75,644.50 | 63 | $15,188.50 |
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 |
|---|---|---|---|---|---|
| eswaran ab this page | — | v4 strategy | +8.4% | 13 | 39.6% |
| Alex Days HiLo Rajib by 14rajib | highest lowest | v4 strategy | No trades on this market | ||
| Donchian Strat EXMO by pskoroplas | highest lowest | v4 strategy | +12.1% | 22 | 68.0% |
| Average Highest High and Lowest Low Swinger Strategy by exlux99 | lowest highest | v4 strategy | +6.4% | 20 | 49.6% |
| Highest High and Lowest Low Channel Strategy by ceyhun | highest lowest | v5 strategy | −3.7% | 26 | 7.9% |
| Donchian Channels System [racer8] by racer8 | highest lowest | v4 strategy | −3.2% | 36 | 43.6% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 9 ms | Yes 1,000 bars in 20 ms | Not measured |
| PineTS | No v5 and v6 only | — | 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. PineTS runs Pine Script v5 and v6 only.
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//Break out trading system works best in a weekly chart and daily chart of Nifty and BankNifty//@version=4strategy("Eswar New",shorttitle = "ESW",default_qty_type = strategy.percent_of_equity,default_qty_value = 100, overlay=true)length = input(20, minval=1)exit = input(1, minval=1, maxval=2,title = "Exit Option") // Use Option 1 to exit using lower band; Use Option 2 to exit using basis linelower = lowest(length)upper = highest(length)basis = avg(upper, lower)l = plot(lower, color=color.blue)u = plot(upper, color=color.blue)plot(basis, color=color.orange)fill(u, l, color=color.blue)longCondition = crossover(close,upper[1])if (longCondition) strategy.entry("Long", strategy.long)if(exit==1) if (crossunder(close,lower[1])) strategy.close("Long")if(exit==2) if (crossunder(close,basis[1])) strategy.close("Long")