Pine Script v4 · Strategy
Strategy- Combo Z Score
A Pine Script v4 strategy built on BB (close, 20), EMA (close, 100) and SMA (divM, 266). It has 56 order rules, 28 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. 11 settings; defaults include Length 266, VIX Z Std Dev 2.0 and MOVE Z Std Dev 2.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 Strategy- Combo Z Score repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Strategy- Combo Z Score 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; it opened a long position that was still open on the last bar, 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 Strategy- Combo Z Score 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 Strategy- Combo Z Score use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Strategy- Combo Z Score run in Zeal Terminal?
- Yes
- It compiles in 71 ms and runs 1,000 bars in 97 ms, in the browser.
BTCUSDT · 1D · default settings
- HLine
- HLine
- HLine
- HLine
- Winning trade
- Losing trade
- Equity
- Buy and hold
Needs TVC:MOVE D data, not available: not a Binance spot market Needs VIX D data, not available: not a Binance spot market Needs VVIX D data, not available: not a Binance spot market Needs CBOE:OVX D data, not available: not a Binance spot market Needs TVC:USOIL 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
- 42.92%
- −$42,917.00
One run with the author's default settings, $100,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
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 5) 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 77, 78, 80, 81, 84, 85, 87, 88, 91, 92, 94, 95, 98, 99, 101, 102, 105, 106, 108, 109, 112, 113, 115, 116, 119, 120, 122, 123, 129, 130, 132, 133, 136, 137, 139, 140, 143, 144, 146, 147, 150, 151, 153, 154, 157, 158, 160, 161, 164, 165, 167, 168, 171, 172, 174, 175. 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 security → request.security, bb → ta.bb, ema → ta.ema, sma → ta.sma, stdev → ta.stdev.
- 56 strategy calls use the when = argument (line 77, 78, 80, 81, 84, 85, 87, 88, 91, 92, 94, 95, 98, 99, 101, 102, 105, 106, 108, 109, 112, 113, 115, 116, 119, 120, 122, 123, 129, 130, 132, 133, 136, 137, 139, 140, 143, 144, 146, 147, 150, 151, 153, 154, 157, 158, 160, 161, 164, 165, 167, 168, 171, 172, 174, 175). 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 8: input(type = input.bool) → input.bool()
- Line 9: input(type = input.bool) → input.bool()
- Line 10: input(type = input.bool) → input.bool()
- Line 11: input(type = input.bool) → input.bool()
- Line 16: input(type = input.float) → input.float()
15 more edits
- Line 17: input(type = input.integer) → input.int()
- Line 19: security → request.security
- Line 20: security → request.security
- Line 21: security → request.security
- Line 22: security → request.security
- Line 23: security → request.security
- Line 25: input(type = input.time) → input.time()
- Line 29: bb → ta.bb
- Line 31: ema → ta.ema
- Line 36: sma → ta.sma
- Line 37: stdev → ta.stdev
- Line 40: sma → ta.sma
- Line 41: stdev → ta.stdev
- Line 56: sma → ta.sma
- Line 57: stdev → ta.stdev
⋯// © jroche1973-//@version=4+//@version=5strategy("Strategy: Combo Z Score", precision=6, overlay=false, pyramiding=100, calc_on_order_fills=true)⋯m_StdDevs = input(defval = 2.0, title="MOVE Z Std Dev")-show_m = input(type=input.bool, title="Show MOVE", defval=true)+show_m = input.bool(title="Show MOVE", defval=true)-show_v = input(type=input.bool, title="Show VIX", defval=true)+show_v = input.bool(title="Show VIX", defval=true)-show_o = input(type=input.bool, title="Show Oil/Oil Vol", defval=true)+show_o = input.bool(title="Show Oil/Oil Vol", defval=true)-show_ema = input(type=input.bool, title="Apply EMA", defval=true)+show_ema = input.bool(title="Apply EMA", defval=true)l_ema = input( title="EMA Length", defval=100)⋯//strat_m = input(type=input.bool, title="Start both Move only", defval=false)-_bb_mult = input(title="BB mult", type=input.float, defval=2)+_bb_mult = input.float(title="BB mult", defval=2)-_bb_range = input(title="BB mean range", type=input.integer, defval=20)+_bb_range = input.int(title="BB mean range", defval=20)//src = input(close)-MOVE = security("TVC:MOVE", timeframe.period, close)+MOVE = request.security("TVC:MOVE", timeframe.period, close)-VIX = security("VIX", timeframe.period, close)+VIX = request.security("VIX", timeframe.period, close)-VVIX = security("VVIX", timeframe.period, close)+VVIX = request.security("VVIX", timeframe.period, close)-OILVIX = security("CBOE:OVX", timeframe.period, close)+OILVIX = request.security("CBOE:OVX", timeframe.period, close)-USO = security("TVC:USOIL", timeframe.period, close)+USO = request.security("TVC:USOIL", timeframe.period, close)//USO = security("WTI", timeframe.period, close)-startDateTime = input(type=input.time, defval=timestamp("1 Jan 2007 09:30"), +startDateTime = input.time(defval=timestamp("1 Jan 2007 09:30"), title="Start Date", group="Strategy Date Range", ⋯ "the strategy simulates buy and sell trades.") -[_bb_mid, _bb_hig, _bb_low] = bb(close, _bb_range, _bb_mult)+[_bb_mid, _bb_hig, _bb_low] = ta.bb(close, _bb_range, _bb_mult)_bb_percent = (close - _bb_low) / (_bb_hig - _bb_low)-s_ema = ema(close, l_ema)+s_ema = ta.ema(close, l_ema)//Proxy of M of Move ie alt VVIX⋯divM = MOVE/iVIX-m_basis = sma(divM, Length)+m_basis = ta.sma(divM, Length)-m_zscore = (divM - m_basis) / stdev(divM, Length)+m_zscore = (divM - m_basis) / ta.stdev(divM, Length)iOILVIX = 1/OILVIXdivO = USO/iOILVIX-o_basis = sma(divO, Length)+o_basis = ta.sma(divO, Length)-o_zscore = (divO - o_basis) / stdev(divO, Length)+o_zscore = (divO - o_basis) / ta.stdev(divO, Length)plot(show_m? m_zscore: na, color=color.new(#55FF55, 0))⋯divV = VIX/VVIX-v_basis = sma(divV, Length)+v_basis = ta.sma(divV, Length)-v_zscore = (divV - v_basis) / stdev(divV, Length)+v_zscore = (divV - v_basis) / ta.stdev(divV, Length)plot(show_v? v_zscore: na, color=color.new(#7d070c, 0))⋯Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 5: input() → input.int()
- Line 6: input() → input.float()
- Line 7: input() → input.float()
- Line 12: input() → input.int()
- Line 77: when = strategy.position_size > 0 → if block
- Line 78: when = long_all → if block
54 more edits
- Line 80: when = strategy.position_size <= 0 → if block
- Line 81: when = short_all → if block
- Line 84: when = strategy.position_size > 0 → if block
- Line 85: when = long_move → if block
- Line 87: when = strategy.position_size <= 0 → if block
- Line 88: when = short_move → if block
- Line 91: when = strategy.position_size > 0 → if block
- Line 92: when = long_vix → if block
- Line 94: when = strategy.position_size <= 0 → if block
- Line 95: when = short_vix → if block
- Line 98: when = strategy.position_size > 0 → if block
- Line 99: when = long_move → if block
- Line 101: when = strategy.position_size <= 0 → if block
- Line 102: when = short_move → if block
- Line 105: when = strategy.position_size > 0 → if block
- Line 106: when = long_vix → if block
- Line 108: when = strategy.position_size <= 0 → if block
- Line 109: when = short_vix → if block
- Line 112: when = strategy.position_size > 0 → if block
- Line 113: when = long_vix → if block
- Line 115: when = strategy.position_size <= 0 → if block
- Line 116: when = short_vix → if block
- Line 119: when = strategy.position_size > 0 → if block
- Line 120: when = long_vix → if block
- Line 122: when = strategy.position_size <= 0 → if block
- Line 123: when = short_vix → if block
- Line 129: when = strategy.position_size > 0 → if block
- Line 130: when = long_all → if block
- Line 132: when = strategy.position_size <= 0 → if block
- Line 133: when = short_all → if block
- Line 136: when = strategy.position_size > 0 → if block
- Line 137: when = long_move → if block
- Line 139: when = strategy.position_size <= 0 → if block
- Line 140: when = short_move → if block
- Line 143: when = strategy.position_size > 0 → if block
- Line 144: when = long_vix → if block
- Line 146: when = strategy.position_size <= 0 → if block
- Line 147: when = short_vix → if block
- Line 150: when = strategy.position_size > 0 → if block
- Line 151: when = long_move → if block
- Line 153: when = strategy.position_size <= 0 → if block
- Line 154: when = short_move → if block
- Line 157: when = strategy.position_size > 0 → if block
- Line 158: when = long_vix → if block
- Line 160: when = strategy.position_size <= 0 → if block
- Line 161: when = short_vix → if block
- Line 164: when = strategy.position_size > 0 → if block
- Line 165: when = long_vix → if block
- Line 167: when = strategy.position_size <= 0 → if block
- Line 168: when = short_vix → if block
- Line 171: when = strategy.position_size > 0 → if block
- Line 172: when = long_vix → if block
- Line 174: when = strategy.position_size <= 0 → if block
- Line 175: when = short_vix → if block
⋯strategy("Strategy: Combo Z Score", precision=6, overlay=false, pyramiding=100, calc_on_order_fills=true)-Length = input(266) //252+Length = input.int(266) //252-v_StdDevs = input(defval = 2.0, title="VIX Z Std Dev")+v_StdDevs = input.float(defval = 2.0, title="VIX Z Std Dev")-m_StdDevs = input(defval = 2.0, title="MOVE Z Std Dev")+m_StdDevs = input.float(defval = 2.0, title="MOVE Z Std Dev")show_m = input.bool(title="Show MOVE", defval=true)⋯show_ema = input.bool(title="Apply EMA", defval=true)-l_ema = input( title="EMA Length", defval=100)+l_ema = input.int( title="EMA Length", defval=100)//strat_all = input(type=input.bool, title="Start both M and V", defval=true)⋯ if m_zscore > 0 and v_zscore > 0 and o_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) //open short position+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100) //open short position- strategy.close("close long", when=long_all) //close all long positions+ if long_all+ strategy.close("close long") //close all long positions else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) //open long position+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100) //open long position- strategy.close("close short", when=short_all) //close all short positions+ if short_all+ strategy.close("close short") //close all short positions else if show_m and show_v == false and show_o == false if m_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0)+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100)- strategy.close("close long", when=long_move)+ if long_move+ strategy.close("close long") else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0)+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100)- strategy.close("close short", when=short_move)+ if short_move+ strategy.close("close short") else if show_v and show_m == false and show_o == false if v_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0)+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100)- strategy.close("close long", when=long_vix)+ if long_vix+ strategy.close("close long") else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0)+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100)- strategy.close("close short", when=short_vix)+ if short_vix+ strategy.close("close short") else if show_o and show_v == false and show_m == false if o_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0)+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100)- strategy.close("close long", when=long_move)+ if long_move+ strategy.close("close long") else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0)+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100)- strategy.close("close short", when=short_move)+ if short_move+ strategy.close("close short") else if show_v and show_m and show_o == false if v_zscore > 0 and m_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0)+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100)- strategy.close("close long", when=long_vix)+ if long_vix+ strategy.close("close long") else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0)+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100)- strategy.close("close short", when=short_vix)+ if short_vix+ strategy.close("close short") else if show_v and show_o and show_m == false if v_zscore > 0 and o_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0)+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100)- strategy.close("close long", when=long_vix)+ if long_vix+ strategy.close("close long") else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0)+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100)- strategy.close("close short", when=short_vix)+ if short_vix+ strategy.close("close short") else if show_o and show_m and show_v == false if o_zscore > 0 and m_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0)+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100)- strategy.close("close long", when=long_vix)+ if long_vix+ strategy.close("close long") else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0)+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100)- strategy.close("close short", when=short_vix)+ if short_vix+ strategy.close("close short")else⋯ if m_zscore > 0 and v_zscore > 0 and o_zscore > 0 and _bb_percent < 0.5 //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) //open short position+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100) //open short position- strategy.close("close long", when=long_all) //close all long positions+ if long_all+ strategy.close("close long") //close all long positions else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) //open long position+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100) //open long position- strategy.close("close short", when=short_all) //close all short positions+ if short_all+ strategy.close("close short") //close all short positions else if show_m and show_v == false and show_o == false if m_zscore > 0 and _bb_percent < 0.5 //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0)+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100)- strategy.close("close long", when=long_move)+ if long_move+ strategy.close("close long") else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0)+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100)- strategy.close("close short", when=short_move)+ if short_move+ strategy.close("close short") else if show_v and show_m == false and show_o == false if v_zscore > 0 and _bb_percent < 0.5 //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0)+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100)- strategy.close("close long", when=long_vix)+ if long_vix+ strategy.close("close long") else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0)+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100)- strategy.close("close short", when=short_vix)+ if short_vix+ strategy.close("close short") else if show_o and show_v == false and show_m == false if o_zscore > 0 and _bb_percent < 0.5 //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0)+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100)- strategy.close("close long", when=long_move)+ if long_move+ strategy.close("close long") else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0)+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100)- strategy.close("close short", when=short_move)+ if short_move+ strategy.close("close short") else if show_v and show_m and show_o == false if v_zscore > 0 and m_zscore > 0 and _bb_percent < 0.5 //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0)+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100)- strategy.close("close long", when=long_vix)+ if long_vix+ strategy.close("close long") else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0)+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100)- strategy.close("close short", when=short_vix)+ if short_vix+ strategy.close("close short") else if show_v and show_o and show_m == false if v_zscore > 0 and o_zscore > 0 and _bb_percent < 0.5 //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0)+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100)- strategy.close("close long", when=long_vix)+ if long_vix+ strategy.close("close long") else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0)+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100)- strategy.close("close short", when=short_vix)+ if short_vix+ strategy.close("close short") else if show_o and show_m and show_v == false if o_zscore > 0 and m_zscore > 0 and _bb_percent < 0.5 //short- strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0)+ if strategy.position_size > 0+ strategy.entry("sell", strategy.short, 100)- strategy.close("close long", when=long_vix)+ if long_vix+ strategy.close("close long") else //long - strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0)+ if strategy.position_size <= 0+ strategy.entry("buy", strategy.long, 100)- strategy.close("close short", when=short_vix)+ if short_vix+ strategy.close("close 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.
⋯// © jroche1973-//@version=5+//@version=6strategy("Strategy: Combo Z Score", precision=6, overlay=false, pyramiding=100, calc_on_order_fills=true)⋯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 |
|---|---|---|---|
| Length (no label in the script) | 266 | int | m_basis m_zscore o_basis o_zscore v_basis v_zscore |
| VIX Z Std Dev | 2.0 | float | hline |
| MOVE Z Std Dev | 2.0 | float | hline |
| Show MOVE | true | bool | plot bgcolor line 75 line 82 line 89 line 96 line 103 line 110 line 117 line 127 line 134 line 141 line 148 line 155 line 162 line 169 |
| Show VIX | true | bool | plot bgcolor line 75 line 82 line 89 line 96 line 103 line 110 line 117 line 127 line 134 line 141 line 148 line 155 line 162 line 169 |
| Show Oil/Oil Vol | true | bool | plot bgcolor line 75 line 82 line 89 line 96 line 103 line 110 line 117 line 127 line 134 line 141 line 148 line 155 line 162 line 169 |
| Apply EMA | true | bool | line 72 |
| EMA Length | 100 | int | s_ema |
| BB mult | 2 | float | _bb_mid _bb_hig _bb_low |
| BB mean range | 20 | int (written input.integer) | _bb_mid _bb_hig _bb_low |
| Strategy Date Range | |||
| Start DateSpecifies the start date and time from which " + "the strategy simulates buy and sell trades. | timestamp("1 Jan 2007 09:30") | time | line 73 line 125 |
What it calculates
- BB (
bb,ta.bbin v5)close, BB mean range (20), BB mult (2)_bb_mid · line 29 - BB (
bb,ta.bbin v5)close, BB mean range (20), BB mult (2)_bb_hig · line 29 - BB (
bb,ta.bbin v5)close, BB mean range (20), BB mult (2)_bb_low · line 29 - EMA (
ema,ta.emain v5)close, EMA Length (100)s_ema · line 31 - SMA (
sma,ta.smain v5)divM, Length (266)m_basis · line 36 - Stdev (
stdev,ta.stdevin v5)divM, Length (266)m_zscore · line 37 - SMA (
sma,ta.smain v5)divO, Length (266)o_basis · line 40 - Stdev (
stdev,ta.stdevin v5)divO, Length (266)o_zscore · line 41 - SMA (
sma,ta.smain v5)divV, Length (266)v_basis · line 56 - Stdev (
stdev,ta.stdevin v5)divV, Length (266)v_zscore · line 57
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 sell short | strategy.position_size > 0 | On | 77 |
| Close close long | long_all | On | 78 |
| Open buy long | strategy.position_size <= 0 | On | 80 |
| Close close short | short_all | On | 81 |
| Open sell short | strategy.position_size > 0 | On | 84 |
| Close close long | long_movem_zscore < 0 and _bb_percent > 0.5 | On | 85 |
| Open buy long | strategy.position_size <= 0 | On | 87 |
| Close close short | short_movem_zscore > 0 and _bb_percent < 0.5 | On | 88 |
| Open sell short | strategy.position_size > 0 | On | 91 |
| Close close long | long_vixv_zscore < 0 and _bb_percent > 0.5 | On | 92 |
| Open buy long | strategy.position_size <= 0 | On | 94 |
| Close close short | short_vixv_zscore > 0 and _bb_percent < 0.5 | On | 95 |
| Open sell short | strategy.position_size > 0 | On | 98 |
| Close close long | long_movem_zscore < 0 and _bb_percent > 0.5 | On | 99 |
| Open buy long | strategy.position_size <= 0 | On | 101 |
| Close close short | short_movem_zscore > 0 and _bb_percent < 0.5 | On | 102 |
| Open sell short | strategy.position_size > 0 | On | 105 |
| Close close long | long_vixv_zscore < 0 and _bb_percent > 0.5 | On | 106 |
| Open buy long | strategy.position_size <= 0 | On | 108 |
| Close close short | short_vixv_zscore > 0 and _bb_percent < 0.5 | On | 109 |
| Open sell short | strategy.position_size > 0 | On | 112 |
| Close close long | long_vixv_zscore < 0 and _bb_percent > 0.5 | On | 113 |
| Open buy long | strategy.position_size <= 0 | On | 115 |
| Close close short | short_vixv_zscore > 0 and _bb_percent < 0.5 | On | 116 |
| Open sell short | strategy.position_size > 0 | On | 119 |
| Close close long | long_vixv_zscore < 0 and _bb_percent > 0.5 | On | 120 |
| Open buy long | strategy.position_size <= 0 | On | 122 |
| Close close short | short_vixv_zscore > 0 and _bb_percent < 0.5 | On | 123 |
| Open sell short | strategy.position_size > 0 | On | 129 |
| Close close long | long_all | On | 130 |
| Open buy long | strategy.position_size <= 0 | On | 132 |
| Close close short | short_all | On | 133 |
| Open sell short | strategy.position_size > 0 | On | 136 |
| Close close long | long_movem_zscore < 0 and _bb_percent > 0.5 | On | 137 |
| Open buy long | strategy.position_size <= 0 | On | 139 |
| Close close short | short_movem_zscore > 0 and _bb_percent < 0.5 | On | 140 |
| Open sell short | strategy.position_size > 0 | On | 143 |
| Close close long | long_vixv_zscore < 0 and _bb_percent > 0.5 | On | 144 |
| Open buy long | strategy.position_size <= 0 | On | 146 |
| Close close short | short_vixv_zscore > 0 and _bb_percent < 0.5 | On | 147 |
| Open sell short | strategy.position_size > 0 | On | 150 |
| Close close long | long_movem_zscore < 0 and _bb_percent > 0.5 | On | 151 |
| Open buy long | strategy.position_size <= 0 | On | 153 |
| Close close short | short_movem_zscore > 0 and _bb_percent < 0.5 | On | 154 |
| Open sell short | strategy.position_size > 0 | On | 157 |
| Close close long | long_vixv_zscore < 0 and _bb_percent > 0.5 | On | 158 |
| Open buy long | strategy.position_size <= 0 | On | 160 |
| Close close short | short_vixv_zscore > 0 and _bb_percent < 0.5 | On | 161 |
| Open sell short | strategy.position_size > 0 | On | 164 |
| Close close long | long_vixv_zscore < 0 and _bb_percent > 0.5 | On | 165 |
| Open buy long | strategy.position_size <= 0 | On | 167 |
| Close close short | short_vixv_zscore > 0 and _bb_percent < 0.5 | On | 168 |
| Open sell short | strategy.position_size > 0 | On | 171 |
| Close close long | long_vixv_zscore < 0 and _bb_percent > 0.5 | On | 172 |
| Open buy long | strategy.position_size <= 0 | On | 174 |
| Close close short | short_vixv_zscore > 0 and _bb_percent < 0.5 | On | 175 |
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 data5 security call(s), none with lookahead on.
- 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
Not run on other markets: the script requests TVC:MOVE D, VIX D, VVIX D, CBOE:OVX D, TVC:USOIL D, and that data is not available here (not a Binance spot market; not a Binance spot market; not a Binance spot market; 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 |
|---|---|---|---|---|---|
| Strategy- Combo Z Score this page | — | v4 strategy | 0.0% | 0 | 42.9% |
| Strategy Oil Z Score by jroche1973 | bb ema sma stdev | v4 strategy | No trades on this market | ||
| Volume Weighted Bollinger Bands Strategy by Ankit_1618 | ema sma stdev | v4 strategy | +10.0% | 15 | 27.5% |
| BB21_MA200_Strategy by mohanee | ema sma stdev | v4 strategy | No trades on this market | ||
| Super Breakout day trading by beststockalert | stdev sma ema | v4 strategy | No trades on this market | ||
| Super Auto Breakout Day Trade Volatile stocks by beststockalert | stdev sma ema | v4 strategy | −6.1% | 51 | 29.1% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 71 ms | With a workaround 1,000 bars in 97 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/// © jroche1973//@version=4strategy("Strategy: Combo Z Score", precision=6, overlay=false, pyramiding=100, calc_on_order_fills=true)Length = input(266) //252v_StdDevs = input(defval = 2.0, title="VIX Z Std Dev")m_StdDevs = input(defval = 2.0, title="MOVE Z Std Dev")show_m = input(type=input.bool, title="Show MOVE", defval=true)show_v = input(type=input.bool, title="Show VIX", defval=true)show_o = input(type=input.bool, title="Show Oil/Oil Vol", defval=true)show_ema = input(type=input.bool, title="Apply EMA", defval=true)l_ema = input( title="EMA Length", defval=100)//strat_all = input(type=input.bool, title="Start both M and V", defval=true)//strat_v = input(type=input.bool, title="Start both Vix only", defval=false)//strat_m = input(type=input.bool, title="Start both Move only", defval=false)_bb_mult = input(title="BB mult", type=input.float, defval=2)_bb_range = input(title="BB mean range", type=input.integer, defval=20)//src = input(close)MOVE = security("TVC:MOVE", timeframe.period, close)VIX = security("VIX", timeframe.period, close)VVIX = security("VVIX", timeframe.period, close)OILVIX = security("CBOE:OVX", timeframe.period, close)USO = security("TVC:USOIL", timeframe.period, close)//USO = security("WTI", timeframe.period, close)startDateTime = input(type=input.time, defval=timestamp("1 Jan 2007 09:30"), title="Start Date", group="Strategy Date Range", tooltip="Specifies the start date and time from which " + "the strategy simulates buy and sell trades.") [_bb_mid, _bb_hig, _bb_low] = bb(close, _bb_range, _bb_mult)_bb_percent = (close - _bb_low) / (_bb_hig - _bb_low)s_ema = ema(close, l_ema)//Proxy of M of Move ie alt VVIXiVIX = 1/VIX//MOVE calcsdivM = MOVE/iVIXm_basis = sma(divM, Length)m_zscore = (divM - m_basis) / stdev(divM, Length)iOILVIX = 1/OILVIXdivO = USO/iOILVIXo_basis = sma(divO, Length)o_zscore = (divO - o_basis) / stdev(divO, Length)plot(show_m? m_zscore: na, color=color.new(#55FF55, 0))plot(show_o? o_zscore: na, color=color.new(#ebbd14, 0))//plot( _bb_percent , color = color.new(color.yellow,0))hline(m_StdDevs, color=color.white, linestyle=hline.style_dotted)hline(-1 * m_StdDevs, color=color.white, linestyle=hline.style_dotted)color o_color = o_zscore < 0 ? color.new(color.white, 70): color.new(color.yellow, 70) //we want white if not activecolor ob_color = o_zscore < 0 and _bb_percent > 0.5 ? color.new(color.white, 70): color.new(color.yellow, 70) //we want white if not activecolor m_color = m_zscore < 0 ? color.new(color.white, 70): color.new(color.blue, 70) //we want white if not activecolor mb_color = m_zscore < 0 and _bb_percent > 0.5 ? color.new(color.white, 70): color.new(color.blue, 70) //we want white if not activeuse_b = _bb_percent < 0.5 ? true: falsebgcolor(show_o and use_b ? color.new(o_color,70) : color.new(color.white, 70)) // we want whatever color our status stipulates if 'on' or white if 'off'bgcolor(show_m and use_b ? color.new(m_color,70) : color.new(color.white, 70)) // we want whatever color our status stipulates if 'on' or white if 'off'//VIX CalcsdivV = VIX/VVIXv_basis = sma(divV, Length)v_zscore = (divV - v_basis) / stdev(divV, Length)plot(show_v? v_zscore: na, color=color.new(#7d070c, 0))hline(v_StdDevs, color=color.white, linestyle=hline.style_dotted)hline(-1 * v_StdDevs, color=color.white, linestyle=hline.style_dotted)color v_color = v_zscore < 0 ? color.new(color.white, 70): color.new(color.red, 70) //we want white if not activebgcolor(show_v and use_b? color.new(v_color,70) : color.new(color.white, 70)) // we want whatever color our status stipulates if 'on' or white if 'off'//Strategy Testinglong_all = m_zscore < 0 and v_zscore < 0 and o_zscore < 0 and _bb_percent > 0.5 ? true : falselong_vix = v_zscore < 0 and _bb_percent > 0.5long_move = m_zscore < 0 and _bb_percent > 0.5long_oil = o_zscore < 0 and _bb_percent > 0.5short_all = m_zscore > 0 and v_zscore > 0 and o_zscore > 0 and _bb_percent < 0.5 ? true : falseshort_vix = v_zscore > 0 and _bb_percent < 0.5short_move = m_zscore > 0 and _bb_percent < 0.5short_oil = o_zscore > 0 and _bb_percent < 0.5if show_ema if time >= startDateTime and time <= timenow //if m_zscore and v_zscore > 0 and %b <.05 then enter short if show_v and show_m and show_o if m_zscore > 0 and v_zscore > 0 and o_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) //open short position strategy.close("close long", when=long_all) //close all long positions else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) //open long position strategy.close("close short", when=short_all) //close all short positions else if show_m and show_v == false and show_o == false if m_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) strategy.close("close long", when=long_move) else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) strategy.close("close short", when=short_move) else if show_v and show_m == false and show_o == false if v_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) strategy.close("close long", when=long_vix) else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) strategy.close("close short", when=short_vix) else if show_o and show_v == false and show_m == false if o_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) strategy.close("close long", when=long_move) else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) strategy.close("close short", when=short_move) else if show_v and show_m and show_o == false if v_zscore > 0 and m_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) strategy.close("close long", when=long_vix) else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) strategy.close("close short", when=short_vix) else if show_v and show_o and show_m == false if v_zscore > 0 and o_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) strategy.close("close long", when=long_vix) else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) strategy.close("close short", when=short_vix) else if show_o and show_m and show_v == false if o_zscore > 0 and m_zscore > 0 and _bb_percent < 0.5 and close < s_ema //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) strategy.close("close long", when=long_vix) else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) strategy.close("close short", when=short_vix)else if time >= startDateTime and time <= timenow //if m_zscore and v_zscore > 0 and %b <.05 then enter short if show_v and show_m and show_o if m_zscore > 0 and v_zscore > 0 and o_zscore > 0 and _bb_percent < 0.5 //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) //open short position strategy.close("close long", when=long_all) //close all long positions else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) //open long position strategy.close("close short", when=short_all) //close all short positions else if show_m and show_v == false and show_o == false if m_zscore > 0 and _bb_percent < 0.5 //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) strategy.close("close long", when=long_move) else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) strategy.close("close short", when=short_move) else if show_v and show_m == false and show_o == false if v_zscore > 0 and _bb_percent < 0.5 //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) strategy.close("close long", when=long_vix) else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) strategy.close("close short", when=short_vix) else if show_o and show_v == false and show_m == false if o_zscore > 0 and _bb_percent < 0.5 //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) strategy.close("close long", when=long_move) else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) strategy.close("close short", when=short_move) else if show_v and show_m and show_o == false if v_zscore > 0 and m_zscore > 0 and _bb_percent < 0.5 //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) strategy.close("close long", when=long_vix) else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) strategy.close("close short", when=short_vix) else if show_v and show_o and show_m == false if v_zscore > 0 and o_zscore > 0 and _bb_percent < 0.5 //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) strategy.close("close long", when=long_vix) else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) strategy.close("close short", when=short_vix) else if show_o and show_m and show_v == false if o_zscore > 0 and m_zscore > 0 and _bb_percent < 0.5 //short strategy.entry("sell", strategy.short, 100, when=strategy.position_size > 0) strategy.close("close long", when=long_vix) else //long strategy.entry("buy", strategy.long, 100, when=strategy.position_size <= 0) strategy.close("close short", when=short_vix)