Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Wyckoff Range Strategy

A Pine Script v5 strategy built on Crossover or SMA (close) and Crossunder or SMA (close). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade commits 10% of equity and pays no commission. 5 settings; defaults include Accumulation 32, Distribution 35 and Spring 10.

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 Wyckoff Range Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 2 of 2 trades.
How did Wyckoff Range Strategy do on BTCUSDT 1D with default settings?
+6.17%
From 26 Jan 2024 to 21 Oct 2026, over 6 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
What alerts does Wyckoff Range Strategy have?
2
Enter Long Position; Enter Short Position.
Does Wyckoff Range Strategy run in Pine Script v6?
Yes
Same 6 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 Wyckoff Range Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 33, 34.

BTCUSDT · 1D · default settings

  • Accumulation Phase
  • Distribution Phase
  • Spring
  • Upthrust
  • 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 (5)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,096$2,025Equity from $1,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
+6.17%
$61.73
Buy and hold
+102.5%
same period
Closed trades
6
4 won · 2 lost
Profitable
66.7%
of closed trades
Profit factor
8.43
gross profit ÷ gross loss
Max drawdown
2.31%
−$23.06

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

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

Settings

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

SettingDefaultType and rangeFeeds
Accumulation32intisAccumulation
Distribution35intisDistribution
Spring10intisSpring
Upthrust20intisUpthrust
Stop Percentage10intstopLossLevelLong stopLossLevelShort

What it calculates

  • Crossover / SMAclose, ta.sma(close, AccumulationLength)isAccumulation · line 12
  • Crossunder / SMAclose, ta.sma(close, DistributionLength)isDistribution · line 14
  • Crossover / SMAlow, ta.sma(low, SpringLength)isSpring · line 16
  • Crossunder / SMAhigh, ta.sma(high, UpthrustLength)isUpthrust · line 17

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 dataAccumulationLengthAccumulationsetting · 32DistributionLengthDistributionsetting · 35lowlowprice dataSpringLengthSpringsetting · 10highhighprice dataUpthrustLengthUpthrustsetting · 20stopPercentageStop Percentagesetting · 10isAccumulationCrossover / SMA→ isAccumulationisDistributionCrossunder / SMA→ isDistributionisSpringCrossover / SMA→ isSpringisUpthrustCrossunder / SMA→ isUpthruststopLossLevelLong, stopLossLevelShortstopLossLevelLong · sto…2 valuesenterLongenterLongconditionenterShortenterShortconditionclose:ShortClose Shortstrategy.closeentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeentry:ShortOpen Shortstrategy.entryexit:Stop Loss Longexit Stop Loss Longstrategy.exitexit:Stop Loss Shortexit Stop Loss Shortstrategy.exitalert:25alertalertalert:29alertalertplotshape:36Accumulation Phaseplotshapeplotshape:37Distribution Phaseplotshapeplotshape:38Springplotshapeplotshape:39Upthrustplotshape

Order rules

OrderFires whenBy defaultLine
Close Short(enterLong)On23
Open Long long(enterLong)On24
Close Long(enterShort)On27
Open Short short(enterShort)On28
Exit Stop Loss Long stopevery barOn33
Exit Stop Loss Short stopevery barOn34

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

Alerts

AlertCallMessageLine
(no title)alertEnter Long Position25
(no title)alertEnter Short Position29

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

2/2trades 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 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+6.2%+102.5%667%8.432.3%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.3%+5.5%850%1.073.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+12.8%+9.8%863%6.682.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−6.1%+8.4%933%0.167.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.5%+16.7%757%1.332.3%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+1.7%+21.5%1331%1.523.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−11.0%+148.3%633%0.2314.9%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.6%+17.1%838%1.481.2%8 May 2026 – 21 Oct 2026

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

Settings heatmap

Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (Accumulation 19, Distribution 21) made +10.5% before 26 Dec 2025 and −2.7% after it, worse than the defaults' +3.0% after. Tuning on the past did not carry forward. 70% of the 64 combinations made money in-sample and 70% out-of-sample.

Before 26 Dec 2025 · in-sample
Distribution ↓ · Accumulation →1619222732384554
18+6%+7%+5%−0%+3%+0%+1%+0%
21+10%+10%+10%−1%+6%−1%+1%−2%
25+8%+9%+8%+0%+3%−0%+2%+0%
30+9%+9%+9%+1%+3%+0%+1%+2%
35+8%+9%+8%+1%+3%+0%+1%+2%
42+7%+6%+6%−1%+1%−2%−1%−0%
49+6%+5%+5%−2%−0%−3%−2%−1%
60+5%+4%+4%−2%−0%−3%−2%−3%
From 26 Dec 2025 · out-of-sample
Distribution ↓ · Accumulation →1619222732384554
18+1%−3%−3%−2%+3%−1%0%+3%
21−1%−3%−3%−2%+1%−1%0%+0%
25+4%−0%−0%−0%+6%+2%+2%+5%
30+4%−0%−0%−0%+6%+2%+2%+5%
35+3%+0%+0%+0%+3%+2%+2%+3%
42−0%+0%+0%+0%−0%+2%+2%+3%
49+3%+0%+0%+0%+3%+2%+2%+3%
60+2%+2%+2%+2%+2%+2%+2%+2%

Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market20%−$8.31
Sideways market2100%$40.37
Falling market2100%$29.66

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

How bad could the drawdown be?

0.8%

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

0%1%
All 6 trades
SideEntryExitBarsP&L
short3 Apr 2024 65,464.007 Apr 2024 68,896.004−$5.24
long7 Apr 2024 68,896.0014 Jun 2024 66,773.0068−$3.07
short14 Jun 2024 66,773.008 Aug 2024 60,647.6055$9.10
long12 Apr 2025 83,423.8010 Oct 2025 109,496.00181$31.28
short21 Jan 2026 88,427.706 Feb 2026 69,200.9016$22.44
short27 Mar 2026 68,820.305 Aug 2026 64,106.60131$7.22

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
Wyckoff Range Strategy this page—v5 strategy+6.2%62.3%
Follow the Crypto Shorts by xtradernetsmav4 strategyNo trades on this market
buy down and sell high trend 200 sma and ma cross by willi130503smav4 strategyNo trades on this market
Mayer Multiple Strategy by xtradernetsmav4 strategyNo trades on this market
Moving Average Cross Strategy early Closing by Geduldtradersmav4 strategy+73.8%20151.5%
MFI Simple Strategy by OztheWozsmav5 strategy−0.2%283.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.

  • 5 settings use the untyped input() (line 6, 7, 8, 9, 10). 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 6 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
  • Line 9: input() → input.int()
  • Line 10: input() → input.int()
⋯// Input Variables-AccumulationLength = input(32, "Accumulation")+AccumulationLength = input.int(32, "Accumulation")-DistributionLength = input(35, "Distribution")+DistributionLength = input.int(35, "Distribution")-SpringLength = input(10, "Spring")+SpringLength = input.int(10, "Spring")-UpthrustLength = input(20, "Upthrust")+UpthrustLength = input.int(20, "Upthrust")-stopPercentage = input(10, "Stop Percentage")+stopPercentage = input.int(10, "Stop Percentage")// Accumulation Phase⋯

Does it run in Pine Script v6?

Yes

Same 6 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

⋯// © deperp-//@version=5+//@version=6strategy("Wyckoff Range Strategy by deperp", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 21 msYes 1,000 bars in 39 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/// © deperp//@version=5strategy("Wyckoff Range Strategy by deperp", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent)// Input VariablesAccumulationLength = input(32, "Accumulation")DistributionLength = input(35, "Distribution")SpringLength = input(10, "Spring")UpthrustLength = input(20, "Upthrust")stopPercentage = input(10, "Stop Percentage")// Accumulation PhaseisAccumulation = ta.crossover(close, ta.sma(close, AccumulationLength))// Distribution PhaseisDistribution = ta.crossunder(close, ta.sma(close, DistributionLength))// Spring and UpthrustisSpring = ta.crossover(low, ta.sma(low, SpringLength))isUpthrust = ta.crossunder(high, ta.sma(high, UpthrustLength))// Strategy ConditionsenterLong = isAccumulation and isSpringenterShort = isDistribution and isUpthrust// Entry and Exit Conditionsif (enterLong)    strategy.close("Short")    strategy.entry("Long", strategy.long, comment="Enter Long")    alert("Enter Long Position")if (enterShort)    strategy.close("Long")    strategy.entry("Short", strategy.short,  comment="Enter Short")    alert("Enter Short Position")// Stop LossstopLossLevelLong = close * (1 - stopPercentage / 100)stopLossLevelShort = close * (1 + stopPercentage / 100)strategy.exit("Stop Loss Long", "Long", stop=stopLossLevelLong)strategy.exit("Stop Loss Short", "Short", stop=stopLossLevelShort)// Plotting Wyckoff Schematicsplotshape(isAccumulation, title="Accumulation Phase", location=location.belowbar, color=color.green, style=shape.labelup, text="Accumulation")plotshape(isDistribution, title="Distribution Phase", location=location.abovebar, color=color.red, style=shape.labeldown, text="Distribution")plotshape(isSpring, title="Spring", location=location.belowbar, color=color.blue, style=shape.triangleup)plotshape(isUpthrust, title="Upthrust", location=location.abovebar, color=color.orange, style=shape.triangledown)