Pine Script v4 · Strategy
New Highs-Lows Strategy
A Pine Script v4 strategy built on EMA (net, 10). It has 2 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. It has no settings.
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 New Highs-Lows Strategy repaint?
- Yes
- At least one pattern in the source can repaint: intrabar recalculation.
- How did New Highs-Lows Strategy do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its entry conditions never all held on this data. It closed no trades on the other markets either. A backtest, not investment advice.
- Can New Highs-Lows Strategy be converted to Pine Script v5?
- Not tested
- The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
- Does New Highs-Lows Strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does New Highs-Lows Strategy run in Zeal Terminal?
- Yes
- It compiles in 7 ms and runs 1,000 bars in 15 ms, in the browser.
BTCUSDT · 1D · default settings
- EMA
- EMA
- Winning trade
- Losing trade
- Equity
- Buy and hold
Needs HIGQ D data, not available: not a Binance spot market Needs LOWQ D data, not available: not a Binance spot market Values that depend on it are empty on this chart.
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.00
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. 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
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 security → request.security, sum → math.sum, ema → ta.ema.
v4 → v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 3: //@version=4 → //@version=5
- Line 5: security → request.security
- Line 6: security → request.security
- Line 8: sum → math.sum
- Line 9: ema → ta.ema
- Line 10: ema → ta.ema
⋯// © pieroliviermarquis-//@version=4+//@version=5strategy(title = "New Highs-Lows", shorttitle="New Highs-Lows Strategy", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100, calc_on_every_tick=true)-newhigh = security("HIGQ", timeframe.period, close)+newhigh = request.security("HIGQ", timeframe.period, close)-newlow = security("LOWQ", timeframe.period, close)+newlow = request.security("LOWQ", timeframe.period, close)net = newhigh - newlow-sum_ = sum(net, 20)+sum_ = math.sum(net, 20)-avg_fast = ema(net, 10)+avg_fast = ta.ema(net, 10)-avg_slow = ema(net, 20)+avg_slow = ta.ema(net, 20)buy = avg_fast > avg_slow and net > 0⋯Clean v5
VerifiedNothing to change.
Does it run in Pine Script v6?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © pieroliviermarquis-//@version=5+//@version=6strategy(title = "New Highs-Lows", shorttitle="New Highs-Lows Strategy", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100, calc_on_every_tick=true)⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
The script declares no settings.
What it calculates
- EMA (
ema,ta.emain v5)net, 10avg_fast · line 9 - EMA (
ema,ta.emain v5)net, 20avg_slow · line 10
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 | buy | On | 15 |
| Close Long | sell | On | 17 |
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.
- ClearHigher-timeframe data2 security call(s), none with lookahead on.
- 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
Not run on other markets: the script requests HIGQ D, LOWQ D, and that data is not available here (not a Binance spot market; not a Binance spot market). Its results would rest on empty values.
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 |
|---|---|---|---|---|---|
| New Highs-Lows Strategy this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| EMA Slope AyE by fajardoarelys | ema | v4 strategy | No trades on this market | ||
| ROoT by realisticDove62527 | ema | v5 strategy | −4.7% | 225 | 9.4% |
| sachin5986 by mohitesachin78 | ema | v4 strategy | +32.1% | 35 | 17.6% |
| sonu1997 by Sonu1997 | ema | v4 strategy | +960.7% | 2 | 1,103.8% |
| Moving Average Crossover by Muh4mm4d | ema | v4 strategy | +19,990.1% | 30 | 1,274.2% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 7 ms | With a workaround 1,000 bars in 15 ms | Not measured |
| PineTS | No 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/// © pieroliviermarquis//@version=4strategy(title = "New Highs-Lows", shorttitle="New Highs-Lows Strategy", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100, calc_on_every_tick=true)newhigh = security("HIGQ", timeframe.period, close)newlow = security("LOWQ", timeframe.period, close)net = newhigh - newlowsum_ = sum(net, 20)avg_fast = ema(net, 10)avg_slow = ema(net, 20)buy = avg_fast > avg_slow and net > 0sell = avg_fast < avg_slow and net < 0plot(net, title="Net NASDAQ", color=net > 0? color.green: color.red, style=plot.style_columns, linewidth=2)if buy strategy.entry("Long", strategy.long, comment="")if sell strategy.close("Long", comment="", alert_message="")