Zeal Terminal Open in Zeal Terminal

Pine Script v3 · Strategy

Legacy

McClellan Oscillator Strategy

A Pine Script v3 strategy built on EMA (rana, 16), SMA (x, length) and Stdev (x, length). It has 5 order rules, 4 entries among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays no commission. 29 settings; defaults include RANA ratio multiplier 1000, Slow Length Sell 20 and Fast Length Sell 9.

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 McClellan Oscillator Strategy repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did McClellan Oscillator Strategy 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 entry conditions never all held on this data. It closed no trades on the other markets either. A backtest, not investment advice.
Can McClellan Oscillator Strategy 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.
What alerts does McClellan Oscillator Strategy have?
2
McC long ; McC short .
Does McClellan Oscillator Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.

BTCUSDT · 1D · default settings

  • 0
  • -
  • +
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct0$100,000$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 ADVN.NY D, ADVN.NQ D, ADVN.US D, ADVN.DJ D, ADVN.AX D, ADVN.AM D, DECL.NY D, DECL.NQ D, DECL.US D, DECL.DJ D, DECL.AX D, DECL.AM D, VXX D, VVIX D, MMOH D, MMFI D, SKEW D, VX1! D, VX2! D, VIX D, IWM D, which this page cannot load in your browser.

Needs ADVN.NY D data, not available: not a Binance spot market Needs ADVN.NQ D data, not available: not a Binance spot market Needs ADVN.US D data, not available: not a Binance spot market Needs ADVN.DJ D data, not available: not a Binance spot market Needs ADVN.AX D data, not available: not a Binance spot market Needs ADVN.AM D data, not available: not a Binance spot market Needs DECL.NY D data, not available: not a Binance spot market Needs DECL.NQ D data, not available: not a Binance spot market Needs DECL.US D data, not available: not a Binance spot market Needs DECL.DJ D data, not available: not a Binance spot market Needs DECL.AX D data, not available: not a Binance spot market Needs DECL.AM D data, not available: not a Binance spot market Needs VXX D data, not available: not a Binance spot market Needs VVIX D data, not available: not a Binance spot market Needs MMOH D data, not available: not a Binance spot market Needs MMFI D data, not available: not a Binance spot market Needs SKEW D data, not available: not a Binance spot market Needs VX1! D data, not available: not a Binance spot market Needs VX2! D data, not available: not a Binance spot market Needs VIX D data, not available: not a Binance spot market Needs IWM 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
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

    3 settings do nothing

    “Exit when oscillator goes under 0?”, “Enter when oscillator goes over 0?”, “Only sell when percent of X stocks is in downtrend” are declared but never read.

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

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    1 setting has no label

    In the settings dialog iwmma12 (line 91) 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.

Upgrade and export

Written in Pine Script v3. The upgrade to v5 takes 2 steps, 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, ema → ta.ema, sma → ta.sma, stdev → ta.stdev, crossunder → ta.crossunder, crossover → ta.crossover.
  • Colours are bare names (white, black, blue, red, green, orange, yellow); v4 spells them color.white, color.black, color.blue, color.red, color.green, color.orange, color.yellow.

v3 → v4

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 3: //@version=3 → //@version=4
  • Line 16: resolution → input.resolution
  • Line 16: period → timeframe.period
  • Line 37: area → plot.style_area
  • Line 37: white → color.white
  • Line 38: area → plot.style_area
14 more edits
  • Line 38: white → color.white
  • Line 39: line → plot.style_line
  • Line 39: black → color.black
  • Line 40: blue → color.blue
  • Line 41: red → color.red
  • Line 44: green → color.green
  • Line 44: red → color.red
  • Line 44: white → color.white
  • Line 53: blue → color.blue
  • Line 54: orange → color.orange
  • Line 55: red → color.red
  • Line 56: black → color.black
  • Line 88: orange → color.orange
  • Line 89: yellow → color.yellow
⋯// © sparrow_hawk_737-//@version=3+//@version=4strategy("McClellan Oscillator Strategy", default_qty_type=strategy.percent_of_equity, default_qty_value=100)⋯useCTF=input(false, title="Use Custom Timeframe?"), -tf=useCTF?input("D", type=resolution, title="Custom Timeframe"):period // Recommend NOT enabling this+tf=useCTF?input("D", type=input.resolution, title="Custom Timeframe"):timeframe.period // Recommend NOT enabling thisgaps=barmerge.gaps_off // Recommend leaving this OFF⋯hline(0, title="0")-plot(showOsc?mo<0?mo:0:na, style=area, color=white, title="-")+plot(showOsc?mo<0?mo:0:na, style=plot.style_area, color=color.white, title="-")-plot(showOsc?mo>=0?mo:0:na, style=area, color=white, title="+")+plot(showOsc?mo>=0?mo:0:na, style=plot.style_area, color=color.white, title="+")-plot(showOsc?mo:na, style=line, color=black, title="MO", linewidth=2)+plot(showOsc?mo:na, style=plot.style_line, color=color.black, title="MO", linewidth=2)-plot(showEMAs?e1:na, color=blue, linewidth=2, title="19 EMA")+plot(showEMAs?e1:na, color=color.blue, linewidth=2, title="19 EMA")-plot(showEMAs?e2:na, color=red, linewidth=2, title="39 EMA")+plot(showEMAs?e2:na, color=color.red, linewidth=2, title="39 EMA")short= mo>=100 and mo<mo[1]long= mo<=-100 and mo>mo[1]-bgcolor(long ? green : short ? red : white, transp=75)+bgcolor(long ? color.green : short ? color.red : color.white, transp=75)alertcondition(long and not long[1], "McC long ", "McC long ")⋯mab2 = ema(mo, slowLengthBuy)-plot(mas1, color=blue, linewidth=2, title="39 EMA")+plot(mas1, color=color.blue, linewidth=2, title="39 EMA")-plot(mas2, color=orange, linewidth=2, title="39 EMA")+plot(mas2, color=color.orange, linewidth=2, title="39 EMA")-plot(mab1, color=red, linewidth=2, title="39 EMA")+plot(mab1, color=color.red, linewidth=2, title="39 EMA")-plot(mab2, color=black, linewidth=2, title="39 EMA")+plot(mab2, color=color.black, linewidth=2, title="39 EMA")get_bbr(x, length) => ⋯rysell = roll_yield <= 0.01-plot(roll_yield * 100, color=orange, linewidth=2,title="ROLL YIELD")+plot(roll_yield * 100, color=color.orange, linewidth=2,title="ROLL YIELD")-plot(shape * 10, color=yellow, linewidth=2,title="VIX SHAPE")+plot(shape * 10, color=color.yellow, linewidth=2,title="VIX SHAPE")iwm = security("IWM", "", close)⋯

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 16: input(type = input.resolution) → input.timeframe()
  • Line 28: security → request.security
  • Line 28: security → request.security
  • Line 28: security → request.security
  • Line 28: security → request.security
33 more edits
  • Line 28: security → request.security
  • Line 28: security → request.security
  • Line 29: security → request.security
  • Line 29: security → request.security
  • Line 29: security → request.security
  • Line 29: security → request.security
  • Line 29: security → request.security
  • Line 29: security → request.security
  • Line 34: ema → ta.ema
  • Line 34: ema → ta.ema
  • Line 34: ema → ta.ema
  • Line 34: ema → ta.ema
  • Line 44: transp = 75 → color.new(long ? color.green : short ? color.red : color.white, 75)
  • Line 49: ema → ta.ema
  • Line 50: ema → ta.ema
  • Line 51: ema → ta.ema
  • Line 52: ema → ta.ema
  • Line 59: sma → ta.sma
  • Line 60: stdev → ta.stdev
  • Line 65: security → request.security
  • Line 66: security → request.security
  • Line 71: sma → ta.sma
  • Line 71: security → request.security
  • Line 73: security → request.security
  • Line 76: security → request.security
  • Line 77: sma → ta.sma
  • Line 82: security → request.security
  • Line 83: security → request.security
  • Line 84: security → request.security
  • Line 90: security → request.security
  • Line 91: sma → ta.sma
  • Line 93: crossunder → ta.crossunder
  • Line 98: crossover → ta.crossover
⋯// © sparrow_hawk_737-//@version=4+//@version=5strategy("McClellan Oscillator Strategy", default_qty_type=strategy.percent_of_equity, default_qty_value=100)⋯useCTF=input(false, title="Use Custom Timeframe?"), -tf=useCTF?input("D", type=input.resolution, title="Custom Timeframe"):timeframe.period // Recommend NOT enabling this+tf=useCTF?input.timeframe("D", title="Custom Timeframe"):timeframe.period // Recommend NOT enabling thisgaps=barmerge.gaps_off // Recommend leaving this OFF⋯ai=0.0, di=0.0-adv=use_ny*nz(security("ADVN.NY", tf, src, gaps))+use_nq*nz(security("ADVN.NQ", tf, src, gaps))+use_us*nz(security("ADVN.US", tf, src, gaps))+use_dj*nz(security("ADVN.DJ", tf, src, gaps))+use_ax*nz(security("ADVN.AX", tf, src, gaps))+use_am*nz(security("ADVN.AM", tf, src, gaps))+adv=use_ny*nz(request.security("ADVN.NY", tf, src, gaps))+use_nq*nz(request.security("ADVN.NQ", tf, src, gaps))+use_us*nz(request.security("ADVN.US", tf, src, gaps))+use_dj*nz(request.security("ADVN.DJ", tf, src, gaps))+use_ax*nz(request.security("ADVN.AX", tf, src, gaps))+use_am*nz(request.security("ADVN.AM", tf, src, gaps))-dec=use_ny*nz(security("DECL.NY", tf, src, gaps))+use_nq*nz(security("DECL.NQ", tf, src, gaps))+use_us*nz(security("DECL.US", tf, src, gaps))+use_dj*nz(security("DECL.DJ", tf, src, gaps))+use_ax*nz(security("DECL.AX", tf, src, gaps))+use_am*nz(security("DECL.AM", tf, src, gaps))+dec=use_ny*nz(request.security("DECL.NY", tf, src, gaps))+use_nq*nz(request.security("DECL.NQ", tf, src, gaps))+use_us*nz(request.security("DECL.US", tf, src, gaps))+use_dj*nz(request.security("DECL.DJ", tf, src, gaps))+use_ax*nz(request.security("DECL.AX", tf, src, gaps))+use_am*nz(request.security("DECL.AM", tf, src, gaps))ai:=ai+adv, di:=di+dec⋯mtwol = input(36, "mo2 length")-e1=isRA?ema(rana, moonel):ema(ai-di, moonel),e2=isRA?ema(rana, mtwol):ema(ai-di, mtwol)+e1=isRA?ta.ema(rana, moonel):ta.ema(ai-di, moonel),e2=isRA?ta.ema(rana, mtwol):ta.ema(ai-di, mtwol)mo=e1-e2⋯long= mo<=-100 and mo>mo[1]-bgcolor(long ? color.green : short ? color.red : color.white, transp=75)+bgcolor(color.new(long ? color.green : short ? color.red : color.white, 75))alertcondition(long and not long[1], "McC long ", "McC long ")⋯inpos = strategy.position_size > 0-mas1 = ema(mo, fastLengthSell)+mas1 = ta.ema(mo, fastLengthSell)-mas2 = ema(mo, slowLengthSell)+mas2 = ta.ema(mo, slowLengthSell)-mab1 = ema(mo, fastLengthBuy)+mab1 = ta.ema(mo, fastLengthBuy)-mab2 = ema(mo, slowLengthBuy)+mab2 = ta.ema(mo, slowLengthBuy)plot(mas1, color=color.blue, linewidth=2, title="39 EMA")⋯    mult = 2-    basis = sma(x, length)+    basis = ta.sma(x, length)-    dev = mult * stdev(x, length)+    dev = mult * ta.stdev(x, length)    upper = basis + dev⋯    -vxx =  security("VXX", "", close)+vxx =  request.security("VXX", "", close)-vvix = security("VVIX", "", close)+vvix = request.security("VVIX", "", close)bbr1 = get_bbr(vvix, input(10, title="vvix bbr length"))⋯// 25 is the max observed so far-mmth = sma(security(input("MMOH", "Percent of stocks above X"), "", close), input(20, "percent of stocks length"))+mmth = ta.sma(request.security(input("MMOH", "Percent of stocks above X"), "", close), input(20, "percent of stocks length"))mmthlow =( ( mmth[0] - mmth[1] ) + ( mmth[1] - mmth[2] ) + ( mmth[2] - mmth[3] ) ) / 3 < 0-mmfi = security("MMFI", "", close)+mmfi = request.security("MMFI", "", close)mmfibbr = get_bbr(mmfi, 100)buy2 = mmfibbr >= 0 and ( mmfibbr[1] <= 0.01)-skew = security("SKEW", "", close)+skew = request.security("SKEW", "", close)-skewma = sma(skew, input(10, "SKEW MA LENGTH"))+skewma = ta.sma(skew, input(10, "SKEW MA LENGTH"))skewpos = ( ( (skewma - skewma[1]) + (skewma[1] - skewma[2]) + (skewma[2] - skewma[3]) ) / 3) > 0⋯extremenegativeskew = (skbbr > skewthresh) or (skbbr[1] > skewthresh)-v1 = security("VX1!", "", close)+v1 = request.security("VX1!", "", close)-v2 = security("VX2!", "", close)+v2 = request.security("VX2!", "", close)-vix = security("VIX", "", close)+vix = request.security("VIX", "", close)roll_yield = (v1 - vix) / vix⋯plot(shape * 10, color=color.yellow, linewidth=2,title="VIX SHAPE")-iwm = security("IWM", "", close)+iwm = request.security("IWM", "", close)-iwmma12 = sma(iwm, input(12))+iwmma12 = ta.sma(iwm, input(12))buy3 = iwm > iwmma12-sell = rysell and mmthlow and ( crossunder(mas1, mas2) or mas1 < mas2 ) and ( bbr1  >= 0.90 or bbr2 >= 0.90 and mas1 < mas1[1]) and not extremenegativeskew and not buy3+sell = rysell and mmthlow and ( ta.crossunder(mas1, mas2) or mas1 < mas2 ) and ( bbr1  >= 0.90 or bbr2 >= 0.90 and mas1 < mas1[1]) and not extremenegativeskew and not buy3preznobuy = ((year - 2004) % 4 == 0 and month == 10 ? dayofmonth < 10 and dayofmonth > 31 : true) ⋯    strategy.entry("extremenegativeskew", strategy.long)-if (preznobuy and  ( (crossover(mab1, mab2) or mab1 > mab2)) and strategy.position_size <= 0)+if (preznobuy and  ( (ta.crossover(mab1, mab2) or mab1 > mab2)) and strategy.position_size <= 0)    strategy.entry("mab cross", strategy.long)⋯

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.bool()
  • Line 6: input() → input.bool()
  • Line 7: input() → input.bool()
  • Line 8: input() → input.int()
  • Line 9: input() → input.bool()
  • Line 10: input() → input.bool()
22 more edits
  • Line 11: input() → input.int()
  • Line 12: input() → input.int()
  • Line 13: input() → input.int()
  • Line 14: input() → input.int()
  • Line 15: input() → input.bool()
  • Line 21: input() → input.float()
  • Line 22: input() → input.int()
  • Line 23: input() → input.float()
  • Line 24: input() → input.int()
  • Line 25: input() → input.float()
  • Line 26: input() → input.int()
  • Line 32: input() → input.int()
  • Line 33: input() → input.int()
  • Line 67: input() → input.int()
  • Line 68: input() → input.int()
  • Line 69: input() → input.bool()
  • Line 71: input() → input.string()
  • Line 71: input() → input.int()
  • Line 77: input() → input.int()
  • Line 79: input() → input.int()
  • Line 80: input() → input.float()
  • Line 91: input() → input.int()
⋯strategy("McClellan Oscillator Strategy", default_qty_type=strategy.percent_of_equity, default_qty_value=100)-exitWhenOscIsZero = input(false, title="Exit when oscillator goes under 0?")+exitWhenOscIsZero = input.bool(false, title="Exit when oscillator goes under 0?")-enterWhenOscIsZero = input(false, title="Enter when oscillator goes over 0?")+enterWhenOscIsZero = input.bool(false, title="Enter when oscillator goes over 0?")-isRA=input(true, title="Stockcharts version (Ratio Adjusted)?")+isRA=input.bool(true, title="Stockcharts version (Ratio Adjusted)?")-rm=input(defval=1000, title="RANA ratio multiplier")+rm=input.int(defval=1000, title="RANA ratio multiplier")-showEMAs=input(false, title="Show EMAs?")+showEMAs=input.bool(false, title="Show EMAs?")-showOsc=input(true, title="Show Oscillator?")+showOsc=input.bool(true, title="Show Oscillator?")-slowLengthSell = input(20, title="Slow Length Sell")+slowLengthSell = input.int(20, title="Slow Length Sell")-fastLengthSell = input(9, title="Fast Length Sell")+fastLengthSell = input.int(9, title="Fast Length Sell")-slowLengthBuy = input(20, title="Slow Length Buy")+slowLengthBuy = input.int(20, title="Slow Length Buy")-fastLengthBuy = input(9, title="Fast Length Buy")+fastLengthBuy = input.int(9, title="Fast Length Buy")-useCTF=input(false, title="Use Custom Timeframe?"), +useCTF=input.bool(false, title="Use Custom Timeframe?"), tf=useCTF?input.timeframe("D", title="Custom Timeframe"):timeframe.period // Recommend NOT enabling this⋯// varianta cu toate bursele, dar uneori (f rar) cea cu NYSE le da mai devreme.-use_ny=input(100.0,"NYSE %")/100+use_ny=input.float(100.0,"NYSE %")/100-use_nq=input(0,"NASDAQ %")/100+use_nq=input.int(0,"NASDAQ %")/100-use_us=input(100.0,"US %")/100+use_us=input.float(100.0,"US %")/100-use_dj=input(0,"DJ %")/100+use_dj=input.int(0,"DJ %")/100-use_ax=input(100.0,"AX %")/100+use_ax=input.float(100.0,"AX %")/100-use_am=input(0,"AM %")/100+use_am=input.int(0,"AM %")/100ai=0.0, di=0.0⋯rana=rm * (ai-di)/(ai+di)-moonel = input(16, "mo1 length")+moonel = input.int(16, "mo1 length")-mtwol = input(36, "mo2 length")+mtwol = input.int(36, "mo2 length")e1=isRA?ta.ema(rana, moonel):ta.ema(ai-di, moonel),e2=isRA?ta.ema(rana, mtwol):ta.ema(ai-di, mtwol)⋯vvix = request.security("VVIX", "", close)-bbr1 = get_bbr(vvix, input(10, title="vvix bbr length"))+bbr1 = get_bbr(vvix, input.int(10, title="vvix bbr length"))-bbr2 = get_bbr(vxx, input(20,title="vxx bbr length"))+bbr2 = get_bbr(vxx, input.int(20,title="vxx bbr length"))-mmthsell = input(true, "Only sell when percent of X stocks is in downtrend")+mmthsell = input.bool(true, "Only sell when percent of X stocks is in downtrend")// 25 is the max observed so far-mmth = ta.sma(request.security(input("MMOH", "Percent of stocks above X"), "", close), input(20, "percent of stocks length"))+mmth = ta.sma(request.security(input.string("MMOH", "Percent of stocks above X"), "", close), input.int(20, "percent of stocks length"))mmthlow =( ( mmth[0] - mmth[1] ) + ( mmth[1] - mmth[2] ) + ( mmth[2] - mmth[3] ) ) / 3 < 0⋯skew = request.security("SKEW", "", close)-skewma = ta.sma(skew, input(10, "SKEW MA LENGTH"))+skewma = ta.sma(skew, input.int(10, "SKEW MA LENGTH"))skewpos = ( ( (skewma - skewma[1]) + (skewma[1] - skewma[2]) + (skewma[2] - skewma[3]) ) / 3) > 0-skbbr = get_bbr(skew, input(29, "skew bbr length"))+skbbr = get_bbr(skew, input.int(29, "skew bbr length"))-skewthresh = input(1.1, "skew bbr thresh")+skewthresh = input.float(1.1, "skew bbr thresh")extremenegativeskew = (skbbr > skewthresh) or (skbbr[1] > skewthresh)⋯iwm = request.security("IWM", "", close)-iwmma12 = ta.sma(iwm, input(12))+iwmma12 = ta.sma(iwm, input.int(12))buy3 = iwm > iwmma12⋯

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.

⋯// © sparrow_hawk_737-//@version=5+//@version=6strategy("McClellan Oscillator Strategy", default_qty_type=strategy.percent_of_equity, default_qty_value=100)⋯

Settings

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

SettingDefaultType and rangeFeeds
Exit when oscillator goes under 0?falseboolunused
Enter when oscillator goes over 0?falseboolunused
Stockcharts version (Ratio Adjusted)?trueboole1 e2
RANA ratio multiplier1000intrana
Show EMAs?falsebool19 EMA 39 EMA
Show Oscillator?truebool- + MO
Slow Length Sell20intmas2
Fast Length Sell9intmas1
Slow Length Buy20intmab2
Fast Length Buy9intmab1
Use Custom Timeframe?falsebooltf
Custom TimeframeDtimeframe (written resolution)adv dec
NYSE %100.0floatadv dec
NASDAQ %0intadv dec
US %100.0floatadv dec
DJ %0intadv dec
AX %100.0floatadv dec
AM %0intadv dec
mo1 length16inte1
mo2 length36inte2
vvix bbr length10intsell
vxx bbr length20intsell
Only sell when percent of X stocks is in downtrendtrueboolunused
Percent of stocks above XMMOHstringmmthlow
percent of stocks length20intmmthlow
SKEW MA LENGTH10intskewpos
skew bbr length29intextremenegativeskew
skew bbr thresh1.1floatextremenegativeskew
Iwmma12 (no label in the script)12intbuy3

What it calculates

  • EMA (ema, ta.ema in v5)rana, mo1 length (16)e1 · line 34
  • EMA (ema, ta.ema in v5)rana, mo2 length (36)e2 · line 34
  • EMA (ema, ta.ema in v5)mo, Fast Length Sell (9)mas1 · line 49
  • EMA (ema, ta.ema in v5)mo, Slow Length Sell (20)mas2 · line 50
  • EMA (ema, ta.ema in v5)mo, Fast Length Buy (9)mab1 · line 51
  • EMA (ema, ta.ema in v5)mo, Slow Length Buy (20)mab2 · line 52
  • SMA (sma, ta.sma in v5)x, lengthbasis · line 59
  • Stdev (stdev, ta.stdev in v5)x, lengthdev · line 60

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 70 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open extremenegativeskew long(preznobuy and extremenegativeskew and strategy.position_size <= 0)On97
Open mab cross long(preznobuy and ( (crossover(mab1, mab2) or mab1 > mab2)) and strategy.position_size <= 0)On99
Open mmfi + skew bottom long(preznobuy and (buy2 and skewpos) and strategy.position_size <= 0)On102
Open RUS bottom long(preznobuy and (buy3 and skewpos) and strategy.position_size <= 0)On105
Close ((prezsell or sell) and strategy.position_size > 0)On108

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

Alerts

AlertCallMessageLine
McC long alertconditionMcC long 45
McC short alertconditionMcC short 46

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 data21 security call(s), none with lookahead on.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo calc_on_every_tick. 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 ADVN.NY D, ADVN.NQ D, ADVN.US D, ADVN.DJ D, ADVN.AX D, ADVN.AM D, DECL.NY D, DECL.NQ D, DECL.US D, DECL.DJ D, DECL.AX D, DECL.AM D, VXX D, VVIX D, MMOH D, MMFI D, SKEW D, VX1! D, VX2! D, VIX D, IWM 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; 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; 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; 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; 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
McClellan Oscillator Strategy this page—v3 strategy0.0%00.0%
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%
VFI strategy [based on VFI indicator published by UTS] by mohaneesma stdev emav4 strategy+181.4%8154.2%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 78 msWith a workaround 1,000 bars in 137 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/// © sparrow_hawk_737//@version=3strategy("McClellan Oscillator Strategy", default_qty_type=strategy.percent_of_equity, default_qty_value=100)exitWhenOscIsZero = input(false, title="Exit when oscillator goes under 0?")enterWhenOscIsZero = input(false, title="Enter when oscillator goes over 0?")isRA=input(true, title="Stockcharts version (Ratio Adjusted)?")rm=input(defval=1000, title="RANA ratio multiplier")showEMAs=input(false, title="Show EMAs?")showOsc=input(true, title="Show Oscillator?")slowLengthSell = input(20, title="Slow Length Sell")fastLengthSell = input(9, title="Fast Length Sell")slowLengthBuy = input(20, title="Slow Length Buy")fastLengthBuy = input(9, title="Fast Length Buy")useCTF=input(false, title="Use Custom Timeframe?"), tf=useCTF?input("D", type=resolution, title="Custom Timeframe"):period // Recommend NOT enabling thisgaps=barmerge.gaps_off // Recommend leaving this OFFsrc=close// Varianta doar cu NYSE sau doar cu NASDAQ da semnale long mai proaste decat// varianta cu toate bursele, dar uneori (f rar) cea cu NYSE le da mai devreme.use_ny=input(100.0,"NYSE %")/100use_nq=input(0,"NASDAQ %")/100use_us=input(100.0,"US %")/100use_dj=input(0,"DJ %")/100use_ax=input(100.0,"AX %")/100use_am=input(0,"AM %")/100ai=0.0, di=0.0adv=use_ny*nz(security("ADVN.NY", tf, src, gaps))+use_nq*nz(security("ADVN.NQ", tf, src, gaps))+use_us*nz(security("ADVN.US", tf, src, gaps))+use_dj*nz(security("ADVN.DJ", tf, src, gaps))+use_ax*nz(security("ADVN.AX", tf, src, gaps))+use_am*nz(security("ADVN.AM", tf, src, gaps))dec=use_ny*nz(security("DECL.NY", tf, src, gaps))+use_nq*nz(security("DECL.NQ", tf, src, gaps))+use_us*nz(security("DECL.US", tf, src, gaps))+use_dj*nz(security("DECL.DJ", tf, src, gaps))+use_ax*nz(security("DECL.AX", tf, src, gaps))+use_am*nz(security("DECL.AM", tf, src, gaps))ai:=ai+adv, di:=di+decrana=rm * (ai-di)/(ai+di)moonel = input(16, "mo1 length")mtwol = input(36, "mo2 length")e1=isRA?ema(rana, moonel):ema(ai-di, moonel),e2=isRA?ema(rana, mtwol):ema(ai-di, mtwol)mo=e1-e2hline(0, title="0")plot(showOsc?mo<0?mo:0:na, style=area, color=white, title="-")plot(showOsc?mo>=0?mo:0:na, style=area, color=white, title="+")plot(showOsc?mo:na, style=line, color=black, title="MO", linewidth=2)plot(showEMAs?e1:na, color=blue, linewidth=2, title="19 EMA")plot(showEMAs?e2:na, color=red, linewidth=2, title="39 EMA")short= mo>=100 and mo<mo[1]long= mo<=-100 and mo>mo[1]bgcolor(long ? green : short ? red : white, transp=75)alertcondition(long and not long[1], "McC long ", "McC long ")alertcondition(short and not short[1], "McC short ", "McC short ")exited = falseinpos = strategy.position_size > 0mas1 = ema(mo, fastLengthSell)mas2 = ema(mo, slowLengthSell)mab1 = ema(mo, fastLengthBuy)mab2 = ema(mo, slowLengthBuy)plot(mas1, color=blue, linewidth=2, title="39 EMA")plot(mas2, color=orange, linewidth=2, title="39 EMA")plot(mab1, color=red, linewidth=2, title="39 EMA")plot(mab2, color=black, linewidth=2, title="39 EMA")get_bbr(x, length) =>     mult = 2    basis = sma(x, length)    dev = mult * stdev(x, length)    upper = basis + dev    lower = basis - dev    (x - lower)/(upper - lower)    vxx =  security("VXX", "", close)vvix = security("VVIX", "", close)bbr1 = get_bbr(vvix, input(10, title="vvix bbr length"))bbr2 = get_bbr(vxx, input(20,title="vxx bbr length"))mmthsell = input(true, "Only sell when percent of X stocks is in downtrend")// 25 is the max observed so farmmth = sma(security(input("MMOH", "Percent of stocks above X"), "", close), input(20, "percent of stocks length"))mmthlow =( ( mmth[0] - mmth[1] ) + ( mmth[1] - mmth[2] ) + ( mmth[2] - mmth[3] ) ) / 3 < 0mmfi = security("MMFI", "", close)mmfibbr = get_bbr(mmfi, 100)buy2 = mmfibbr >= 0 and ( mmfibbr[1] <= 0.01)skew = security("SKEW", "", close)skewma = sma(skew, input(10, "SKEW MA LENGTH"))skewpos = ( ( (skewma - skewma[1]) + (skewma[1] - skewma[2]) + (skewma[2] - skewma[3]) ) / 3) > 0skbbr = get_bbr(skew, input(29, "skew bbr length"))skewthresh = input(1.1, "skew bbr thresh")extremenegativeskew = (skbbr > skewthresh) or (skbbr[1] > skewthresh)v1 = security("VX1!", "", close)v2 = security("VX2!", "", close)vix = security("VIX", "", close)roll_yield = (v1 - vix) / vixshape =  ( v2 - v1 )rysell = roll_yield <= 0.01plot(roll_yield * 100, color=orange, linewidth=2,title="ROLL YIELD")plot(shape * 10, color=yellow, linewidth=2,title="VIX SHAPE")iwm = security("IWM", "", close)iwmma12 = sma(iwm, input(12))buy3 = iwm > iwmma12sell = rysell and mmthlow and ( crossunder(mas1, mas2) or mas1 < mas2 ) and ( bbr1  >= 0.90 or bbr2 >= 0.90 and mas1 < mas1[1]) and not extremenegativeskew and not buy3preznobuy = ((year - 2004) % 4 == 0 and month == 10 ? dayofmonth < 10 and dayofmonth > 31 : true) prezsell = ((year - 2004) % 4 == 0 and month == 10 ? dayofmonth >= 10 and dayofmonth <= 17 : false)if (preznobuy and extremenegativeskew and strategy.position_size <= 0)    strategy.entry("extremenegativeskew", strategy.long)if (preznobuy and  ( (crossover(mab1, mab2) or mab1 > mab2)) and strategy.position_size <= 0)    strategy.entry("mab cross", strategy.long)    if (preznobuy and  (buy2 and skewpos) and strategy.position_size <= 0)    strategy.entry("mmfi + skew bottom", strategy.long)    if (preznobuy and  (buy3 and skewpos) and strategy.position_size <= 0)    strategy.entry("RUS bottom", strategy.long)    if ((prezsell or sell) and strategy.position_size > 0)    strategy.close_all()