Pine Script v4 · Strategy
Weis Chop Strategy
A Pine Script v4 strategy built on ATR or Highest or Lowest (1) and Crossunder (ci, 61.8). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 10% of equity and pays no commission. 9 settings; defaults include Max Intraday Loss(%) 1, Renko Assignment Method ATR and Value 14.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 Weis Chop Strategy repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 5 of 5 trades.
- How did Weis Chop Strategy do on BTCUSDT 1D with default settings?
- −7.53%
- From 26 Jan 2024 to 21 Oct 2026, over 12 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Weis Chop Strategy be converted to Pine Script v5?
- No
- The automatic step from v4 to v5 changes the results, so no v5 download is offered; the edits are shown below.
- Does Weis Chop Strategy use a stop loss?
- Yes
- strategy.exit sets a stop on line 52, 53.
- Does Weis Chop Strategy run in Zeal Terminal?
- Yes
- It compiles in 18 ms and runs 1,000 bars in 56 ms, in the browser.
BTCUSDT · 1D · default settings
- Wave Volume
- CHOP
- Upper Band
- Lower Band
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −7.53%
- −$7,526.84
- Buy and hold
- +102.5%
- same period
- Closed trades
- 12
- 4 won · 8 lost
- Profitable
- 33.3%
- of closed trades
- Profit factor
- 0.31
- gross profit ÷ gross loss
- Max drawdown
- 11.10%
- −$11,098.80
One run with the author's default settings, $100,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 commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
1 setting has no label
In the settings dialog length (line 38) shows 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 52, 53. The upgraded version below moves each call inside an if block.
-
Note
Uses transp =, which v5 removed line 37
transp = on line 37. v5 folds the transparency into the colour with color.new(c, transp).
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 atr → ta.atr, round → math.round, change → ta.change, log10 → math.log10, sum → math.sum, highest → ta.highest, lowest → ta.lowest, ema → ta.ema, crossunder → ta.crossunder.
- 2 strategy calls use the when = argument (line 52, 53). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
DiffersTrades differ: 12 before, 12 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 5: input(type = input.float) → input.float()
- Line 7: method is reserved in v5: renamed method_
- Line 8: input(type = input.float) → input.float()
- Line 13: input(type = input.bool) → input.bool()
- Line 14: input(type = input.bool) → input.bool()
15 more edits
- Line 15: tr → ta.tr
- Line 20: atr → ta.atr
- Line 20: round → math.round
- Line 30: change → ta.change
- Line 37: transp = 75 → color.new(directionIsUp ? color.green : color.red, 75)
- Line 39: log10 → math.log10
- Line 39: sum → math.sum
- Line 39: atr → ta.atr
- Line 39: highest → ta.highest
- Line 39: lowest → ta.lowest
- Line 39: log10 → math.log10
- Line 40: input(type = input.integer) → input.int()
- Line 45: ema → ta.ema
- Line 46: ema → ta.ema
- Line 47: crossunder → ta.crossunder
⋯// © sharatgbhat-//@version=4+//@version=5strategy("Weis Chop Strategy", overlay=false, default_qty_type = strategy.percent_of_equity, default_qty_value = 10,max_lines_count = 500, max_labels_count = 500)-maxIdLossPcnt = input(1, "Max Intraday Loss(%)", type=input.float)+maxIdLossPcnt = input.float(1, "Max Intraday Loss(%)")strategy.risk.max_intraday_loss(maxIdLossPcnt, strategy.percent_of_equity)-method = input(defval="ATR", options=["ATR", "Traditional", "Part of Price"], title="Renko Assignment Method")+method_ = input(defval="ATR", options=["ATR", "Traditional", "Part of Price"], title="Renko Assignment Method")-methodvalue = input(defval=14.0, type=input.float, minval=0, title="Value")+methodvalue = input.float(defval=14.0, minval=0, title="Value")pricesource = input(defval="Close", options=["Close", "Open / Close", "High / Low"], title="Price Source")⋯useTrueRange = input(defval="Auto", options=["Always", "Auto", "Never"], title="Use True Range instead of Volume")-isOscillating = input(defval=false, type=input.bool, title="Oscillating")+isOscillating = input.bool(defval=false, title="Oscillating")-normalize = input(defval=false, type=input.bool, title="Normalize")+normalize = input.bool(defval=false, title="Normalize")-vol = useTrueRange == "Always" or useTrueRange == "Auto" and na(volume) ? tr : volume+vol = useTrueRange == "Always" or useTrueRange == "Auto" and na(volume) ? ta.tr : volumeop = useClose ? close : open⋯lo = useOpenClose ? close <= op ? close : op : low-if method == "ATR"+if method_ == "ATR"- methodvalue := atr(round(methodvalue))+ methodvalue := ta.atr(math.round(methodvalue))-if method == "Part of Price"+if method_ == "Part of Price" methodvalue := close / methodvalue⋯direction := currclose > prevclose ? 1 : currclose < prevclose ? -1 : nz(direction[1])-directionHasChanged = change(direction) != 0+directionHasChanged = ta.change(direction) != 0directionIsUp = direction > 0⋯res = barcount > 1 ? vol / barcount : vol-plot(isOscillating and directionIsDown ? -res : res, style=plot.style_columns, color=directionIsUp ? color.green : color.red, transp=75, linewidth=3, title="Wave Volume")+plot(isOscillating and directionIsDown ? -res : res, style=plot.style_columns, color=color.new(directionIsUp ? color.green : color.red, 75), linewidth=3, title="Wave Volume")length = input(14, minval=1)-ci = 100 * log10(sum(atr(1), length) / (highest(length) - lowest(length))) / log10(length)+ci = 100 * math.log10(math.sum(ta.atr(1), length) / (ta.highest(length) - ta.lowest(length))) / math.log10(length)-offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)+offset = input.int(0, "Offset", minval = -500, maxval = 500)plot(ci, "CHOP", color=#2962FF, offset = offset)⋯fill(band1, band0, color = color.rgb(33, 150, 243, 90), title = "Background")-MomentumBull = close>ema(close,8)+MomentumBull = close>ta.ema(close,8)-MomentumBear = close<ema(close,8)+MomentumBear = close<ta.ema(close,8)-Tradecon = crossunder(ci,61.8)+Tradecon = ta.crossunder(ci,61.8)if (MomentumBull and directionIsUp and Tradecon)⋯Clean v5
VerifiedSame 12 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 7: input() → input.string()
- Line 9: input() → input.string()
- Line 12: input() → input.string()
- Line 38: input() → input.int()
- Line 52: when = directionIsDown → if block
- Line 53: when = directionIsUp → if block
⋯strategy.risk.max_intraday_loss(maxIdLossPcnt, strategy.percent_of_equity)-method_ = input(defval="ATR", options=["ATR", "Traditional", "Part of Price"], title="Renko Assignment Method")+method_ = input.string(defval="ATR", options=["ATR", "Traditional", "Part of Price"], title="Renko Assignment Method")methodvalue = input.float(defval=14.0, minval=0, title="Value")-pricesource = input(defval="Close", options=["Close", "Open / Close", "High / Low"], title="Price Source")+pricesource = input.string(defval="Close", options=["Close", "Open / Close", "High / Low"], title="Price Source")useClose = pricesource == "Close"useOpenClose = pricesource == "Open / Close" or useClose-useTrueRange = input(defval="Auto", options=["Always", "Auto", "Never"], title="Use True Range instead of Volume")+useTrueRange = input.string(defval="Auto", options=["Always", "Auto", "Never"], title="Use True Range instead of Volume")isOscillating = input.bool(defval=false, title="Oscillating")⋯plot(isOscillating and directionIsDown ? -res : res, style=plot.style_columns, color=color.new(directionIsUp ? color.green : color.red, 75), linewidth=3, title="Wave Volume")-length = input(14, minval=1)+length = input.int(14, minval=1)ci = 100 * math.log10(math.sum(ta.atr(1), length) / (ta.highest(length) - ta.lowest(length))) / math.log10(length)⋯ strategy.entry("Sell", strategy.short)- strategy.exit("exit","Buy",when=directionIsDown,qty_percent=100,profit=20,loss=10)+ if directionIsDown+ strategy.exit("exit","Buy",qty_percent=100,profit=20,loss=10)- strategy.exit("exit","Sell",when=directionIsUp,qty_percent=100,profit=20,loss=10)+ if directionIsUp+ strategy.exit("exit","Sell",qty_percent=100,profit=20,loss=10)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: 12 before, 12 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.
⋯// © sharatgbhat-//@version=5+//@version=6strategy("Weis Chop Strategy", overlay=false, default_qty_type = strategy.percent_of_equity, default_qty_value = 10,max_lines_count = 500, max_labels_count = 500)⋯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 |
|---|---|---|---|
| Max Intraday Loss(%) | 1 | float | line 6 |
| Renko Assignment Method | ATR | string · options ["ATR", "Traditional", "Part of Price"] | line 19 line 21 |
| Value | 14.0 | float · min 0 | prevhigh prevlow |
| Price Source | Close | string · options ["Close", "Open / Close", "High / Low"] | useClose useOpenClose |
| Use True Range instead of Volume | Auto | string · options ["Always", "Auto", "Never"] | vol |
| Oscillating | false | bool | Wave Volume |
| Normalize | false | bool | barcount |
| Length (no label in the script) | 14 | int · min 1 | ci |
| Offset | 0 | int (written input.integer) · min -500 · max 500 | CHOP |
What it calculates
- ATR / Highest / Lowest (
atr,ta.atrin v5)1ci · line 39 - Crossunder (
crossunder,ta.crossunderin v5)ci, 61.8Tradecon · line 47
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 Buy long | (MomentumBull and directionIsUp and Tradecon) | On | 49 |
| Open Sell short | (MomentumBear and directionIsDown and Tradecon ) | On | 51 |
| Exit exit stop and limit | directionIsDowndirection < 0 | On | 52 |
| Exit exit stop and limit | directionIsUpdirection > 0 | On | 53 |
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.
- 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 | −7.5% | +102.5% | 12 | 33% | 0.31 | 11.1% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −1.6% | +5.5% | 10 | 40% | 0.66 | 4.9% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −11.0% | +9.8% | 23 | 48% | 0.43 | 16.2% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −5.1% | +8.4% | 12 | 25% | 0.18 | 6.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −8.2% | +16.7% | 15 | 27% | 0.40 | 8.4% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +1.4% | +21.5% | 10 | 60% | 1.65 | 2.2% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.1% | +148.3% | 11 | 45% | 1.01 | 5.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −4.9% | +17.1% | 10 | 20% | 0.14 | 6.0% | 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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 4 | 25% | −$3,495.20 |
| Sideways market | 3 | 67% | $513.91 |
| Falling market | 5 | 20% | −$4,545.55 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
10.2%
The 95th percentile of the worst drawdown when the same 12 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 7.5% to 10.2%; the tick is what actually happened, 8.9%. Order luck alone moves it this much.
All 12 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 30 Mar 2024 69,850.50 | 14 Apr 2024 63,924.50 | 15 | −$848.38 |
| short | 14 Apr 2024 63,924.50 | 7 Jun 2024 70,799.10 | 54 | −$1,066.29 |
| long | 7 Jun 2024 70,799.10 | 11 Nov 2024 81,389.60 | 157 | $1,467.22 |
| long | 6 Dec 2024 96,945.60 | 3 Feb 2025 97,700.60 | 59 | $77.53 |
| short | 3 Feb 2025 97,700.60 | 11 Sep 2025 113,960.00 | 220 | −$1,658.05 |
| long | 11 Sep 2025 113,960.00 | 17 Dec 2025 87,863.40 | 97 | −$2,243.54 |
| short | 17 Dec 2025 87,863.40 | 5 Jan 2026 91,529.70 | 19 | −$399.45 |
| long | 5 Jan 2026 91,529.70 | 6 Feb 2026 61,636.80 | 32 | −$3,113.38 |
| short | 24 Feb 2026 64,656.00 | 5 Mar 2026 72,666.80 | 9 | −$1,142.53 |
| long | 5 Mar 2026 72,666.80 | 18 May 2026 77,457.70 | 74 | $600.44 |
| short | 18 May 2026 77,457.70 | 22 Jul 2026 66,556.10 | 65 | $1,290.23 |
| long | 22 Jul 2026 66,556.10 | 15 Aug 2026 63,043.60 | 24 | −$490.63 |
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 |
|---|---|---|---|---|---|
| Weis Chop Strategy this page | — | v4 strategy | −7.5% | 12 | 11.1% |
| Aggresive Scalper-Swing Crypto Strategy by exlux99 | lowest highest atr | v4 strategy | −7.4% | 3 | 16.0% |
| Donchian Channels Strategy by KrisWaters by kriswaters | highest lowest atr | v4 strategy | +55.8% | 21 | 23.3% |
| Chandelier Exit - Strategy by melihtuna | atr highest lowest | v4 strategy | −34.8% | 11 | 43.2% |
| ETF trader by FX_minds | atr lowest highest | v4 strategy | +78.3% | 17 | 32.7% |
| Chandelier Exit by Zeal Terminal | atr highest lowest | v5 indicator | indicator | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 18 ms | Yes 1,000 bars in 56 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/// © sharatgbhat//@version=4strategy("Weis Chop Strategy", overlay=false, default_qty_type = strategy.percent_of_equity, default_qty_value = 10,max_lines_count = 500, max_labels_count = 500)maxIdLossPcnt = input(1, "Max Intraday Loss(%)", type=input.float)strategy.risk.max_intraday_loss(maxIdLossPcnt, strategy.percent_of_equity)method = input(defval="ATR", options=["ATR", "Traditional", "Part of Price"], title="Renko Assignment Method")methodvalue = input(defval=14.0, type=input.float, minval=0, title="Value")pricesource = input(defval="Close", options=["Close", "Open / Close", "High / Low"], title="Price Source")useClose = pricesource == "Close"useOpenClose = pricesource == "Open / Close" or useCloseuseTrueRange = input(defval="Auto", options=["Always", "Auto", "Never"], title="Use True Range instead of Volume")isOscillating = input(defval=false, type=input.bool, title="Oscillating")normalize = input(defval=false, type=input.bool, title="Normalize")vol = useTrueRange == "Always" or useTrueRange == "Auto" and na(volume) ? tr : volumeop = useClose ? close : openhi = useOpenClose ? close >= op ? close : op : highlo = useOpenClose ? close <= op ? close : op : lowif method == "ATR" methodvalue := atr(round(methodvalue))if method == "Part of Price" methodvalue := close / methodvaluecurrclose = float(na)prevclose = nz(currclose[1])prevhigh = prevclose + methodvalueprevlow = prevclose - methodvaluecurrclose := hi > prevhigh ? hi : lo < prevlow ? lo : prevclosedirection = int(na)direction := currclose > prevclose ? 1 : currclose < prevclose ? -1 : nz(direction[1])directionHasChanged = change(direction) != 0directionIsUp = direction > 0directionIsDown = direction < 0barcount = 1barcount := not directionHasChanged and normalize ? barcount[1] + barcount : barcountvol := not directionHasChanged ? vol[1] + vol : volres = barcount > 1 ? vol / barcount : volplot(isOscillating and directionIsDown ? -res : res, style=plot.style_columns, color=directionIsUp ? color.green : color.red, transp=75, linewidth=3, title="Wave Volume")length = input(14, minval=1)ci = 100 * log10(sum(atr(1), length) / (highest(length) - lowest(length))) / log10(length)offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)plot(ci, "CHOP", color=#2962FF, offset = offset)band1 = hline(61.8, "Upper Band", color=#787B86, linestyle=hline.style_dashed)band0 = hline(38.2, "Lower Band", color=#787B86, linestyle=hline.style_dashed)fill(band1, band0, color = color.rgb(33, 150, 243, 90), title = "Background")MomentumBull = close>ema(close,8)MomentumBear = close<ema(close,8)Tradecon = crossunder(ci,61.8)if (MomentumBull and directionIsUp and Tradecon) strategy.entry("Buy", strategy.long)if (MomentumBear and directionIsDown and Tradecon ) strategy.entry("Sell", strategy.short) strategy.exit("exit","Buy",when=directionIsDown,qty_percent=100,profit=20,loss=10) strategy.exit("exit","Sell",when=directionIsUp,qty_percent=100,profit=20,loss=10)