Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Low-High-Trend Strategy

A Pine Script v5 strategy with no technical-analysis calculation. It has 5 order rules, 2 entries 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 1 commission. 8 settings; defaults include Lowest Price Lookback 20, Highest Price Lookback 10 and Take Profit % 8.

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 Low-High-Trend Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
How did Low-High-Trend Strategy do on BTCUSDT 1D with default settings?
+57.96%
From 26 Jan 2024 to 21 Oct 2026, over 5 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Low-High-Trend Strategy run in Pine Script v6?
Yes
Same 5 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does Low-High-Trend Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Low-High-Trend Strategy run in Zeal Terminal?
Yes
It compiles in 16 ms and runs 1,000 bars in 46 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 (8)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$162,681,000$202,527,287Equity from $100,000,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
+57.96%
$57,963,000.00
Buy and hold
+102.5%
same period
Closed trades
5
5 won · 0 lost
Profitable
100.0%
of closed trades
Profit factor
57,963,000.00
gross profit ÷ gross loss
Max drawdown
24.48%
−$26,471,500.00

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

    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

    Uses an argument v6 removed

    when = on line 24, 26, 28, 30. 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
Start Timetimestamp('01 Jan 2000 05:00 +0000')timeInDateRange
End Timetimestamp('01 Jan 2099 00:00 +0000')timeInDateRange
Lowest Price LookbackThe strategy will BUY when the price crosses over the lowest it has been in the last X amount of bars20intplot entry Long
Highest Price LookbackIf Take-Profit is not checked, the strategy will SELL when the price crosses under the highest it has been in the last X amount of bars10intplot close Long
Sell with Take-Profit % intead of highest price cross?trueboolclose Long close Long line 27 line 29
Take Profit %8float · step .25close Long
Only buy when price is above EMA trend?trueboolentry Long entry Long line 23 line 25
EMA Length200intTrendisLong plot

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.

timetimeprice dataStartTimeStart Timesetting · timestamp('01 Jan 2…EndTimeEnd Timesetting · timestamp('01 Jan 2…closecloseprice dataemaEMA Lengthsetting · 200lowcriteriaLowest Price Lookbacksetting · 20TakeProfitTake Profit %setting · 8highcriteriaHighest Price Lookbacksetting · 10InDateRangeInDateRangeconditionTrendisLongTrendisLongconditionentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeclose_all:close_all strategy.close_allplot:12plotplotplot:13plotplotplot:21plotplot

Order rules

OrderFires whenBy defaultLine
Open Long longta.crossover(close, lowcriteria) and TrendisLongOn24
Open Long longta.crossover(close, lowcriteria)On26
Close LongTakeProfitOn28
Close Longta.crossunder(close, highcriteria)On30
Close (not InDateRange)On32

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.

1/1trades 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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.

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+58.0%+102.5%5100%57,963,000.0024.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+20.5%+5.5%2100%20,482,700.004.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+20.3%+9.8%2100%20,322,900.0063.7%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+30.5%+8.4%3100%30,473,400.0013.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+39.3%+16.7%3100%39,278,100.0069.5%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+19.2%+21.5%2100%19,154,200.0016.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+21.3%+148.3%2100%21,255,800.0044.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+29.0%+17.1%3100%29,014,600.007.6%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 market4100%$49,840,200.00
Sideways market1100%$8,122,780.00
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 5 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 5 trades
SideEntryExitBarsP&L
long11 Oct 2024 62,540.0016 Oct 2024 67,620.005$8,122,780.00
long24 Dec 2024 98,663.6020 May 2025 106,850.00147$8,971,240.00
long6 Jun 2025 104,288.0010 Jul 2025 116,010.0034$13,160,800.00
long3 Aug 2025 114,209.005 Oct 2025 123,482.0063$10,576,400.00
long11 Sep 2026 77,225.7021 Sep 2026 86,620.0010$17,131,700.00

Similar scripts

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

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 24, 26, 28, 30). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 5 settings use the untyped input() (line 10, 11, 15, 18, 19). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

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

  • Line 10: input() → input.int()
  • Line 11: input() → input.int()
  • Line 15: input() → input.bool()
  • Line 18: input() → input.bool()
  • Line 19: input() → input.int()
  • Line 24: when = ta.crossover(close, lowcriteria) and TrendisLong → if block
3 more edits
  • Line 26: when = ta.crossover(close, lowcriteria) → if block
  • Line 28: when = TakeProfit → if block
  • Line 30: when = ta.crossunder(close, highcriteria) → if block
⋯// Strategy Calculations //-lowcriteria = ta.lowest(close, input(20, "Lowest Price Lookback", tooltip="The strategy will BUY when the price crosses over the lowest it has been in the last X amount of bars"))[1]+lowcriteria = ta.lowest(close, input.int(20, "Lowest Price Lookback", tooltip="The strategy will BUY when the price crosses over the lowest it has been in the last X amount of bars"))[1]-highcriteria = ta.highest(close, input(10, "Highest Price Lookback", tooltip="If Take-Profit is not checked, the strategy will SELL when the price crosses under the highest it has been in the last X amount of bars"))[1]+highcriteria = ta.highest(close, input.int(10, "Highest Price Lookback", tooltip="If Take-Profit is not checked, the strategy will SELL when the price crosses under the highest it has been in the last X amount of bars"))[1]plot(highcriteria, color=color.green)⋯// Take Profit //-TakeProfitInput = input(true, "Sell with Take-Profit % intead of highest price cross?")+TakeProfitInput = input.bool(true, "Sell with Take-Profit % intead of highest price cross?")TakeProfit = ta.crossover(close,strategy.position_avg_price*(1+(.01*input.float(8, title="Take Profit %", step=.25))))// Operational Functions //-TrendFilterInput = input(true, "Only buy when price is above EMA trend?")+TrendFilterInput = input.bool(true, "Only buy when price is above EMA trend?")-ema = ta.ema(close, input(200, "EMA Length"))+ema = ta.ema(close, input.int(200, "EMA Length"))TrendisLong = (close>ema)⋯if (InDateRange and TrendFilterInput==true)-    strategy.entry("Long", strategy.long, when = ta.crossover(close, lowcriteria) and TrendisLong)+    if ta.crossover(close, lowcriteria) and TrendisLong+        strategy.entry("Long", strategy.long)if (InDateRange and TrendFilterInput==false)-    strategy.entry("Long", strategy.long, when = ta.crossover(close, lowcriteria))+    if ta.crossover(close, lowcriteria)+        strategy.entry("Long", strategy.long)if (InDateRange and TakeProfitInput==true)-    strategy.close("Long", when = TakeProfit)+    if TakeProfit+        strategy.close("Long")if (InDateRange and TakeProfitInput==false)-    strategy.close("Long", when = ta.crossunder(close, highcriteria))+    if ta.crossunder(close, highcriteria)+        strategy.close("Long")if (not InDateRange)⋯

Does it run in Pine Script v6?

Yes

Same 5 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/-// @version=5+// @version=6// Author = TradeAutomation⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 16 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/// @version=5// Author = TradeAutomationstrategy(title="Low-High-Trend Strategy", shorttitle="Low-High-Trend Strategy", process_orders_on_close=true, overlay=true, commission_type=strategy.commission.cash_per_order, commission_value=1, slippage=1, initial_capital = 100000000, margin_long=50, margin_short=50, default_qty_type=strategy.percent_of_equity, default_qty_value=100)// Backtest Date Range Inputs // StartTime = input.time(defval=timestamp('01 Jan 2000 05:00 +0000'), title='Start Time')EndTime = input.time(defval=timestamp('01 Jan 2099 00:00 +0000'), title='End Time')InDateRange = time>=StartTime and time<=EndTime// Strategy Calculations //lowcriteria = ta.lowest(close, input(20, "Lowest Price Lookback", tooltip="The strategy will BUY when the price crosses over the lowest it has been in the last X amount of bars"))[1]highcriteria = ta.highest(close, input(10, "Highest Price Lookback", tooltip="If Take-Profit is not checked, the strategy will SELL when the price crosses under the highest it has been in the last X amount of bars"))[1]plot(highcriteria, color=color.green)plot(lowcriteria, color=color.red)// Take Profit //TakeProfitInput = input(true, "Sell with Take-Profit % intead of highest price cross?")TakeProfit = ta.crossover(close,strategy.position_avg_price*(1+(.01*input.float(8, title="Take Profit %", step=.25))))// Operational Functions //TrendFilterInput = input(true, "Only buy when price is above EMA trend?")ema = ta.ema(close, input(200, "EMA Length"))TrendisLong = (close>ema)plot(ema)// Entry & Exit Functions//if (InDateRange and TrendFilterInput==true)    strategy.entry("Long", strategy.long, when = ta.crossover(close, lowcriteria) and TrendisLong)if (InDateRange and TrendFilterInput==false)    strategy.entry("Long", strategy.long, when = ta.crossover(close, lowcriteria))if (InDateRange and TakeProfitInput==true)    strategy.close("Long", when = TakeProfit)if (InDateRange and TakeProfitInput==false)    strategy.close("Long", when = ta.crossunder(close, highcriteria))if (not InDateRange)    strategy.close_all()