Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

HTF High-Low Repaint Strategy

A Pine Script v4 strategy with no technical-analysis calculation. 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 0.01% commission. 6 settings; defaults include Resolution 3M, HTFMultiplier 22 and Offset 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 HTF High-Low Repaint Strategy repaint?
Yes
At least one pattern in the source can repaint: higher-timeframe data.
How did HTF High-Low Repaint Strategy do on BTCUSDT 1D with default settings?
+126.90%
From 26 Jan 2024 to 21 Oct 2026, over 3 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can HTF High-Low Repaint Strategy be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does HTF High-Low Repaint Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does HTF High-Low Repaint Strategy run in Zeal Terminal?
Yes
It compiles in 13 ms and runs 1,000 bars in 106 ms, in the browser.

BTCUSDT · 1D · default settings

  • HTF High
  • HTF Low
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$47,490$40,505Equity from $20,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. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market. The live re-run is not offered here: the script requests BINANCE:BTCUSDT 3M, which this page cannot load in your browser.
Net profit
+126.90%
$25,380.00
Buy and hold
+102.5%
same period
Closed trades
3
3 won · 0 lost
Profitable
100.0%
of closed trades
Profit factor
5,593.21
gross profit ÷ gross loss
Max drawdown
11.42%
−$4,645.95

One run with the author's default settings, $20,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

    4 settings have no label

    In the settings dialog resolution (line 8), HTFMultiplier (line 9), offset (line 10), lookahead (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.

  • Note

    Uses an argument v6 removed

    when = on line 60, 61. The upgraded version below moves each call inside an if block.

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 security → request.security, tostring → str.tostring, round → math.round, min → math.min.
  • 2 strategy calls use the when = argument (line 60, 61). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 5: input(type = input.time) → input.time()
  • Line 6: input(type = input.time) → input.time()
  • Line 8: input(type = input.resolution) → input.timeframe()
  • Line 13: security → request.security
  • Line 14: security → request.security
7 more edits
  • Line 15: security → request.security
  • Line 16: security → request.security
  • Line 28: tostring → str.tostring
  • Line 28: round → math.round
  • Line 29: tostring → str.tostring
  • Line 29: round → math.round
  • Line 29: min → math.min
⋯// © HeWhoMustNotBeNamed-//@version=4+//@version=5strategy("HTF High/Low Repaint Strategy", overlay=true, initial_capital = 20000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_type = strategy.commission.percent, pyramiding = 1, commission_value = 0.01)-i_startTime = input(defval = timestamp("01 Jan 2010 00:00 +0000"), title = "Start Time", type = input.time)+i_startTime = input.time(defval = timestamp("01 Jan 2010 00:00 +0000"), title = "Start Time")-i_endTime = input(defval = timestamp("01 Jan 2099 00:00 +0000"), title = "End Time", type = input.time)+i_endTime = input.time(defval = timestamp("01 Jan 2099 00:00 +0000"), title = "End Time")inDateRange = time >= i_startTime and time <= i_endTime-resolution = input("3M", type=input.resolution)+resolution = input.timeframe("3M")HTFMultiplier = input(22, minval=1, step=1)⋯gaps = false-f_secureSecurity_on_on(_symbol, _res, _src, _offset) => security(_symbol, _res, _src[_offset], lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_on)+f_secureSecurity_on_on(_symbol, _res, _src, _offset) => request.security(_symbol, _res, _src[_offset], lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_on)-f_secureSecurity_on_off(_symbol, _res, _src, _offset) => security(_symbol, _res, _src[_offset], lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_off)+f_secureSecurity_on_off(_symbol, _res, _src, _offset) => request.security(_symbol, _res, _src[_offset], lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_off)-f_secureSecurity_off_on(_symbol, _res, _src, _offset) => security(_symbol, _res, _src[_offset], lookahead = barmerge.lookahead_off, gaps=barmerge.gaps_on)+f_secureSecurity_off_on(_symbol, _res, _src, _offset) => request.security(_symbol, _res, _src[_offset], lookahead = barmerge.lookahead_off, gaps=barmerge.gaps_on)-f_secureSecurity_off_off(_symbol, _res, _src, _offset) => security(_symbol, _res, _src[_offset], lookahead = barmerge.lookahead_off, gaps=barmerge.gaps_off)+f_secureSecurity_off_off(_symbol, _res, _src, _offset) => request.security(_symbol, _res, _src[_offset], lookahead = barmerge.lookahead_off, gaps=barmerge.gaps_off)f_multiple_resolution(HTFMultiplier) => ⋯      target_Res_In_Min   <= 0.751        ? "30S" :-      target_Res_In_Min   <= 1440         ? tostring(round(target_Res_In_Min)) :+      target_Res_In_Min   <= 1440         ? str.tostring(math.round(target_Res_In_Min)) :-      tostring(round(min(target_Res_In_Min / 1440, 365))) + "D"+      str.tostring(math.round(math.min(target_Res_In_Min / 1440, 365))) + "D"f_get_htfHighLow(resolution, HTFMultiplier, lookahead, gaps, offset)=>⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 9: input() → input.int()
  • Line 10: input() → input.int()
  • Line 11: input() → input.bool()
  • Line 60: when = buyCondition and inDateRange → if block
  • Line 61: when = sellCondition and inDateRange → if block
⋯resolution = input.timeframe("3M")-HTFMultiplier = input(22, minval=1, step=1)+HTFMultiplier = input.int(22, minval=1, step=1)-offset = input(0, minval=0, step=1)+offset = input.int(0, minval=0, step=1)-lookahead = input(true)+lookahead = input.bool(true)gaps = false⋯sellCondition = nhigh < nhighlast and nlow < nlowlast-strategy.entry("Buy", strategy.long, when= buyCondition and inDateRange, oca_name="oca_buy", oca_type=strategy.oca.cancel)+if buyCondition and inDateRange+    strategy.entry("Buy", strategy.long, oca_name="oca_buy", oca_type=strategy.oca.cancel)-strategy.entry("Sell", strategy.short, when= sellCondition and inDateRange, oca_name="oca_sell", oca_type=strategy.oca.cancel)+if sellCondition and inDateRange+    strategy.entry("Sell", strategy.short, oca_name="oca_sell", oca_type=strategy.oca.cancel)

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: 3 before, 105 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.

⋯// © HeWhoMustNotBeNamed-//@version=5+//@version=6strategy("HTF High/Low Repaint Strategy", overlay=true, initial_capital = 20000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_type = strategy.commission.percent, pyramiding = 1, commission_value = 0.01)⋯

Settings

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

SettingDefaultType and rangeFeeds
Start Timetimestamp("01 Jan 2010 00:00 +0000")timeinDateRange
End Timetimestamp("01 Jan 2099 00:00 +0000")timeinDateRange
Resolution (no label in the script)3Mtimeframe (written input.resolution)derivedResolution nhigh nlow nhighlast nlowlast
HTFMultiplier (no label in the script)22int · min 1 · step 1target_Res_In_Min derivedResolution nhigh nlow nhighlast nlowlast
Offset (no label in the script)0int · min 0 · step 1nhigh_on_on nlow_on_on nhigh_on_off nlow_on_off nhigh_off_on nlow_off_on nhigh_off_off nlow_off_off nhigh nlow nhighlast nlowlast
Lookahead (no label in the script)trueboolnhigh nlow nhighlast nlowlast

What it calculates

No technical-analysis calculation: the script works on prices and settings directly.

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.

HTFMultiplierHTFMultipliersetting · 22resolutionResolutionsetting · 3Mhighhighprice dataoffsetOffsetsetting · 0lowlowprice datatimetimeprice datai_startTimeStart Timesetting · timestamp("01 Jan 2…i_endTimeEnd Timesetting · timestamp("01 Jan 2…target_Res_In_Mintarget_Res_In_MinvaluederivedResolutionderivedResolutionvaluenhigh_on_on, nhigh_on_off, nhigh_off_on, nhigh_off_offnhigh_on_on · nhigh_on_…4 valuesnlow_on_on, nlow_on_off, nlow_off_on, nlow_off_offnlow_on_on · nlow_on_of…4 valuesnhigh, nlow, nhighlast, nlowlastnhigh · nlow +24 valuesinDateRangeinDateRangeconditionbuyCondition, sellConditionbuyCondition · sellCond…2 conditionsentry:BuyOpen Buystrategy.entryentry:SellOpen Sellstrategy.entryplot:56HTF Highplotplot:57HTF Lowplot

Order rules

OrderFires whenBy defaultLine
Open Buy longbuyCondition and inDateRangeOn60
Open Sell shortsellCondition and inDateRangeOn61

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 measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • CheckHigher-timeframe data2 security call(s) use lookahead_on (line 13, 14). Without a [1] offset this reads future bars in history.
  • 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+126.9%+102.5%3100%5,593.2111.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.0%+5.5%00%0.008.9%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+530.3%+9.8%6100%8,413.9713.3%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+30.5%+8.4%1100%2,337.333.8%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+193.9%+16.7%667%5.5354.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+14.8%+21.5%1100%1,291.2511.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+317.4%+148.3%6100%7,604.3411.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−20.1%+17.1%10%0.0026.7%8 May 2026 – 21 Oct 2026

Higher-timeframe data for request.security(): BINANCE:BTCUSDT 3M (aggregated from Binance BTCUSDT 1M), fetched from Binance's public market data for each market.

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market0—$0.00
Sideways market3100%$25,384.50
Falling market0—$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 3 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.

0%1%
All 3 trades
SideEntryExitBarsP&L
long27 Jan 2024 41,823.502 Jul 2024 62,900.00157$10,072.80
short2 Jul 2024 62,900.002 Oct 2024 60,804.9092$995.75
long2 Oct 2024 60,804.902 Jan 2026 88,839.10457$14,316.00

Similar scripts

No other indicator or strategy here shares enough of its calculations.

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 13 msWith a workaround 1,000 bars in 106 msNot measured
PineTSNo v5 and v6 only—Not measured

The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

“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/// © HeWhoMustNotBeNamed//@version=4strategy("HTF High/Low Repaint Strategy", overlay=true, initial_capital = 20000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_type = strategy.commission.percent, pyramiding = 1, commission_value = 0.01)i_startTime = input(defval = timestamp("01 Jan 2010 00:00 +0000"), title = "Start Time", type = input.time)i_endTime = input(defval = timestamp("01 Jan 2099 00:00 +0000"), title = "End Time", type = input.time)inDateRange = time >= i_startTime and time <= i_endTimeresolution = input("3M", type=input.resolution)HTFMultiplier = input(22, minval=1, step=1)offset = input(0, minval=0, step=1)lookahead = input(true)gaps = falsef_secureSecurity_on_on(_symbol, _res, _src, _offset) => security(_symbol, _res, _src[_offset], lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_on)f_secureSecurity_on_off(_symbol, _res, _src, _offset) => security(_symbol, _res, _src[_offset], lookahead = barmerge.lookahead_on, gaps=barmerge.gaps_off)f_secureSecurity_off_on(_symbol, _res, _src, _offset) => security(_symbol, _res, _src[_offset], lookahead = barmerge.lookahead_off, gaps=barmerge.gaps_on)f_secureSecurity_off_off(_symbol, _res, _src, _offset) => security(_symbol, _res, _src[_offset], lookahead = barmerge.lookahead_off, gaps=barmerge.gaps_off)f_multiple_resolution(HTFMultiplier) =>     target_Res_In_Min = timeframe.multiplier * HTFMultiplier * (      timeframe.isseconds   ? 1. / 60. :      timeframe.isminutes   ? 1. :      timeframe.isdaily     ? 1440. :      timeframe.isweekly    ? 7. * 24. * 60. :      timeframe.ismonthly   ? 30.417 * 24. * 60. : na)    target_Res_In_Min     <= 0.0417       ? "1S"  :      target_Res_In_Min   <= 0.167        ? "5S"  :      target_Res_In_Min   <= 0.376        ? "15S" :      target_Res_In_Min   <= 0.751        ? "30S" :      target_Res_In_Min   <= 1440         ? tostring(round(target_Res_In_Min)) :      tostring(round(min(target_Res_In_Min / 1440, 365))) + "D"f_get_htfHighLow(resolution, HTFMultiplier, lookahead, gaps, offset)=>    derivedResolution = resolution == ""?f_multiple_resolution(HTFMultiplier):resolution    nhigh_on_on = f_secureSecurity_on_on(syminfo.tickerid, derivedResolution, high, offset)     nlow_on_on = f_secureSecurity_on_on(syminfo.tickerid, derivedResolution, low, offset)        nhigh_on_off = f_secureSecurity_on_off(syminfo.tickerid, derivedResolution, high, offset)     nlow_on_off = f_secureSecurity_on_off(syminfo.tickerid, derivedResolution, low, offset)        nhigh_off_on = f_secureSecurity_off_on(syminfo.tickerid, derivedResolution, high, offset)     nlow_off_on = f_secureSecurity_off_on(syminfo.tickerid, derivedResolution, low, offset)        nhigh_off_off = f_secureSecurity_off_off(syminfo.tickerid, derivedResolution, high, offset)     nlow_off_off = f_secureSecurity_off_off(syminfo.tickerid, derivedResolution, low, offset)        nhigh = lookahead and gaps ? nhigh_on_on :             lookahead and not gaps ? nhigh_on_off :             not lookahead and gaps ? nhigh_off_on :             not lookahead and not gaps ? nhigh_off_off : na    nlow = lookahead and gaps ? nlow_on_on :             lookahead and not gaps ? nlow_on_off :             not lookahead and gaps ? nlow_off_on :             not lookahead and not gaps ? nlow_off_off : na    [nhigh, nlow]    [nhigh, nlow] = f_get_htfHighLow(resolution, HTFMultiplier, lookahead, gaps, offset)[nhighlast, nlowlast] = f_get_htfHighLow(resolution, HTFMultiplier, lookahead, gaps, offset+1)plot(nhigh , title="HTF High",style=plot.style_circles, color=color.green, linewidth=1) plot(nlow , title="HTF Low",style=plot.style_circles, color=color.red, linewidth=1)buyCondition = nhigh > nhighlast and nlow > nlowlastsellCondition = nhigh < nhighlast and nlow < nlowlaststrategy.entry("Buy", strategy.long, when= buyCondition and inDateRange, oca_name="oca_buy", oca_type=strategy.oca.cancel)strategy.entry("Sell", strategy.short, when= sellCondition and inDateRange, oca_name="oca_sell", oca_type=strategy.oca.cancel)