Pine Script v4 · Strategy
MARKET DYNAMICS HH LL BREAKOUT
A Pine Script v4 strategy built on Highest (26) and Lowest (26). It has 6 order rules, 4 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 13 settings; defaults include Strategy Direction all, Backtest Start Year 2016 and Backtest Start Month 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 MARKET DYNAMICS HH LL BREAKOUT repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did MARKET DYNAMICS HH LL BREAKOUT 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 code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
- Can MARKET DYNAMICS HH LL BREAKOUT 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 MARKET DYNAMICS HH LL BREAKOUT use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does MARKET DYNAMICS HH LL BREAKOUT run in Zeal Terminal?
- Yes
- It compiles in 18 ms and runs 1,000 bars in 41 ms, in the browser.
BTCUSDT · 1D · default settings
- Highest
- Lowest
- Highest
- Lowest
- Winning trade
- Losing trade
- Equity
- Buy and hold
- 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, $300,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.
-
Note
4 settings have no label
In the settings dialog price (line 23), LookBack (line 24), length (line 33), length2 (line 36) 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 42, 43, 45, 46, 48, 51. 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 highest → ta.highest, lowest → ta.lowest.
- 6 strategy calls use the when = argument (line 42, 43, 45, 46, 48, 51). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
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 18: input(type = input.float) → input.float()
- Line 19: input(type = input.float) → input.float()
- Line 25: highest → ta.highest
- Line 26: lowest → ta.lowest
- Line 34: highest → ta.highest
- Line 35: lowest → ta.lowest
⋯// © sincereLizard-//@version=4+//@version=5strategy(title="MD BANKNIFTY STRATEGY ", overlay=true,initial_capital=300000, default_qty_value=1)⋯testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)-sl_inp = (input(2.0, title='Stop Loss %', type=input.float))/100+sl_inp = (input.float(2.0, title='Stop Loss %'))/100-tp_inp = (input(7.0, title='Take Profit %', type=input.float))/100+tp_inp = (input.float(7.0, title='Take Profit %'))/100testPeriod() =>⋯LookBack = input(26)-Highest = highest(LookBack)+Highest = ta.highest(LookBack)-Lowest = lowest(LookBack)+Lowest = ta.lowest(LookBack)long = price > Highest[1] ⋯length = input(10)-High_Guard = highest(length)+High_Guard = ta.highest(length)-Low_Guard = lowest(length)+Low_Guard = ta.lowest(length)length2 = input(1)⋯Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 5: input() → input.string()
- Line 9: input() → input.int()
- Line 10: input() → input.int()
- Line 11: input() → input.int()
- Line 14: input() → input.int()
- Line 15: input() → input.int()
11 more edits
- Line 16: input() → input.int()
- Line 23: input() → input.source()
- Line 24: input() → input.int()
- Line 33: input() → input.int()
- Line 36: input() → input.int()
- Line 42: when = long1 and testPeriod() → if block
- Line 43: when = long_exit → if block
- Line 45: when = short1 and testPeriod() → if block
- Line 46: when = short_exit → if block
- Line 48: when = long1 and testPeriod() → if block
- Line 51: when = short1 and testPeriod() → if block
⋯strategy(title="MD BANKNIFTY STRATEGY ", overlay=true,initial_capital=300000, default_qty_value=1)-strat_dir_input = input(title="Strategy Direction", defval="all", options=["long", "short", "all"])+strat_dir_input = input.string(title="Strategy Direction", defval="all", options=["long", "short", "all"])strat_dir_value = strat_dir_input == "long" ? strategy.direction.long : strat_dir_input == "short" ? strategy.direction.short : strategy.direction.all⋯strategy.risk.allow_entry_in(strat_dir_value)-testStartYear = input(2016, "Backtest Start Year")+testStartYear = input.int(2016, "Backtest Start Year")-testStartMonth = input(1, "Backtest Start Month")+testStartMonth = input.int(1, "Backtest Start Month")-testStartDay = input(1, "Backtest Start Day")+testStartDay = input.int(1, "Backtest Start Day")testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)//Stop date if you want to use a specific range of dates-testStopYear = input(2022, "Backtest Stop Year")+testStopYear = input.int(2022, "Backtest Stop Year")-testStopMonth = input(12, "Backtest Stop Month")+testStopMonth = input.int(12, "Backtest Stop Month")-testStopDay = input(30, "Backtest Stop Day")+testStopDay = input.int(30, "Backtest Stop Day")testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)⋯//Higher High or Lower Low Entry Inputs-price = input(close)+price = input.source(close)-LookBack = input(26)+LookBack = input.int(26)Highest = ta.highest(LookBack)⋯//Safety Confirmation Inputs - Helps to thin out false breakouts or break downs-length = input(10)+length = input.int(10)High_Guard = ta.highest(length)Low_Guard = ta.lowest(length)-length2 = input(1)+length2 = input.int(1)long1 = long == 1 and (Highest[1] > High_Guard[length2])⋯if strat_dir_input == "long"- strategy.entry("Long", strategy.long, when=long1 and testPeriod())+ if long1 and testPeriod()+ strategy.entry("Long", strategy.long)- strategy.close(id = "Long", when = long_exit)+ if long_exit+ strategy.close(id = "Long")if strat_dir_input == "short" - strategy.entry("Short", strategy.short, when=short1 and testPeriod())+ if short1 and testPeriod()+ strategy.entry("Short", strategy.short)- strategy.close(id = "Short", when = short_exit)+ if short_exit+ strategy.close(id = "Short")if strat_dir_input =="all"- strategy.entry("Long",strategy.long, when=long1 and testPeriod())+ if long1 and testPeriod()+ strategy.entry("Long",strategy.long) - strategy.entry("Short", strategy.short, when=short1 and testPeriod())+ if short1 and testPeriod()+ strategy.entry("Short", strategy.short)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.
⋯// © sincereLizard-//@version=5+//@version=6strategy(title="MD BANKNIFTY STRATEGY ", overlay=true,initial_capital=300000, default_qty_value=1)⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Strategy Direction | all | string · options ["long", "short", "all"] | strat_dir_value entry Long close Long entry Short close Short entry Long entry Short line 41 line 44 line 47 |
| Backtest Start Year | 2016 | int | testPeriodStart |
| Backtest Start Month | 1 | int | testPeriodStart |
| Backtest Start Day | 1 | int | testPeriodStart |
| Backtest Stop Year | 2022 | int | testPeriodStop |
| Backtest Stop Month | 12 | int | testPeriodStop |
| Backtest Stop Day | 30 | int | testPeriodStop |
| Stop Loss % | 2.0 | float | stop_level |
| Take Profit % | 7.0 | float | take_level |
| Price (no label in the script) | close | source | long short |
| Look Back (no label in the script) | 26 | int | Highest Lowest |
| Length (no label in the script) | 10 | int | High_Guard Low_Guard |
| Length2 (no label in the script) | 1 | int | long1 short1 |
What it calculates
- Highest (
highest,ta.highestin v5)Look Back (26)Highest · line 25 - Lowest (
lowest,ta.lowestin v5)Look Back (26)Lowest · line 26 - Highest (
highest,ta.highestin v5)Length (10)High_Guard · line 34 - Lowest (
lowest,ta.lowestin v5)Length (10)Low_Guard · line 35
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 | long1 and testPeriod() | On | 42 |
| Close Long | long_exitshort1 or (close < stop_level) or (close > take_level) | On | 43 |
| Open Short short | short1 and testPeriod() | On | 45 |
| Close Short | short_exitlong1 or (close > take_level) or (close < stop_level) | On | 46 |
| Open Long long | long1 and testPeriod() | On | 48 |
| Open Short short | short1 and testPeriod() | On | 51 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
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 |
|---|---|---|---|---|---|
| MARKET DYNAMICS HH LL BREAKOUT this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| Alex Days HiLo Rajib by 14rajib | highest lowest | v4 strategy | No trades on this market | ||
| Donchian Strat EXMO by pskoroplas | highest lowest | v4 strategy | +12.1% | 22 | 68.0% |
| Average Highest High and Lowest Low Swinger Strategy by exlux99 | lowest highest | v4 strategy | +6.4% | 20 | 49.6% |
| Highest High and Lowest Low Channel Strategy by ceyhun | highest lowest | v5 strategy | −3.7% | 26 | 7.9% |
| Donchian Channels System [racer8] by racer8 | highest lowest | v4 strategy | −3.2% | 36 | 43.6% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 18 ms | Yes 1,000 bars in 41 ms | Not measured |
| PineTS | No 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/// © sincereLizard//@version=4strategy(title="MD BANKNIFTY STRATEGY ", overlay=true,initial_capital=300000, default_qty_value=1)strat_dir_input = input(title="Strategy Direction", defval="all", options=["long", "short", "all"])strat_dir_value = strat_dir_input == "long" ? strategy.direction.long : strat_dir_input == "short" ? strategy.direction.short : strategy.direction.all////strategy.risk.allow_entry_in(strat_dir_value)testStartYear = input(2016, "Backtest Start Year")testStartMonth = input(1, "Backtest Start Month")testStartDay = input(1, "Backtest Start Day")testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)//Stop date if you want to use a specific range of datestestStopYear = input(2022, "Backtest Stop Year")testStopMonth = input(12, "Backtest Stop Month")testStopDay = input(30, "Backtest Stop Day")testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)sl_inp = (input(2.0, title='Stop Loss %', type=input.float))/100tp_inp = (input(7.0, title='Take Profit %', type=input.float))/100testPeriod() => time >= testPeriodStart and time <= testPeriodStop ? true : false//Higher High or Lower Low Entry Inputsprice = input(close)LookBack = input(26)Highest = highest(LookBack)Lowest = lowest(LookBack)long = price > Highest[1] short = price < Lowest[1]avg_price = strategy.position_avg_pricestop_level = avg_price * (1 - sl_inp)take_level = avg_price * (1 + tp_inp)//Safety Confirmation Inputs - Helps to thin out false breakouts or break downslength = input(10)High_Guard = highest(length)Low_Guard = lowest(length)length2 = input(1)long1 = long == 1 and (Highest[1] > High_Guard[length2])short1 = short == 1 and Lowest[1] < Low_Guard[length2]long_exit = short1 or (close < stop_level) or (close > take_level)short_exit = long1 or (close > take_level) or (close < stop_level)if strat_dir_input == "long" strategy.entry("Long", strategy.long, when=long1 and testPeriod()) strategy.close(id = "Long", when = long_exit)if strat_dir_input == "short" strategy.entry("Short", strategy.short, when=short1 and testPeriod()) strategy.close(id = "Short", when = short_exit)if strat_dir_input =="all" strategy.entry("Long",strategy.long, when=long1 and testPeriod()) strategy.entry("Short", strategy.short, when=short1 and testPeriod())