Pine Script v4 · Strategy
MZ SRSI Strategy V1.0
A Pine Script v4 strategy built on EMA (close, len), SMA or Linreg or EMA or WMA (sma(src, ceil(len / 2)), floor(len / 2) + 1) and Highest (dev, 10). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade is 5 contracts and pays 0.1 commission. 24 settings; defaults include From Month 1, From Day 1 and From Year 2021.
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 MZ SRSI Strategy V1.0 repaint?
- Yes
- At least one pattern in the source can repaint: intrabar recalculation.
- How did MZ SRSI Strategy V1.0 do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
- Can MZ SRSI Strategy V1.0 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 MZ SRSI Strategy V1.0 use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does MZ SRSI Strategy V1.0 run in Zeal Terminal?
- Yes
- It compiles in 55 ms and runs 1,000 bars in 97 ms, in the browser.
BTCUSDT · 1D · default settings
- HLine
- HLine
- frsi
- fsma
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.00
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Check
1 setting does nothing
“Show Date Range” is declared but never read.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Note
2 settings have no label
In the settings dialog TopBand (line 26), LowBand (line 27) show an empty name. The labels on this page come from the variable names.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
-
Note
Uses an argument v6 removed
when = on line 186, 187. The upgraded version below moves each call inside an if block.
-
Note
Uses long =, which v5 renamed line 186
long = on line 186. v5 writes it as direction = strategy.long or strategy.short.
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, heikinashi → ticker.heikinashi, ema → ta.ema, asin → math.asin, sqrt → math.sqrt, exp → math.exp, cos → math.cos, pow → math.pow, sma → ta.sma, ceil → math.ceil, floor → math.floor, linreg → ta.linreg, wma → ta.wma, highest → ta.highest, lowest → ta.lowest, avg → math.avg, round → math.round, stdev → ta.stdev, abs → math.abs, rsi → ta.rsi, crossover → ta.crossover, crossunder → ta.crossunder.
- 2 strategy calls use the when = argument (line 186, 187). 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 10: security → request.security
- Line 10: heikinashi → ticker.heikinashi
- Line 11: security → request.security
- Line 11: heikinashi → ticker.heikinashi
- Line 12: security → request.security
70 more edits
- Line 12: heikinashi → ticker.heikinashi
- Line 13: security → request.security
- Line 13: heikinashi → ticker.heikinashi
- Line 15: input(type = input.integer) → input.int()
- Line 16: input(type = input.integer) → input.int()
- Line 17: input(type = input.integer) → input.int()
- Line 18: input(type = input.integer) → input.int()
- Line 19: input(type = input.integer) → input.int()
- Line 20: input(type = input.integer) → input.int()
- Line 21: input(type = input.bool) → input.bool()
- Line 32: input(type = input.string) → input.string()
- Line 33: input(type = input.string) → input.string()
- Line 38: ema → ta.ema
- Line 39: ema → ta.ema
- Line 40: ema → ta.ema
- Line 43: input(type = input.integer) → input.int()
- Line 44: input(type = input.integer) → input.int()
- Line 51: input(type = input.integer) → input.int()
- Line 52: input(type = input.integer) → input.int()
- Line 56: asin → math.asin
- Line 57: sqrt → math.sqrt
- Line 58: exp → math.exp
- Line 59: cos → math.cos
- Line 61: pow → math.pow
- Line 67: asin → math.asin
- Line 69: exp → math.exp
- Line 70: cos → math.cos
- Line 71: pow → math.pow
- Line 74: pow → math.pow
- Line 79: type is reserved in v5: renamed type_
- Line 82: sma → ta.sma
- Line 82: sma → ta.sma
- Line 82: ceil → math.ceil
- Line 82: floor → math.floor
- Line 98: linreg → ta.linreg
- Line 100: sma → ta.sma
- Line 102: ema → ta.ema
- Line 104: ema → ta.ema
- Line 105: ema → ta.ema
- Line 107: ema → ta.ema
- Line 108: ema → ta.ema
- Line 108: ema → ta.ema
- Line 108: ema → ta.ema
- Line 110: wma → ta.wma
- Line 113: ema → ta.ema
- Line 115: highest → ta.highest
- Line 116: lowest → ta.lowest
- Line 117: avg → math.avg
- Line 119: wma → ta.wma
- Line 119: wma → ta.wma
- Line 119: wma → ta.wma
- Line 119: round → math.round
- Line 119: sqrt → math.sqrt
- Line 125: pow → math.pow
- Line 132: pow → math.pow
- Line 132: pow → math.pow
- Line 136: avg → math.avg
- Line 136: lowest → ta.lowest
- Line 136: highest → ta.highest
- Line 137: avg → math.avg
- Line 137: lowest → ta.lowest
- Line 137: highest → ta.highest
- Line 142: ema → ta.ema
- Line 142: pow → math.pow
- Line 155: stdev → ta.stdev
- Line 160: abs → math.abs
- Line 171: rsi → ta.rsi
- Line 178: crossover → ta.crossover
- Line 179: crossunder → ta.crossunder
- Line 186: long = true → direction = strategy.long
⋯// © MightyZinger-//@version=4+//@version=5strategy(shorttitle="MZ SRSI",title="MightyZinger SRSI Strategy", overlay=false, pyramiding=1, calc_on_order_fills=true, calc_on_every_tick=true, default_qty_type=strategy.fixed, default_qty_value=5,commission_value=0.1)⋯// === BASE FUNCTIONS ===-haClose = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, close) : close+haClose = UseHAcandles ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close) : close-haOpen = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, open) : open+haOpen = UseHAcandles ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open) : open-haHigh = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, high) : high+haHigh = UseHAcandles ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high) : high-haLow = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, low) : low+haLow = UseHAcandles ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low) : low//Backtest dates-fromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12)+fromMonth = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)-fromDay = input(defval = 1, title = "From Day", type = input.integer, minval = 1, maxval = 31)+fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)-fromYear = input(defval = 2021, title = "From Year", type = input.integer, minval = 1970)+fromYear = input.int(defval = 2021, title = "From Year", minval = 1970)-thruMonth = input(defval = 12, title = "Thru Month", type = input.integer, minval = 1, maxval = 12)+thruMonth = input.int(defval = 12, title = "Thru Month", minval = 1, maxval = 12)-thruDay = input(defval = 30, title = "Thru Day", type = input.integer, minval = 1, maxval = 31)+thruDay = input.int(defval = 30, title = "Thru Day", minval = 1, maxval = 31)-thruYear = input(defval = 2021, title = "Thru Year", type = input.integer, minval = 1970)+thruYear = input.int(defval = 2021, title = "Thru Year", minval = 1970)-showDate = input(defval = true, title = "Show Date Range", type = input.bool)+showDate = input.bool(defval = true, title = "Show Date Range")start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start window⋯//RSI Source-maType = input(title="MA Type", type=input.string, defval="LRC", options=["SMA","EMA","DEMA","TEMA","LRC","WMA","MF","VAMA","TMA","HMA", "JMA", "Kijun v2", "EDSMA","McGinley"])+maType = input.string(title="MA Type", defval="LRC", options=["SMA","EMA","DEMA","TEMA","LRC","WMA","MF","VAMA","TMA","HMA", "JMA", "Kijun v2", "EDSMA","McGinley"])-rsiMaType = input(title="RSI MA Type", type=input.string, defval="TMA", options=["SMA","EMA","DEMA","TEMA","LRC","WMA","MF","VAMA","TMA","HMA", "JMA", "Kijun v2", "EDSMA","McGinley"])+rsiMaType = input.string(title="RSI MA Type", defval="TMA", options=["SMA","EMA","DEMA","TEMA","LRC","WMA","MF","VAMA","TMA","HMA", "JMA", "Kijun v2", "EDSMA","McGinley"])//MA Function⋯tema(src, len) =>- ema1 = ema(src, len)+ ema1 = ta.ema(src, len)- ema2 = ema(ema1, len)+ ema2 = ta.ema(ema1, len)- ema3 = ema(ema2, len)+ ema3 = ta.ema(ema2, len) (3 * ema1) - (3 * ema2) + ema3kidiv = input(defval=1,maxval=4, title="Kijun MOD Divider")-jurik_phase = input(title="* Jurik (JMA) Only - Phase", type=input.integer, defval=3)+jurik_phase = input.int(title="* Jurik (JMA) Only - Phase", defval=3)-jurik_power = input(title="* Jurik (JMA) Only - Power", type=input.integer, defval=1)+jurik_power = input.int(title="* Jurik (JMA) Only - Power", defval=1)volatility_lookback = input(10, title="* Volatility Adjusted (VAMA) Only - Volatility lookback length")⋯//EDSMA-ssfLength = input(title="EDSMA - Super Smoother Filter Length", type=input.integer, minval=1, defval=20)+ssfLength = input.int(title="EDSMA - Super Smoother Filter Length", minval=1, defval=20)-ssfPoles = input(title="EDSMA - Super Smoother Filter Poles", type=input.integer, defval=2, options=[2, 3])+ssfPoles = input.int(title="EDSMA - Super Smoother Filter Poles", defval=2, options=[2, 3])//----⋯get2PoleSSF(src, length) =>- PI = 2 * asin(1)+ PI = 2 * math.asin(1)- arg = sqrt(2) * PI / length+ arg = math.sqrt(2) * PI / length- a1 = exp(-arg)+ a1 = math.exp(-arg)- b1 = 2 * a1 * cos(arg)+ b1 = 2 * a1 * math.cos(arg) c2 = b1- c3 = -pow(a1, 2)+ c3 = -math.pow(a1, 2) c1 = 1 - c2 - c3⋯get3PoleSSF(src, length) =>- PI = 2 * asin(1)+ PI = 2 * math.asin(1) arg = PI / length- a1 = exp(-arg)+ a1 = math.exp(-arg)- b1 = 2 * a1 * cos(1.738 * arg)+ b1 = 2 * a1 * math.cos(1.738 * arg)- c1 = pow(a1, 2)+ c1 = math.pow(a1, 2) coef2 = b1 + c1 coef3 = -(c1 + b1 * c1)- coef4 = pow(c1, 2)+ coef4 = math.pow(c1, 2) coef1 = 1 - coef2 - coef3 - coef4⋯// MA Main function-ma(type, src, len) =>+ma(type_, src, len) => float result = 0- if type=="TMA"+ if type_=="TMA"- result := sma(sma(src, ceil(len / 2)), floor(len / 2) + 1)+ result := ta.sma(ta.sma(src, math.ceil(len / 2)), math.floor(len / 2) + 1)- if type=="MF"+ if type_=="MF" ts=0.,b=0.,c=0.,os=0.⋯ result := ts- if type=="LRC"+ if type_=="LRC"- result := linreg(src, len, 0)+ result := ta.linreg(src, len, 0)- if type=="SMA" // Simple+ if type_=="SMA" // Simple- result := sma(src, len)+ result := ta.sma(src, len)- if type=="EMA" // Exponential+ if type_=="EMA" // Exponential- result := ema(src, len)+ result := ta.ema(src, len)- if type=="DEMA" // Double Exponential+ if type_=="DEMA" // Double Exponential- e = ema(src, len)+ e = ta.ema(src, len)- result := 2 * e - ema(e, len)+ result := 2 * e - ta.ema(e, len)- if type=="TEMA" // Triple Exponential+ if type_=="TEMA" // Triple Exponential- e = ema(src, len)+ e = ta.ema(src, len)- result := 3 * (e - ema(e, len)) + ema(ema(e, len), len)+ result := 3 * (e - ta.ema(e, len)) + ta.ema(ta.ema(e, len), len)- if type=="WMA" // Weighted+ if type_=="WMA" // Weighted- result := wma(src, len)+ result := ta.wma(src, len)- if type=="VAMA" // Volatility Adjusted+ if type_=="VAMA" // Volatility Adjusted /// Copyright © 2019 to present, Joris Duyck (JD)- mid=ema(src,len)+ mid=ta.ema(src,len) dev=src-mid- vol_up=highest(dev,volatility_lookback)+ vol_up=ta.highest(dev,volatility_lookback)- vol_down=lowest(dev,volatility_lookback)+ vol_down=ta.lowest(dev,volatility_lookback)- result := mid+avg(vol_up,vol_down)+ result := mid+math.avg(vol_up,vol_down)- if type=="HMA" // Hull+ if type_=="HMA" // Hull- result := wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len)))+ result := ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len)))- if type=="JMA" // Jurik+ if type_=="JMA" // Jurik /// Copyright © 2018 Alex Orekhov (everget)⋯ beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2)- alpha = pow(beta, jurik_power)+ alpha = math.pow(beta, jurik_power) jma = 0.0⋯ e2 = 0.0- e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * pow(1 - alpha, 2) + pow(alpha, 2) * nz(e2[1])+ e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(e2[1]) jma := e2 + nz(jma[1]) result := jma- if type=="Kijun v2"+ if type_=="Kijun v2"- kijun = avg(lowest(len), highest(len))//, (open + close)/2)+ kijun = math.avg(ta.lowest(len), ta.highest(len))//, (open + close)/2)- conversionLine = avg(lowest(len/kidiv), highest(len/kidiv))+ conversionLine = math.avg(ta.lowest(len/kidiv), ta.highest(len/kidiv)) delta = (kijun + conversionLine)/2 result :=delta- if type=="McGinley"+ if type_=="McGinley" mg = 0.0- mg := na(mg[1]) ? ema(src, len) : mg[1] + (src - mg[1]) / (len * pow(src/mg[1], 4))+ mg := na(mg[1]) ? ta.ema(src, len) : mg[1] + (src - mg[1]) / (len * math.pow(src/mg[1], 4)) result :=mg- if type=="EDSMA"+ if type_=="EDSMA" ⋯ // Rescale filter in terms of Standard Deviations- stdev = stdev(ssf, len)+ stdev = ta.stdev(ssf, len) scaledFilter = stdev != 0⋯ - alpha = 5 * abs(scaledFilter) / len+ alpha = 5 * math.abs(scaledFilter) / len ⋯rsiSource = ma(maType, src , lengthMA)-frsi = rsi(rsiSource, lengthRSI)+frsi = ta.rsi(rsiSource, lengthRSI)fsma = ma(rsiMaType, frsi , lengthRSI_MA)⋯bgcolor(frsi > fsma ? color.lime : color.orange, 80)-longcondition = crossover (frsi , fsma)+longcondition = ta.crossover (frsi , fsma)-shortcondition = crossunder(frsi , fsma)+shortcondition = ta.crossunder(frsi , fsma)////////////////////////////////⋯// strategy.close("SELL", strategy.short, when = window())-strategy.entry(id="long", long = true, when = longcondition and window())+strategy.entry(id="long", direction = strategy.long, when = longcondition and window())strategy.close("long", when = shortcondition and window())Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 6: input() → input.bool()
- Line 25: input() → input.source()
- Line 26: input() → input.int()
- Line 27: input() → input.int()
- Line 28: input() → input.int()
- Line 29: input() → input.int()
8 more edits
- Line 30: input() → input.int()
- Line 42: input() → input.int()
- Line 45: input() → input.int()
- Line 47: input() → input.float()
- Line 48: input() → input.bool()
- Line 49: input() → input.float()
- Line 186: when = longcondition and window() → if block
- Line 187: when = shortcondition and window() → if block
⋯//heiking ashi calculation-UseHAcandles = input(true, title="Use Heikin Ashi Candles in Algo Calculations")+UseHAcandles = input.bool(true, title="Use Heikin Ashi Candles in Algo Calculations")////⋯window() => time >= start and time <= finish ? true : false // create function "within window of time"-src = UseHAcandles ? haClose : input(close, title="Source")+src = UseHAcandles ? haClose : input.source(close, title="Source")-TopBand = input(80, step=0.01)+TopBand = input.int(80, step=0.01)-LowBand = input(20, step=0.01)+LowBand = input.int(20, step=0.01)-lengthRSI = input(2, minval=1,title="RSI Length")+lengthRSI = input.int(2, minval=1,title="RSI Length")-lengthMA = input(50, minval=1,title="MA Length")+lengthMA = input.int(50, minval=1,title="MA Length")-lengthRSI_MA= input(5, minval=1,title="RSI MA Length")+lengthRSI_MA= input.int(5, minval=1,title="RSI MA Length")//RSI Source⋯ (3 * ema1) - (3 * ema2) + ema3-kidiv = input(defval=1,maxval=4, title="Kijun MOD Divider")+kidiv = input.int(defval=1,maxval=4, title="Kijun MOD Divider")jurik_phase = input.int(title="* Jurik (JMA) Only - Phase", defval=3)jurik_power = input.int(title="* Jurik (JMA) Only - Power", defval=1)-volatility_lookback = input(10, title="* Volatility Adjusted (VAMA) Only - Volatility lookback length")+volatility_lookback = input.int(10, title="* Volatility Adjusted (VAMA) Only - Volatility lookback length")// MF-beta = input(0.8,minval=0,maxval=1,step=0.1, title="Modular Filter, General Filter Only - Beta")+beta = input.float(0.8,minval=0,maxval=1,step=0.1, title="Modular Filter, General Filter Only - Beta")-feedback = input(false, title="Modular Filter Only - Feedback")+feedback = input.bool(false, title="Modular Filter Only - Feedback")-z = input(0.5,title="Modular Filter Only - Feedback Weighting",step=0.1, minval=0, maxval=1)+z = input.float(0.5,title="Modular Filter Only - Feedback Weighting",step=0.1, minval=0, maxval=1)//EDSMA⋯// strategy.close("SELL", strategy.short, when = window())-strategy.entry(id="long", direction = strategy.long, when = longcondition and window())+if longcondition and window()+ strategy.entry(id="long", direction = strategy.long)-strategy.close("long", when = shortcondition and window())+if shortcondition and window()+ strategy.close("long")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.
⋯// © MightyZinger-//@version=5+//@version=6strategy(shorttitle="MZ SRSI",title="MightyZinger SRSI Strategy", overlay=false, pyramiding=1, calc_on_order_fills=true, calc_on_every_tick=true, default_qty_type=strategy.fixed, default_qty_value=5,commission_value=0.1)⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Use Heikin Ashi Candles in Algo Calculations | true | bool | haClose haOpen haHigh haLow src |
| From Month | 1 | int (written input.integer) · min 1 · max 12 | start |
| From Day | 1 | int (written input.integer) · min 1 · max 31 | start |
| From Year | 2021 | int (written input.integer) · min 1970 | start |
| Thru Month | 12 | int (written input.integer) · min 1 · max 12 | finish |
| Thru Day | 30 | int (written input.integer) · min 1 · max 31 | finish |
| Thru Year | 2021 | int (written input.integer) · min 1970 | finish |
| Show Date Range | true | bool | unused |
| Source | close | source | ema1 result a e mid dev e0 e1 mg zeros edsma rsiSource ssf |
| Top Band (no label in the script) | 80 | int · step 0.01 | hline |
| Low Band (no label in the script) | 20 | int · step 0.01 | hline |
| RSI Length | 2 | int · min 1 | frsi |
| MA Length | 50 | int · min 1 | rsiSource |
| RSI MA Length | 5 | int · min 1 | fsma |
| MA Type | LRC | string · options ["SMA","EMA","DEMA","TEMA","LRC","WMA","MF","VAMA","TMA","HMA", "JMA", "Kijun v2", "EDSMA","McGinley"] | rsiSource |
| RSI MA Type | TMA | string · options ["SMA","EMA","DEMA","TEMA","LRC","WMA","MF","VAMA","TMA","HMA", "JMA", "Kijun v2", "EDSMA","McGinley"] | fsma |
| Kijun MOD Divider | 1 | int · max 4 | conversionLine |
| * Jurik (JMA) Only - Phase | 3 | int (written input.integer) | phaseRatio |
| * Jurik (JMA) Only - Power | 1 | int (written input.integer) | alpha |
| * Volatility Adjusted (VAMA) Only - Volatility lookback length | 10 | int | vol_up vol_down |
| Modular Filter Only - Feedback | false | bool | a |
| Modular Filter Only - Feedback Weighting | 0.5 | float · min 0 · max 1 · step 0.1 | a |
| EDSMA - Super Smoother Filter Length | 20 | int (written input.integer) · min 1 | ssf |
| EDSMA - Super Smoother Filter Poles | 2 | int (written input.integer) · options [2, 3] | ssf |
What it calculates
- EMA (
ema,ta.emain v5)Source (close), lenema1 · line 38 - EMA (
ema,ta.emain v5)ema1, lenema2 · line 39 - EMA (
ema,ta.emain v5)ema2, lenema3 · line 40 - SMA / Linreg / EMA / WMA (
sma,ta.smain v5)sma(src, ceil(len / 2)), floor(len / 2) + 1result · line 82 - EMA (
ema,ta.emain v5)Source (close), lene · line 107 - EMA (
ema,ta.emain v5)Source (close), lenmid · line 113 - Highest (
highest,ta.highestin v5)dev, * Volatility Adjusted (VAMA) Only - Volatility lookback length (10)vol_up · line 115 - Lowest (
lowest,ta.lowestin v5)dev, * Volatility Adjusted (VAMA) Only - Volatility lookback length (10)vol_down · line 116 - Lowest / Highest (
lowest,ta.lowestin v5)lenkijun · line 136 - Lowest / Highest (
lowest,ta.lowestin v5)len/kidivconversionLine · line 137 - EMA (
ema,ta.emain v5)Source (close), lenmg · line 142 - Stdev (
stdev,ta.stdevin v5)ssf, lenstdev · line 155 - RSI (
rsi,ta.rsiin v5)rsiSource, RSI Length (2)frsi · line 171 - Crossover (
crossover,ta.crossoverin v5)frsi, fsmalongcondition · line 178 - Crossunder (
crossunder,ta.crossunderin v5)frsi, fsmashortcondition · line 179
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.
The script has 80 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open long long | longcondition and window() | On | 186 |
| Close long | shortcondition and window() | On | 187 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
Yes
At least one pattern in the source can repaint; it is marked Check below.
- ClearHigher-timeframe data4 security call(s), none with lookahead on.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- CheckIntrabar recalculationcalc_on_every_tick = true. Live values can differ from history.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
Higher-timeframe data for request.security(): heikinashi:SYMBOL D (Binance BTCUSDT 1d, as Heikin-Ashi by the engine), heikinashi:BINANCE:BTCUSDT D (Binance BTCUSDT 1d, as Heikin-Ashi by the engine), fetched from Binance's public market data for each market.
Backtests are simulations on historical data and are not investment advice.
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| MZ SRSI Strategy V1.0 this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| BTC 15 min by RafaelZioni | sma ema rsi wma linreg stdev highest lowest | v4 strategy | −25.7% | 119 | 38.9% |
| VixFixLinReg-Strategy by Trendoscope | highest stdev sma lowest linreg | v4 strategy | −49.3% | 12 | 51.1% |
| Crunchster's Turtle and Trend System by Crunchster1 | lowest highest ema stdev sma | v5 strategy | +18.0% | 31 | 16.7% |
| sma RSI & sudden buy and sell Strategy v1 by samwillington | ema rsi highest lowest sma | v5 strategy | +7.6% | 15 | 3.7% |
| Swing Multi Moving Averages Crypto and Stocks Strategy by exlux99 | ema wma highest lowest sma | v5 strategy | +60.2% | 22 | 13.1% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 55 ms | With a workaround 1,000 bars in 97 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 186) so the engine trades the way the script says. 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. Data the page supplies at the chart's own timeframe (another symbol, or Heikin-Ashi) reaches the script one bar later in Zeal Terminal's engine than on TradingView.
“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/// © MightyZinger//@version=4strategy(shorttitle="MZ SRSI",title="MightyZinger SRSI Strategy", overlay=false, pyramiding=1, calc_on_order_fills=true, calc_on_every_tick=true, default_qty_type=strategy.fixed, default_qty_value=5,commission_value=0.1)//heiking ashi calculationUseHAcandles = input(true, title="Use Heikin Ashi Candles in Algo Calculations")////// === /INPUTS ===// === BASE FUNCTIONS ===haClose = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, close) : closehaOpen = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, open) : openhaHigh = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, high) : highhaLow = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, low) : low//Backtest datesfromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12)fromDay = input(defval = 1, title = "From Day", type = input.integer, minval = 1, maxval = 31)fromYear = input(defval = 2021, title = "From Year", type = input.integer, minval = 1970)thruMonth = input(defval = 12, title = "Thru Month", type = input.integer, minval = 1, maxval = 12)thruDay = input(defval = 30, title = "Thru Day", type = input.integer, minval = 1, maxval = 31)thruYear = input(defval = 2021, title = "Thru Year", type = input.integer, minval = 1970)showDate = input(defval = true, title = "Show Date Range", type = input.bool)start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start windowfinish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish windowwindow() => time >= start and time <= finish ? true : false // create function "within window of time"src = UseHAcandles ? haClose : input(close, title="Source")TopBand = input(80, step=0.01)LowBand = input(20, step=0.01)lengthRSI = input(2, minval=1,title="RSI Length")lengthMA = input(50, minval=1,title="MA Length")lengthRSI_MA= input(5, minval=1,title="RSI MA Length")//RSI SourcemaType = input(title="MA Type", type=input.string, defval="LRC", options=["SMA","EMA","DEMA","TEMA","LRC","WMA","MF","VAMA","TMA","HMA", "JMA", "Kijun v2", "EDSMA","McGinley"])rsiMaType = input(title="RSI MA Type", type=input.string, defval="TMA", options=["SMA","EMA","DEMA","TEMA","LRC","WMA","MF","VAMA","TMA","HMA", "JMA", "Kijun v2", "EDSMA","McGinley"])//MA Function// Pre-reqs//tema(src, len) => ema1 = ema(src, len) ema2 = ema(ema1, len) ema3 = ema(ema2, len) (3 * ema1) - (3 * ema2) + ema3kidiv = input(defval=1,maxval=4, title="Kijun MOD Divider")jurik_phase = input(title="* Jurik (JMA) Only - Phase", type=input.integer, defval=3)jurik_power = input(title="* Jurik (JMA) Only - Power", type=input.integer, defval=1)volatility_lookback = input(10, title="* Volatility Adjusted (VAMA) Only - Volatility lookback length")// MFbeta = input(0.8,minval=0,maxval=1,step=0.1, title="Modular Filter, General Filter Only - Beta")feedback = input(false, title="Modular Filter Only - Feedback")z = input(0.5,title="Modular Filter Only - Feedback Weighting",step=0.1, minval=0, maxval=1)//EDSMAssfLength = input(title="EDSMA - Super Smoother Filter Length", type=input.integer, minval=1, defval=20)ssfPoles = input(title="EDSMA - Super Smoother Filter Poles", type=input.integer, defval=2, options=[2, 3])//----// EDSMAget2PoleSSF(src, length) => PI = 2 * asin(1) arg = sqrt(2) * PI / length a1 = exp(-arg) b1 = 2 * a1 * cos(arg) c2 = b1 c3 = -pow(a1, 2) c1 = 1 - c2 - c3 ssf = 0.0 ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2])get3PoleSSF(src, length) => PI = 2 * asin(1) arg = PI / length a1 = exp(-arg) b1 = 2 * a1 * cos(1.738 * arg) c1 = pow(a1, 2) coef2 = b1 + c1 coef3 = -(c1 + b1 * c1) coef4 = pow(c1, 2) coef1 = 1 - coef2 - coef3 - coef4 ssf = 0.0 ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3])// MA Main functionma(type, src, len) => float result = 0 if type=="TMA" result := sma(sma(src, ceil(len / 2)), floor(len / 2) + 1) if type=="MF" ts=0.,b=0.,c=0.,os=0. //---- alpha = 2/(len+1) a = feedback ? z*src + (1-z)*nz(ts[1],src) : src //---- b := a > alpha*a+(1-alpha)*nz(b[1],a) ? a : alpha*a+(1-alpha)*nz(b[1],a) c := a < alpha*a+(1-alpha)*nz(c[1],a) ? a : alpha*a+(1-alpha)*nz(c[1],a) os := a == b ? 1 : a == c ? 0 : os[1] //---- upper = beta*b+(1-beta)*c lower = beta*c+(1-beta)*b ts := os*upper+(1-os)*lower result := ts if type=="LRC" result := linreg(src, len, 0) if type=="SMA" // Simple result := sma(src, len) if type=="EMA" // Exponential result := ema(src, len) if type=="DEMA" // Double Exponential e = ema(src, len) result := 2 * e - ema(e, len) if type=="TEMA" // Triple Exponential e = ema(src, len) result := 3 * (e - ema(e, len)) + ema(ema(e, len), len) if type=="WMA" // Weighted result := wma(src, len) if type=="VAMA" // Volatility Adjusted /// Copyright © 2019 to present, Joris Duyck (JD) mid=ema(src,len) dev=src-mid vol_up=highest(dev,volatility_lookback) vol_down=lowest(dev,volatility_lookback) result := mid+avg(vol_up,vol_down) if type=="HMA" // Hull result := wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len))) if type=="JMA" // Jurik /// Copyright © 2018 Alex Orekhov (everget) /// Copyright © 2017 Jurik Research and Consulting. phaseRatio = jurik_phase < -100 ? 0.5 : jurik_phase > 100 ? 2.5 : jurik_phase / 100 + 1.5 beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2) alpha = pow(beta, jurik_power) jma = 0.0 e0 = 0.0 e0 := (1 - alpha) * src + alpha * nz(e0[1]) e1 = 0.0 e1 := (src - e0) * (1 - beta) + beta * nz(e1[1]) e2 = 0.0 e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * pow(1 - alpha, 2) + pow(alpha, 2) * nz(e2[1]) jma := e2 + nz(jma[1]) result := jma if type=="Kijun v2" kijun = avg(lowest(len), highest(len))//, (open + close)/2) conversionLine = avg(lowest(len/kidiv), highest(len/kidiv)) delta = (kijun + conversionLine)/2 result :=delta if type=="McGinley" mg = 0.0 mg := na(mg[1]) ? ema(src, len) : mg[1] + (src - mg[1]) / (len * pow(src/mg[1], 4)) result :=mg if type=="EDSMA" zeros = src - nz(src[2]) avgZeros = (zeros + zeros[1]) / 2 // Ehlers Super Smoother Filter ssf = ssfPoles == 2 ? get2PoleSSF(avgZeros, ssfLength) : get3PoleSSF(avgZeros, ssfLength) // Rescale filter in terms of Standard Deviations stdev = stdev(ssf, len) scaledFilter = stdev != 0 ? ssf / stdev : 0 alpha = 5 * abs(scaledFilter) / len edsma = 0.0 edsma := alpha * src + (1 - alpha) * nz(edsma[1]) result := edsma result//Indicatorhline(TopBand, color=color.red,linestyle=hline.style_dotted, linewidth=2)hline(LowBand, color=color.green, linestyle=hline.style_dashed, linewidth=2)// RSI DefinitionrsiSource = ma(maType, src , lengthMA)frsi = rsi(rsiSource, lengthRSI)fsma = ma(rsiMaType, frsi , lengthRSI_MA)plot(frsi,title='frsi', color= color.lime, linewidth=3)fsmaColor=color.new(color.red, 80)plot(fsma,title='fsma', color= fsmaColor , linewidth=3, style=plot.style_area)//Backgroundbgcolor(frsi > fsma ? color.lime : color.orange, 80)longcondition = crossover (frsi , fsma)shortcondition = crossunder(frsi , fsma)//////////////////////////////////if (longcondition)// strategy.entry("BUY", strategy.long, when = window()) //if (shortcondition)// strategy.close("SELL", strategy.short, when = window())strategy.entry(id="long", long = true, when = longcondition and window())strategy.close("long", when = shortcondition and window())