Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Daily HIGH-LOW strategy

A Pine Script v5 strategy built on EMA (close, 24). It has 4 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 0.1% commission. 3 settings; defaults include Length MA 24, Source MA close and CMF Length 20.

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 Daily HIGH-LOW strategy repaint?
Yes
At least one pattern in the source can repaint: higher-timeframe data, intrabar recalculation.
How did Daily HIGH-LOW strategy do on BTCUSDT 1D with default settings?
+53.90%
From 26 Jan 2024 to 21 Oct 2026, over 25 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Daily HIGH-LOW strategy 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: 25 before, 62 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 Daily HIGH-LOW strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Daily HIGH-LOW strategy run in Zeal Terminal?
Yes
It compiles in 14 ms and runs 1,000 bars in 46 ms, in the browser.

BTCUSDT · 1D · default settings

  • Previous Daily High
  • Previous Daily Low
  • 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 (3)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$14,853$20,253Equity from $10,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
+53.90%
$5,389.76
Buy and hold
+102.5%
same period
Closed trades
25
9 won · 16 lost
Profitable
36.0%
of closed trades
Profit factor
1.30
gross profit ÷ gross loss
Max drawdown
35.95%
−$7,924.68

One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A short 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

    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.

  • Note

    Uses an argument v6 removed

    when = on line 21, 22, 24, 25. The upgraded version below moves each call inside an if block.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Optimization paramters
Length MA24int · min 1out
Source MAclosesourceout
CMF Length20int · min 1mf

What it calculates

  • EMASource MA (close), Length MA (24)out · line 8

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.

closecloseprice datalenLength MAsetting · 24volumevolumeprice datalowlowprice datahighhighprice datalengthCMF Lengthsetting · 20outEMA→ outadadvaluemfmfvaluepricehighpricehighvaluepricelowpricelowvalueshortshortconditionlonglongconditionentry:shortOpen shortstrategy.entryclose:shortClose shortstrategy.closeentry:longOpen longstrategy.entryclose:longClose longstrategy.closeplot:16Previous Daily Highplotplot:17Previous Daily Lowplot

Order rules

OrderFires whenBy defaultLine
Open short shortbarstate.isconfirmedOn21
Close shortclose > outOn22
Open long longbarstate.isconfirmedOn24
Close longclose < outOn25

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

Not measuredAn engine gap, not the scriptThe script acts only when barstate.isconfirmed is true, which Zeal Terminal's engine never reports during a live replay (it does not run a bar's closing update in live mode), so the replay cannot test this script. The answer comes from the checks on the source alone.
  • CheckHigher-timeframe data1 request.security call(s) use lookahead_on (line 13). Without a [1] offset this reads future bars in history.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationcalc_on_every_tick = true. Live values can differ from history.
  • 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+53.9%+102.5%2536%1.3035.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+38.9%+5.5%1850%2.598.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+11.4%+9.8%3333%1.0464.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−4.5%+8.4%2928%0.9532.4%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+511.7%+16.7%2952%3.4742.3%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+18.6%+21.5%2143%1.3125.3%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+34.8%+148.3%3132%1.1846.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+22.7%+17.1%2544%1.7315.2%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 market2100%$4,115.40
Sideways market1346%$10,086.30
Falling market1010%−$8,796.49

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

55.2%

The 95th percentile of the worst drawdown when the same 25 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 29.1% to 55.2%; the tick is what actually happened, 32.3%. Order luck alone moves it this much.

0%63%
All 25 trades
SideEntryExitBarsP&L
long20 Feb 2024 52,572.1012 Jun 2024 67,314.20113$2,778.60
short12 Jun 2024 67,314.2020 Jul 2024 66,660.0038$98.76
long20 Jul 2024 66,660.0012 Aug 2024 58,712.6023−$1,559.47
short12 Aug 2024 58,712.6024 Aug 2024 64,037.2012−$1,050.08
long24 Aug 2024 64,037.201 Sep 2024 57,860.008−$1,010.21
short1 Sep 2024 57,860.0018 Sep 2024 60,395.8017−$433.94
long18 Sep 2024 60,395.807 Feb 2025 96,150.00142$5,209.21
short7 Feb 2025 96,150.0020 Mar 2025 86,845.9041$1,336.81
long20 Mar 2025 86,845.903 Apr 2025 81,278.5014−$1,014.88
short3 Apr 2025 81,278.5012 Apr 2025 83,588.009−$443.66
long12 Apr 2025 83,588.0019 Aug 2025 116,227.00129$5,410.52
short19 Aug 2025 116,227.0016 Sep 2025 116,299.0028−$50.58
long16 Sep 2025 116,299.0030 Oct 2025 107,403.0044−$1,523.57
short30 Oct 2025 107,403.0012 Jan 2026 92,082.6074$2,502.45
long12 Jan 2026 92,082.6026 Jan 2026 86,670.4014−$1,239.94
short26 Jan 2026 86,670.405 Mar 2026 72,666.8038$3,036.59
long5 Mar 2026 72,666.8022 Mar 2026 68,793.4017−$1,217.75
short22 Mar 2026 68,793.4017 Apr 2026 76,038.0026−$2,241.41
long17 Apr 2026 76,038.0023 May 2026 75,539.5036−$161.24
short23 May 2026 75,539.5011 Jul 2026 64,161.7049$2,741.33
long11 Jul 2026 64,161.7028 Jul 2026 63,755.9017−$176.05
short28 Jul 2026 63,755.908 Aug 2026 65,025.2011−$460.34
long8 Aug 2026 65,025.2014 Aug 2026 63,238.006−$605.81
short14 Aug 2026 63,238.0025 Aug 2026 78,992.8011−$5,029.00
long25 Aug 2026 78,992.8013 Oct 2026 81,850.0049$508.83

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
Daily HIGH-LOW strategy this page—v5 strategy+53.9%2535.9%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

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.

  • 4 strategy calls use the when = argument (line 21, 22, 24, 25). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

Same 25 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 21: when = barstate.isconfirmed → if block
  • Line 22: when = close > out → if block
  • Line 24: when = barstate.isconfirmed → if block
  • Line 25: when = close < out → if block
⋯if short and barstate.isconfirmed-    strategy.entry('short', strategy.short, when=barstate.isconfirmed, stop=pricelow[1])+    if barstate.isconfirmed+        strategy.entry('short', strategy.short, stop=pricelow[1])-    strategy.close('short', when=close > out)+    if close > out+        strategy.close('short')if long and barstate.isconfirmed-    strategy.entry('long', strategy.long, when=barstate.isconfirmed, stop=pricehigh[1])+    if barstate.isconfirmed+        strategy.entry('long', strategy.long, stop=pricehigh[1])-    strategy.close('long', when=close < out)+    if close < out+        strategy.close('long')

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: 25 before, 62 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.

⋯// © exlux99-//@version=5+//@version=6strategy(title='Daily HIGH/LOW strategy', overlay=true, initial_capital=10000, calc_on_every_tick=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 14 msYes 1,000 bars in 46 msNot measured
PineTSNot testedNot testedNot 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/// © exlux99//@version=5strategy(title='Daily HIGH/LOW strategy', overlay=true, initial_capital=10000, calc_on_every_tick=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1)////////////////////////////GENERAL INPUTS//////////////////////////////////////len = input.int(24, minval=1, title='Length MA', group='Optimization paramters')src = input.source(close, title='Source MA', group='Optimization paramters')out = ta.ema(src, len)length = input.int(20, minval=1, title='CMF Length', group='Optimization paramters')ad = close == high and close == low or high == low ? 0 : (2 * close - low - high) / (high - low) * volumemf = math.sum(ad, length) / math.sum(volume, length)f_secureSecurity(_symbol, _res, _src) =>    request.security(_symbol, _res, _src[1], lookahead=barmerge.lookahead_on)pricehigh = f_secureSecurity(syminfo.tickerid, 'D', high)pricelow = f_secureSecurity(syminfo.tickerid, 'D', low)plot(pricehigh, title='Previous Daily High', style=plot.style_linebr, linewidth=2, color=color.new(color.white, 0))plot(pricelow, title='Previous Daily Low', style=plot.style_linebr, linewidth=2, color=color.new(color.white, 0))short = ta.crossunder(low, pricelow) and close < out and mf < 0long = ta.crossover(high, pricehigh) and close > out and mf > 0if short and barstate.isconfirmed    strategy.entry('short', strategy.short, when=barstate.isconfirmed, stop=pricelow[1])    strategy.close('short', when=close > out)if long and barstate.isconfirmed    strategy.entry('long', strategy.long, when=barstate.isconfirmed, stop=pricehigh[1])    strategy.close('long', when=close < out)