Zeal Terminal Open in Zeal Terminal

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
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctHLine$4,389,040$202,527Equity from $100,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. 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. The live re-run is not offered here: the script requests TVC:MOVE D, VIX D, VVIX D, CBOE:OVX D, TVC:USOIL D, which this page cannot load in your browser.

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 verified

Neither 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 verified

Neither 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.

SettingDefaultType and rangeFeeds
Length (no label in the script)266intm_basis m_zscore o_basis o_zscore v_basis v_zscore
VIX Z Std Dev2.0floathline
MOVE Z Std Dev2.0floathline
Show MOVEtrueboolplot 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 VIXtrueboolplot 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 Voltrueboolplot 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 EMAtrueboolline 72
EMA Length100ints_ema
BB mult2float_bb_mid _bb_hig _bb_low
BB mean range20int (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")timeline 73 line 125

What it calculates

  • BB (bb, ta.bb in v5)close, BB mean range (20), BB mult (2)_bb_mid · line 29
  • BB (bb, ta.bb in v5)close, BB mean range (20), BB mult (2)_bb_hig · line 29
  • BB (bb, ta.bb in v5)close, BB mean range (20), BB mult (2)_bb_low · line 29
  • EMA (ema, ta.ema in v5)close, EMA Length (100)s_ema · line 31
  • SMA (sma, ta.sma in v5)divM, Length (266)m_basis · line 36
  • Stdev (stdev, ta.stdev in v5)divM, Length (266)m_zscore · line 37
  • SMA (sma, ta.sma in v5)divO, Length (266)o_basis · line 40
  • Stdev (stdev, ta.stdev in v5)divO, Length (266)o_zscore · line 41
  • SMA (sma, ta.sma in v5)divV, Length (266)v_basis · line 56
  • Stdev (stdev, ta.stdev in 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.

closecloseprice data_bb_rangeBB mean rangesetting · 20_bb_multBB multsetting · 2l_emaEMA Lengthsetting · 100LengthLengthsetting · 266m_StdDevsMOVE Z Std Devsetting · 2.0v_StdDevsVIX Z Std Devsetting · 2.0_bb_midBB→ _bb_mid_bb_higBB→ _bb_hig_bb_lowBB→ _bb_lows_emaEMA→ s_emam_basisSMA→ m_basism_zscoreStdev→ m_zscoreo_basisSMA→ o_basiso_zscoreStdev→ o_zscorev_basisSMA→ v_basisv_zscoreStdev→ v_zscoreMOVE, VIX, VVIX, OILVIX, USOMOVE · VIX +35 values_bb_percent_bb_percentvalueiVIXiVIXvaluedivMdivMvalueiOILVIXiOILVIXvaluedivOdivOvalueuse_buse_bvaluedivVdivVvaluelong_all, short_alllong_all · short_all2 valueslong_vixlong_vixconditionlong_movelong_moveconditionshort_vixshort_vixconditionshort_moveshort_moveconditionlong_oil, short_oillong_oil · short_oil2 conditionso_color, ob_color, m_color, mb_color, v_colorColouro_color · ob_color +3entry:sellOpen sellstrategy.entryclose:close longClose close longstrategy.closeentry:buyOpen buystrategy.entryclose:close shortClose close shortstrategy.closeplot:42plotplotplot:43plotplothline:45hlinehlinehline:46hlinehlinebgcolor:52bgcolorbgcolorbgcolor:53bgcolorbgcolorplot:58plotplothline:59hlinehlinehline:60hlinehlinebgcolor:62bgcolorbgcolor

Order rules

OrderFires whenBy defaultLine
Open sell shortstrategy.position_size > 0On77
Close close longlong_allOn78
Open buy longstrategy.position_size <= 0On80
Close close shortshort_allOn81
Open sell shortstrategy.position_size > 0On84
Close close longlong_movem_zscore < 0 and _bb_percent > 0.5On85
Open buy longstrategy.position_size <= 0On87
Close close shortshort_movem_zscore > 0 and _bb_percent < 0.5On88
Open sell shortstrategy.position_size > 0On91
Close close longlong_vixv_zscore < 0 and _bb_percent > 0.5On92
Open buy longstrategy.position_size <= 0On94
Close close shortshort_vixv_zscore > 0 and _bb_percent < 0.5On95
Open sell shortstrategy.position_size > 0On98
Close close longlong_movem_zscore < 0 and _bb_percent > 0.5On99
Open buy longstrategy.position_size <= 0On101
Close close shortshort_movem_zscore > 0 and _bb_percent < 0.5On102
Open sell shortstrategy.position_size > 0On105
Close close longlong_vixv_zscore < 0 and _bb_percent > 0.5On106
Open buy longstrategy.position_size <= 0On108
Close close shortshort_vixv_zscore > 0 and _bb_percent < 0.5On109
Open sell shortstrategy.position_size > 0On112
Close close longlong_vixv_zscore < 0 and _bb_percent > 0.5On113
Open buy longstrategy.position_size <= 0On115
Close close shortshort_vixv_zscore > 0 and _bb_percent < 0.5On116
Open sell shortstrategy.position_size > 0On119
Close close longlong_vixv_zscore < 0 and _bb_percent > 0.5On120
Open buy longstrategy.position_size <= 0On122
Close close shortshort_vixv_zscore > 0 and _bb_percent < 0.5On123
Open sell shortstrategy.position_size > 0On129
Close close longlong_allOn130
Open buy longstrategy.position_size <= 0On132
Close close shortshort_allOn133
Open sell shortstrategy.position_size > 0On136
Close close longlong_movem_zscore < 0 and _bb_percent > 0.5On137
Open buy longstrategy.position_size <= 0On139
Close close shortshort_movem_zscore > 0 and _bb_percent < 0.5On140
Open sell shortstrategy.position_size > 0On143
Close close longlong_vixv_zscore < 0 and _bb_percent > 0.5On144
Open buy longstrategy.position_size <= 0On146
Close close shortshort_vixv_zscore > 0 and _bb_percent < 0.5On147
Open sell shortstrategy.position_size > 0On150
Close close longlong_movem_zscore < 0 and _bb_percent > 0.5On151
Open buy longstrategy.position_size <= 0On153
Close close shortshort_movem_zscore > 0 and _bb_percent < 0.5On154
Open sell shortstrategy.position_size > 0On157
Close close longlong_vixv_zscore < 0 and _bb_percent > 0.5On158
Open buy longstrategy.position_size <= 0On160
Close close shortshort_vixv_zscore > 0 and _bb_percent < 0.5On161
Open sell shortstrategy.position_size > 0On164
Close close longlong_vixv_zscore < 0 and _bb_percent > 0.5On165
Open buy longstrategy.position_size <= 0On167
Close close shortshort_vixv_zscore > 0 and _bb_percent < 0.5On168
Open sell shortstrategy.position_size > 0On171
Close close longlong_vixv_zscore < 0 and _bb_percent > 0.5On172
Open buy longstrategy.position_size <= 0On174
Close close shortshort_vixv_zscore > 0 and _bb_percent < 0.5On175

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • 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.

ScriptSharesTypeNetTradesMax drawdown
Strategy- Combo Z Score this page—v4 strategy0.0%042.9%
Strategy Oil Z Score by jroche1973bb ema sma stdevv4 strategyNo trades on this market
Volume Weighted Bollinger Bands Strategy by Ankit_1618ema sma stdevv4 strategy+10.0%1527.5%
BB21_MA200_Strategy by mohaneeema sma stdevv4 strategyNo trades on this market
Super Breakout day trading by beststockalertstdev sma emav4 strategyNo trades on this market
Super Auto Breakout Day Trade Volatile stocks by beststockalertstdev sma emav4 strategy−6.1%5129.1%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 71 msWith a workaround 1,000 bars in 97 msNot measured
PineTSNo 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)