Zeal Terminal Open in Zeal Terminal

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
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (2)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$105,986$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots.
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

Differs

Trades 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

Verified

Same 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.

SettingDefaultType and rangeFeeds
Length (no label in the script)20int · min 1lower upper
Exit Option1int · min 1 · max 2line 17 line 20

What it calculates

  • Lowest (lowest, ta.lowest in v5)Length (20)lower · line 7
  • Highest (highest, ta.highest in v5)Length (20)upper · line 8
  • Crossover (crossover, ta.crossover in 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.

lengthLengthsetting · 20closecloseprice datalowerLowest→ lowerupperHighest→ upperlongConditionCrossover→ longConditionbasisbasisvalueentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeplot:10plotplotplot:11plotplotplot:12plotplotfill:13Fillfill

Order rules

OrderFires whenBy defaultLine
Open Long long(longCondition)On16
Close Long(crossunder(close,lower[1]))On19
Close Long(crossunder(close,basis[1]))On22

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.

3/3trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+8.4%+102.5%1346%1.1239.6%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+10.6%+5.5%933%1.636.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+11.1%+9.8%944%1.1243.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+10.1%+8.4%1040%1.4211.5%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−32.1%+16.7%1136%0.7553.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+33.0%+21.5%933%2.6416.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+25.0%+148.3%1030%1.3131.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−5.4%+17.1%1331%0.7621.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 barsTradesWonP&L
Rising market367%$9,293.07
Sideways market838%$573.75
Falling market250%−$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.

0%51%
All 13 trades
SideEntryExitBarsP&L
long27 Feb 2024 54,476.502 May 2024 58,365.0065$7,137.93
long16 May 2024 66,206.5015 Jun 2024 66,044.0030−$263.00
long16 Jul 2024 64,724.105 Aug 2024 58,161.0020−$10,837.20
long24 Aug 2024 64,037.207 Sep 2024 53,963.0014−$15,108.60
long19 Sep 2024 61,760.0025 Feb 2025 91,552.90159$39,040.10
long23 Apr 2025 93,443.006 Jun 2025 101,509.0044$10,355.40
long10 Jul 2025 111,234.002 Aug 2025 113,298.0023$2,418.14
long14 Aug 2025 123,306.0026 Aug 2025 110,112.0012−$14,204.20
long17 Sep 2025 116,789.0026 Sep 2025 108,994.009−$7,911.24
long2 Oct 2025 118,595.005 Nov 2025 101,497.0034−$15,949.10
long5 Jan 2026 91,529.7026 Jan 2026 86,670.4021−$5,026.54
long5 Mar 2026 72,666.8023 May 2026 75,539.5079$3,544.20
long15 Jul 2026 65,044.0016 Sep 2026 75,644.5063$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.

ScriptSharesTypeNetTradesMax drawdown
eswaran ab this page—v4 strategy+8.4%1339.6%
Alex Days HiLo Rajib by 14rajibhighest lowestv4 strategyNo trades on this market
Donchian Strat EXMO by pskoroplashighest lowestv4 strategy+12.1%2268.0%
Average Highest High and Lowest Low Swinger Strategy by exlux99lowest highestv4 strategy+6.4%2049.6%
Highest High and Lowest Low Channel Strategy by ceyhunhighest lowestv5 strategy−3.7%267.9%
Donchian Channels System [racer8] by racer8highest lowestv4 strategy−3.2%3643.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 9 msYes 1,000 bars in 20 msNot measured
PineTSNo 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")