Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

VuManChu Cipher B + Divergences Strategy

A Pine Script v4 strategy built on Valuewhen (fractalTop, src[2]), EMA (tfsrc, chlen) and Cross (wt1[2], wt2[2]). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 10000 in cash and pays 0.025 commission. 81 settings; defaults include WT Channel Length 9, WT Average Length 12 and WT MA Source hlc3.

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 VuManChu Cipher B + Divergences Strategy repaint?
Yes
At least one pattern in the source can repaint: higher-timeframe data.
How did VuManChu Cipher B + Divergences Strategy do on BTCUSDT 1D with default settings?
+76.59%
From 26 Jan 2024 to 21 Oct 2026, over 175 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can VuManChu Cipher B + Divergences Strategy be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
What alerts does VuManChu Cipher B + Divergences Strategy have?
4
Buy; Buy; Sell; Sell.
Does VuManChu Cipher B + Divergences Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.

BTCUSDT · 1D · default settings

  • Plot
  • WT Wave 1
  • WT Wave 2
  • VWAP
  • RSI+MFI Area
  • WT Bearish Divergence
  • WT Bullish Divergence
  • WT 2nd Bearish Divergence
  • WT 2nd Bullish Divergence
  • RSI Bearish Divergence
  • RSI Bullish Divergence
  • Stoch K
  • Stoch D
  • Stoch Bearish Divergence
  • Stoch Bullish Divergence
  • Over Bought Level 2
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$17,998$20,253Equity from $10,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 heikinashi:SYMBOL 60, heikinashi:SYMBOL 240, BINANCE:BTCUSDT 720, heikinashi:BINANCE:BTCUSDT 60, heikinashi:BINANCE:BTCUSDT 240, BINANCE:BTCUSDT 240, which this page cannot load in your browser.

Needs heikinashi:SYMBOL 60 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs heikinashi:SYMBOL 240 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BINANCE:BTCUSDT 720 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs heikinashi:BINANCE:BTCUSDT 60 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs heikinashi:BINANCE:BTCUSDT 240 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BINANCE:BTCUSDT 240 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Values that depend on it are empty on this chart.

Net profit
+76.59%
$7,659.23
Buy and hold
+102.5%
same period
Closed trades
175
74 won · 101 lost
Profitable
42.3%
of closed trades
Profit factor
1.29
gross profit ÷ gross loss
Max drawdown
18.43%
−$3,529.53

One run with the author's default settings, $10,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

    1 setting does nothing

    “Th” 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

    3 settings have no label

    In the settings dialog len (line 405), th (line 406), length (line 444) 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 505, 506, 507, 508. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 351

    transp = on line 351, 352, 353, 355, 356, 358, 360, 361, 369, 386, 387, 389, 391, 392, 393, 395, 396, 398, 399, 400, 401, 402, 403. v5 folds the transparency into the colour with color.new(c, transp).

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames valuewhen → ta.valuewhen, security → request.security, sma → ta.sma, ema → ta.ema, abs → math.abs, cross → ta.cross, lowest → ta.lowest, highest → ta.highest, log → math.log, rsi → ta.rsi, stoch → ta.stoch, avg → math.avg, heikinashi → ticker.heikinashi, change → ta.change, max → math.max, rma → ta.rma, min → math.min, wma → ta.wma.
  • 4 strategy calls use the when = argument (line 505, 506, 507, 508). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

Same 175 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 40: input(type = input.bool) → input.bool()
  • Line 41: input(type = input.bool) → input.bool()
  • Line 42: input(type = input.bool) → input.bool()
  • Line 43: input(type = input.bool) → input.bool()
  • Line 44: input(type = input.bool) → input.bool()
171 more edits
  • Line 45: input(type = input.bool) → input.bool()
  • Line 46: input(type = input.integer) → input.int()
  • Line 47: input(type = input.integer) → input.int()
  • Line 48: input(type = input.source) → input.source()
  • Line 49: input(type = input.integer) → input.int()
  • Line 51: input(type = input.integer) → input.int()
  • Line 52: input(type = input.integer) → input.int()
  • Line 53: input(type = input.integer) → input.int()
  • Line 54: input(type = input.integer) → input.int()
  • Line 55: input(type = input.integer) → input.int()
  • Line 56: input(type = input.integer) → input.int()
  • Line 58: input(type = input.bool) → input.bool()
  • Line 59: input(type = input.bool) → input.bool()
  • Line 60: input(type = input.bool) → input.bool()
  • Line 61: input(type = input.integer) → input.int()
  • Line 62: input(type = input.integer) → input.int()
  • Line 64: input(type = input.bool) → input.bool()
  • Line 65: input(type = input.integer) → input.int()
  • Line 66: input(type = input.integer) → input.int()
  • Line 68: input(type = input.bool) → input.bool()
  • Line 69: input(type = input.integer) → input.int()
  • Line 70: input(type = input.float) → input.float()
  • Line 71: input(type = input.float) → input.float()
  • Line 73: input(type = input.bool) → input.bool()
  • Line 74: input(type = input.source) → input.source()
  • Line 75: input(type = input.integer) → input.int()
  • Line 76: input(type = input.integer) → input.int()
  • Line 77: input(type = input.integer) → input.int()
  • Line 79: input(type = input.bool) → input.bool()
  • Line 80: input(type = input.bool) → input.bool()
  • Line 81: input(type = input.integer) → input.int()
  • Line 82: input(type = input.integer) → input.int()
  • Line 84: input(type = input.bool) → input.bool()
  • Line 85: input(type = input.bool) → input.bool()
  • Line 86: input(type = input.bool) → input.bool()
  • Line 87: input(type = input.source) → input.source()
  • Line 88: input(type = input.integer) → input.int()
  • Line 89: input(type = input.integer) → input.int()
  • Line 90: input(type = input.integer) → input.int()
  • Line 91: input(type = input.integer) → input.int()
  • Line 93: input(type = input.bool) → input.bool()
  • Line 94: input(type = input.bool) → input.bool()
  • Line 96: input(type = input.bool) → input.bool()
  • Line 97: input(type = input.source) → input.source()
  • Line 98: input(type = input.integer) → input.int()
  • Line 99: input(type = input.integer) → input.int()
  • Line 100: input(type = input.integer) → input.int()
  • Line 101: input(type = input.float) → input.float()
  • Line 103: input(type = input.bool) → input.bool()
  • Line 104: input(type = input.bool) → input.bool()
  • Line 105: input(type = input.string) → input.string()
  • Line 106: input(type = input.integer) → input.int()
  • Line 107: input(type = input.integer) → input.int()
  • Line 108: input(type = input.integer) → input.int()
  • Line 109: input(type = input.integer) → input.int()
  • Line 110: input(type = input.integer) → input.int()
  • Line 111: input(type = input.integer) → input.int()
  • Line 113: input(type = input.bool) → input.bool()
  • Line 114: input(type = input.string) → input.string()
  • Line 115: input(type = input.string) → input.string()
  • Line 116: input(type = input.integer) → input.int()
  • Line 117: input(type = input.integer) → input.int()
  • Line 119: input(type = input.bool) → input.bool()
  • Line 120: input(type = input.string) → input.string()
  • Line 121: input(type = input.bool) → input.bool()
  • Line 152: valuewhen → ta.valuewhen
  • Line 153: valuewhen → ta.valuewhen
  • Line 154: valuewhen → ta.valuewhen
  • Line 155: valuewhen → ta.valuewhen
  • Line 163: security → request.security
  • Line 163: sma → ta.sma
  • Line 167: security → request.security
  • Line 168: ema → ta.ema
  • Line 169: ema → ta.ema
  • Line 169: abs → math.abs
  • Line 171: security → request.security
  • Line 171: ema → ta.ema
  • Line 172: security → request.security
  • Line 172: sma → ta.sma
  • Line 176: cross → ta.cross
  • Line 179: cross → ta.cross
  • Line 185: ema → ta.ema
  • Line 186: ema → ta.ema
  • Line 188: lowest → ta.lowest
  • Line 189: highest → ta.highest
  • Line 194: lowest → ta.lowest
  • Line 195: highest → ta.highest
  • Line 203: log → math.log
  • Line 204: rsi → ta.rsi
  • Line 205: sma → ta.sma
  • Line 205: stoch → ta.stoch
  • Line 206: sma → ta.sma
  • Line 207: avg → math.avg
  • Line 212: security → request.security
  • Line 212: ema → ta.ema
  • Line 213: security → request.security
  • Line 213: ema → ta.ema
  • Line 215: security → request.security
  • Line 215: sma → ta.sma
  • Line 230: security → request.security
  • Line 230: heikinashi → ticker.heikinashi
  • Line 231: security → request.security
  • Line 231: heikinashi → ticker.heikinashi
  • Line 232: security → request.security
  • Line 232: heikinashi → ticker.heikinashi
  • Line 233: security → request.security
  • Line 233: heikinashi → ticker.heikinashi
  • Line 235: change → ta.change
  • Line 274: rsi → ta.rsi
  • Line 339: valuewhen → ta.valuewhen
  • Line 351: transp = 100 removed: the call sets no colour to fold it into, so its default colour loses the transparency
  • Line 352: transp = 100 removed: the call sets no colour to fold it into, so its default colour loses the transparency
  • Line 353: transp = 75 → color.new(rsiMFIColor, 75)
  • Line 355: transp = 0 → color.new(macdWTColorsShow ? macdWT1Color : colorWT1, 0)
  • Line 356: transp = 20 → color.new(macdWTColorsShow ? macdWT2Color : darkMode ? colorWT2_ : colorWT2, 20)
  • Line 358: transp = 45 → color.new(colorYellow, 45)
  • Line 360: transp = 20 → color.new(rsiMFIColor, 20)
  • Line 361: transp = 40 → color.new(rsiMFIColor, 40)
  • Line 369: transp = 25 → color.new(rsiColor, 25)
  • Line 386: transp = 85 → color.new(colorWhite, 85)
  • Line 387: transp = 95 → color.new(colorWhite, 95)
  • Line 389: transp = 85 → color.new(colorWhite, 85)
  • Line 391: transp = 0 → color.new(colorPink, 0)
  • Line 392: transp = 0 → color.new(colorBluelight, 0)
  • Line 393: ema → ta.ema
  • Line 393: transp = 15 → color.new(colorYellow, 15)
  • Line 395: transp = 0 → color.new(colorPink, 0)
  • Line 396: transp = 0 → color.new(colorBluelight, 0)
  • Line 398: transp = 15 → color.new(signalColor, 15)
  • Line 399: transp = 50 → color.new(colorGreen, 50)
  • Line 400: transp = 50 → color.new(colorRed, 50)
  • Line 401: transp = 15 → color.new(buySignalDiv_color, 15)
  • Line 402: transp = 15 → color.new(sellSignalDiv_color, 15)
  • Line 403: transp = 15 → color.new(colorOrange, 15)
  • Line 407: max → math.max
  • Line 407: max → math.max
  • Line 407: abs → math.abs
  • Line 407: abs → math.abs
  • Line 408: max → math.max
  • Line 409: max → math.max
  • Line 418: abs → math.abs
  • Line 419: sma → ta.sma
  • Line 436: lowest → ta.lowest
  • Line 437: highest → ta.highest
  • Line 438: stoch → ta.stoch
  • Line 449: rma → ta.rma
  • Line 449: max → math.max
  • Line 449: change → ta.change
  • Line 450: rma → ta.rma
  • Line 450: max → math.max
  • Line 450: change → ta.change
  • Line 451: rma → ta.rma
  • Line 451: min → math.min
  • Line 451: change → ta.change
  • Line 452: rma → ta.rma
  • Line 452: min → math.min
  • Line 452: change → ta.change
  • Line 459: highest → ta.highest
  • Line 459: lowest → ta.lowest
  • Line 460: change → ta.change
  • Line 461: max → math.max
  • Line 461: min → math.min
  • Line 463: max → math.max
  • Line 464: min → math.min
  • Line 467: wma → ta.wma
  • Line 467: wma → ta.wma
  • Line 468: wma → ta.wma
  • Line 468: wma → ta.wma
  • Line 470: wma → ta.wma
  • Line 471: wma → ta.wma
  • Line 473: wma → ta.wma
⋯// © vumanchu-//@version=4+//@version=5//  Thanks to dynausmaux for the code⋯// WaveTrend-wtShow = input(true, title = 'Show WaveTrend', type = input.bool)+wtShow = input.bool(true, title = 'Show WaveTrend')-wtBuyShow = input(true, title = 'Show Buy dots', type = input.bool)+wtBuyShow = input.bool(true, title = 'Show Buy dots')-wtGoldShow = input(true, title = 'Show Gold dots', type = input.bool)+wtGoldShow = input.bool(true, title = 'Show Gold dots')-wtSellShow = input(true, title = 'Show Sell dots', type = input.bool)+wtSellShow = input.bool(true, title = 'Show Sell dots')-wtDivShow = input(true, title = 'Show Div. dots', type = input.bool)+wtDivShow = input.bool(true, title = 'Show Div. dots')-vwapShow = input(true, title = 'Show Fast WT', type = input.bool)+vwapShow = input.bool(true, title = 'Show Fast WT')-wtChannelLen = input(9, title = 'WT Channel Length', type = input.integer)+wtChannelLen = input.int(9, title = 'WT Channel Length')-wtAverageLen = input(12, title = 'WT Average Length', type = input.integer)+wtAverageLen = input.int(12, title = 'WT Average Length')-wtMASource = input(hlc3, title = 'WT MA Source', type = input.source)+wtMASource = input.source(hlc3, title = 'WT MA Source')-wtMALen = input(3, title = 'WT MA Length', type = input.integer)+wtMALen = input.int(3, title = 'WT MA Length')// WaveTrend Overbought & Oversold lines-obLevel = input(53, title = 'WT Overbought Level 1', type = input.integer)+obLevel = input.int(53, title = 'WT Overbought Level 1')-obLevel2 = input(60, title = 'WT Overbought Level 2', type = input.integer)+obLevel2 = input.int(60, title = 'WT Overbought Level 2')-obLevel3 = input(100, title = 'WT Overbought Level 3', type = input.integer)+obLevel3 = input.int(100, title = 'WT Overbought Level 3')-osLevel = input(-53, title = 'WT Oversold Level 1', type = input.integer)+osLevel = input.int(-53, title = 'WT Oversold Level 1')-osLevel2 = input(-60, title = 'WT Oversold Level 2', type = input.integer)+osLevel2 = input.int(-60, title = 'WT Oversold Level 2')-osLevel3 = input(-75, title = 'WT Oversold Level 3', type = input.integer)+osLevel3 = input.int(-75, title = 'WT Oversold Level 3')// Divergence WT-wtShowDiv = input(true, title = 'Show WT Regular Divergences', type = input.bool)+wtShowDiv = input.bool(true, title = 'Show WT Regular Divergences')-wtShowHiddenDiv = input(false, title = 'Show WT Hidden Divergences', type = input.bool)+wtShowHiddenDiv = input.bool(false, title = 'Show WT Hidden Divergences')-showHiddenDiv_nl = input(true, title = 'Not apply OB/OS Limits on Hidden Divergences', type = input.bool)+showHiddenDiv_nl = input.bool(true, title = 'Not apply OB/OS Limits on Hidden Divergences')-wtDivOBLevel = input(45, title = 'WT Bearish Divergence min', type = input.integer)+wtDivOBLevel = input.int(45, title = 'WT Bearish Divergence min')-wtDivOSLevel = input(-65, title = 'WT Bullish Divergence min', type = input.integer)+wtDivOSLevel = input.int(-65, title = 'WT Bullish Divergence min')// Divergence extra range-wtDivOBLevel_addshow = input(true, title = 'Show 2nd WT Regular Divergences', type = input.bool)+wtDivOBLevel_addshow = input.bool(true, title = 'Show 2nd WT Regular Divergences')-wtDivOBLevel_add = input(15, title = 'WT 2nd Bearish Divergence', type = input.integer)+wtDivOBLevel_add = input.int(15, title = 'WT 2nd Bearish Divergence')-wtDivOSLevel_add = input(-40, title = 'WT 2nd Bullish Divergence 15 min', type = input.integer)+wtDivOSLevel_add = input.int(-40, title = 'WT 2nd Bullish Divergence 15 min')// RSI+MFI-rsiMFIShow = input(true, title = 'Show MFI', type = input.bool)+rsiMFIShow = input.bool(true, title = 'Show MFI')-rsiMFIperiod = input(60,title = 'MFI Period', type = input.integer)+rsiMFIperiod = input.int(60,title = 'MFI Period')-rsiMFIMultiplier = input(150, title = 'MFI Area multiplier', type = input.float)+rsiMFIMultiplier = input.float(150, title = 'MFI Area multiplier')-rsiMFIPosY = input(2.5, title = 'MFI Area Y Pos', type = input.float)+rsiMFIPosY = input.float(2.5, title = 'MFI Area Y Pos')// RSI-rsiShow = input(false, title = 'Show RSI', type = input.bool)+rsiShow = input.bool(false, title = 'Show RSI')-rsiSRC = input(close, title = 'RSI Source', type = input.source)+rsiSRC = input.source(close, title = 'RSI Source')-rsiLen = input(14, title = 'RSI Length', type = input.integer)+rsiLen = input.int(14, title = 'RSI Length')-rsiOversold = input(30, title = 'RSI Oversold', minval = 50, maxval = 100, type = input.integer)+rsiOversold = input.int(30, title = 'RSI Oversold', minval = 50, maxval = 100)-rsiOverbought = input(60, title = 'RSI Overbought', minval = 0, maxval = 50, type = input.integer)+rsiOverbought = input.int(60, title = 'RSI Overbought', minval = 0, maxval = 50)// Divergence RSI-rsiShowDiv = input(false, title = 'Show RSI Regular Divergences', type = input.bool)+rsiShowDiv = input.bool(false, title = 'Show RSI Regular Divergences')-rsiShowHiddenDiv = input(false, title = 'Show RSI Hidden Divergences', type = input.bool)+rsiShowHiddenDiv = input.bool(false, title = 'Show RSI Hidden Divergences')-rsiDivOBLevel = input(60, title = 'RSI Bearish Divergence min', type = input.integer)+rsiDivOBLevel = input.int(60, title = 'RSI Bearish Divergence min')-rsiDivOSLevel = input(30, title = 'RSI Bullish Divergence min', type = input.integer)+rsiDivOSLevel = input.int(30, title = 'RSI Bullish Divergence min')// RSI Stochastic-stochShow = input(true, title = 'Show Stochastic RSI', type = input.bool)+stochShow = input.bool(true, title = 'Show Stochastic RSI')-stochUseLog = input(true, title=' Use Log?', type = input.bool)+stochUseLog = input.bool(true, title=' Use Log?')-stochAvg = input(false, title='Use Average of both K & D', type = input.bool)+stochAvg = input.bool(false, title='Use Average of both K & D')-stochSRC = input(close, title = 'Stochastic RSI Source', type = input.source)+stochSRC = input.source(close, title = 'Stochastic RSI Source')-stochLen = input(14, title = 'Stochastic RSI Length', type = input.integer)+stochLen = input.int(14, title = 'Stochastic RSI Length')-stochRsiLen = input(14, title = 'RSI Length ', type = input.integer)+stochRsiLen = input.int(14, title = 'RSI Length ')-stochKSmooth = input(3, title = 'Stochastic RSI K Smooth', type = input.integer)+stochKSmooth = input.int(3, title = 'Stochastic RSI K Smooth')-stochDSmooth = input(3, title = 'Stochastic RSI D Smooth', type = input.integer)+stochDSmooth = input.int(3, title = 'Stochastic RSI D Smooth')// Divergence stoch-stochShowDiv = input(false, title = 'Show Stoch Regular Divergences', type = input.bool)+stochShowDiv = input.bool(false, title = 'Show Stoch Regular Divergences')-stochShowHiddenDiv = input(false, title = 'Show Stoch Hidden Divergences', type = input.bool)+stochShowHiddenDiv = input.bool(false, title = 'Show Stoch Hidden Divergences')// Schaff Trend Cycle-tcLine = input(false, title="Show Schaff TC line", type=input.bool)+tcLine = input.bool(false, title="Show Schaff TC line")-tcSRC = input(close, title = 'Schaff TC Source', type = input.source)+tcSRC = input.source(close, title = 'Schaff TC Source')-tclength = input(10, title="Schaff TC", type=input.integer)+tclength = input.int(10, title="Schaff TC")-tcfastLength = input(23, title="Schaff TC Fast Lenght", type=input.integer)+tcfastLength = input.int(23, title="Schaff TC Fast Lenght")-tcslowLength = input(50, title="Schaff TC Slow Length", type=input.integer)+tcslowLength = input.int(50, title="Schaff TC Slow Length")-tcfactor = input(0.5, title="Schaff TC Factor", type=input.float)+tcfactor = input.float(0.5, title="Schaff TC Factor")// Sommi Flag-sommiFlagShow = input(false, title = 'Show Sommi flag', type = input.bool)+sommiFlagShow = input.bool(false, title = 'Show Sommi flag')-sommiShowVwap = input(false, title = 'Show Sommi F. Wave', type = input.bool)+sommiShowVwap = input.bool(false, title = 'Show Sommi F. Wave')-sommiVwapTF = input('720', title = 'Sommi F. Wave timeframe', type = input.string)+sommiVwapTF = input.string('720', title = 'Sommi F. Wave timeframe')-sommiVwapBearLevel = input(0, title = 'F. Wave Bear Level (less than)', type = input.integer)+sommiVwapBearLevel = input.int(0, title = 'F. Wave Bear Level (less than)')-sommiVwapBullLevel = input(0, title = 'F. Wave Bull Level (more than)', type = input.integer)+sommiVwapBullLevel = input.int(0, title = 'F. Wave Bull Level (more than)')-soomiFlagWTBearLevel = input(0, title = 'WT Bear Level (more than)', type = input.integer) +soomiFlagWTBearLevel = input.int(0, title = 'WT Bear Level (more than)') -soomiFlagWTBullLevel = input(0, title = 'WT Bull Level (less than)', type = input.integer) +soomiFlagWTBullLevel = input.int(0, title = 'WT Bull Level (less than)') -soomiRSIMFIBearLevel = input(0, title = 'Money flow Bear Level (less than)', type = input.integer) +soomiRSIMFIBearLevel = input.int(0, title = 'Money flow Bear Level (less than)') -soomiRSIMFIBullLevel = input(0, title = 'Money flow Bull Level (more than)', type = input.integer) +soomiRSIMFIBullLevel = input.int(0, title = 'Money flow Bull Level (more than)') // Sommi Diamond-sommiDiamondShow = input(false, title = 'Show Sommi diamond', type = input.bool)+sommiDiamondShow = input.bool(false, title = 'Show Sommi diamond')-sommiHTCRes = input('60', title = 'HTF Candle Res. 1', type = input.string)+sommiHTCRes = input.string('60', title = 'HTF Candle Res. 1')-sommiHTCRes2 = input('240', title = 'HTF Candle Res. 2', type = input.string)+sommiHTCRes2 = input.string('240', title = 'HTF Candle Res. 2')-soomiDiamondWTBearLevel = input(0, title = 'WT Bear Level (More than)', type = input.integer)+soomiDiamondWTBearLevel = input.int(0, title = 'WT Bear Level (More than)')-soomiDiamondWTBullLevel = input(0, title = 'WT Bull Level (Less than)', type = input.integer)+soomiDiamondWTBullLevel = input.int(0, title = 'WT Bull Level (Less than)')// macd Colors-macdWTColorsShow = input(false, title = 'Show MACD Colors', type = input.bool)+macdWTColorsShow = input.bool(false, title = 'Show MACD Colors')-macdWTColorsTF = input('240', title = 'MACD Colors MACD TF', type = input.string)+macdWTColorsTF = input.string('240', title = 'MACD Colors MACD TF')-darkMode = input(false, title = 'Dark mode', type = input.bool)+darkMode = input.bool(false, title = 'Dark mode')// Colors⋯    fractalBot = f_fractalize(src) < 0 and (useLimits ? src[2] <= botLimit : true) ? src[2] : na-    highPrev = valuewhen(fractalTop, src[2], 0)[2]+    highPrev = ta.valuewhen(fractalTop, src[2], 0)[2]-    highPrice = valuewhen(fractalTop, high[2], 0)[2]+    highPrice = ta.valuewhen(fractalTop, high[2], 0)[2]-    lowPrev = valuewhen(fractalBot, src[2], 0)[2]+    lowPrev = ta.valuewhen(fractalBot, src[2], 0)[2]-    lowPrice = valuewhen(fractalBot, low[2], 0)[2]+    lowPrice = ta.valuewhen(fractalBot, low[2], 0)[2]    bearSignal = fractalTop and high[2] > highPrice and src[2] < highPrev⋯// RSI+MFI-f_rsimfi(_period, _multiplier, _tf) => security(syminfo.tickerid, _tf, sma(((close - open) / (high - low)) * _multiplier, _period) - rsiMFIPosY)+f_rsimfi(_period, _multiplier, _tf) => request.security(syminfo.tickerid, _tf, ta.sma(((close - open) / (high - low)) * _multiplier, _period) - rsiMFIPosY)   ⋯f_wavetrend(src, chlen, avg, malen, tf) =>-    tfsrc = security(syminfo.tickerid, tf, src)+    tfsrc = request.security(syminfo.tickerid, tf, src)-    esa = ema(tfsrc, chlen)+    esa = ta.ema(tfsrc, chlen)-    de = ema(abs(tfsrc - esa), chlen)+    de = ta.ema(math.abs(tfsrc - esa), chlen)    ci = (tfsrc - esa) / (0.015 * de)-    wt1 = security(syminfo.tickerid, tf, ema(ci, avg))+    wt1 = request.security(syminfo.tickerid, tf, ta.ema(ci, avg))-    wt2 = security(syminfo.tickerid, tf, sma(wt1, malen))+    wt2 = request.security(syminfo.tickerid, tf, ta.sma(wt1, malen))    wtVwap = wt1 - wt2⋯    wtOverbought = wt2 >= obLevel-    wtCross = cross(wt1, wt2)+    wtCross = ta.cross(wt1, wt2)    wtCrossUp = wt2 - wt1 <= 0    wtCrossDown = wt2 - wt1 >= 0-    wtCrosslast = cross(wt1[2], wt2[2])+    wtCrosslast = ta.cross(wt1[2], wt2[2])    wtCrossUplast = wt2[2] - wt1[2] <= 0⋯f_tc(src, length, fastLength, slowLength) =>-    ema1 = ema(src, fastLength)+    ema1 = ta.ema(src, fastLength)-    ema2 = ema(src, slowLength)+    ema2 = ta.ema(src, slowLength)    macdVal = ema1 - ema2   -    alpha = lowest(macdVal, length)+    alpha = ta.lowest(macdVal, length)-    beta = highest(macdVal, length) - alpha+    beta = ta.highest(macdVal, length) - alpha    gamma = (macdVal - alpha) / beta * 100⋯    delta := na(delta[1]) ? delta : delta[1] + tcfactor * (gamma - delta[1])-    epsilon = lowest(delta, length)+    epsilon = ta.lowest(delta, length)-    zeta = highest(delta, length) - epsilon+    zeta = ta.highest(delta, length) - epsilon    eta = (delta - epsilon) / zeta * 100⋯f_stochrsi(_src, _stochlen, _rsilen, _smoothk, _smoothd, _log, _avg) =>-    src = _log ? log(_src) : _src+    src = _log ? math.log(_src) : _src-    rsi = rsi(src, _rsilen)+    rsi = ta.rsi(src, _rsilen)-    kk = sma(stoch(rsi, rsi, rsi, _stochlen), _smoothk)+    kk = ta.sma(ta.stoch(rsi, rsi, rsi, _stochlen), _smoothk)-    d1 = sma(kk, _smoothd)+    d1 = ta.sma(kk, _smoothd)-    avg_1 = avg(kk, d1)+    avg_1 = math.avg(kk, d1)    k = _avg ? avg_1 : kk⋯f_macd(src, fastlen, slowlen, sigsmooth, tf) =>-    fast_ma = security(syminfo.tickerid, tf, ema(src, fastlen))+    fast_ma = request.security(syminfo.tickerid, tf, ta.ema(src, fastlen))-    slow_ma = security(syminfo.tickerid, tf, ema(src, slowlen))+    slow_ma = request.security(syminfo.tickerid, tf, ta.ema(src, slowlen))    macd = fast_ma - slow_ma,-    signal = security(syminfo.tickerid, tf, sma(macd, sigsmooth))+    signal = request.security(syminfo.tickerid, tf, ta.sma(macd, sigsmooth))    hist = macd - signal⋯f_getTFCandle(_tf) => -    _open  = security(heikinashi(syminfo.tickerid), _tf, open, barmerge.gaps_off, barmerge.lookahead_on)+    _open  = request.security(ticker.heikinashi(syminfo.tickerid), _tf, open, barmerge.gaps_off, barmerge.lookahead_on)-    _close = security(heikinashi(syminfo.tickerid), _tf, close, barmerge.gaps_off, barmerge.lookahead_on)+    _close = request.security(ticker.heikinashi(syminfo.tickerid), _tf, close, barmerge.gaps_off, barmerge.lookahead_on)-    _high  = security(heikinashi(syminfo.tickerid), _tf, high, barmerge.gaps_off, barmerge.lookahead_on)+    _high  = request.security(ticker.heikinashi(syminfo.tickerid), _tf, high, barmerge.gaps_off, barmerge.lookahead_on)-    _low   = security(heikinashi(syminfo.tickerid), _tf, low, barmerge.gaps_off, barmerge.lookahead_on)+    _low   = request.security(ticker.heikinashi(syminfo.tickerid), _tf, low, barmerge.gaps_off, barmerge.lookahead_on)    hl2   = (_high + _low) / 2.0-    newBar = change(_open)+    newBar = ta.change(_open)    candleBodyDir = _close > _open⋯// RSI-rsi = rsi(rsiSRC, rsiLen)+rsi = ta.rsi(rsiSRC, rsiLen)rsiColor = rsi <= rsiOversold ? colorGreen : rsi >= rsiOverbought ? colorRed : colorPurple⋯// Gold Buy -lastRsi = valuewhen(wtFractalBot, rsi[2], 0)[2]+lastRsi = ta.valuewhen(wtFractalBot, rsi[2], 0)[2]wtGoldBuy = ((wtShowDiv and wtBullDiv) or (rsiShowDiv and rsiBullDiv)) and⋯//  MFI BAR-rsiMfiBarTopLine = plot(rsiMFIShow ? -95 : na, title = 'MFI Bar TOP Line', transp = 100)+rsiMfiBarTopLine = plot(rsiMFIShow ? -95 : na, title = 'MFI Bar TOP Line')-rsiMfiBarBottomLine = plot(rsiMFIShow ? -99 : na, title = 'MFI Bar BOTTOM Line', transp = 100)+rsiMfiBarBottomLine = plot(rsiMFIShow ? -99 : na, title = 'MFI Bar BOTTOM Line')-fill(rsiMfiBarTopLine, rsiMfiBarBottomLine, title = 'MFI Bar Colors', color = rsiMFIColor, transp = 75)+fill(rsiMfiBarTopLine, rsiMfiBarBottomLine, title = 'MFI Bar Colors', color = color.new(rsiMFIColor, 75))// WT Areas-plot(wtShow ? wt1 : na, style = plot.style_area, title = 'WT Wave 1', color = macdWTColorsShow ? macdWT1Color : colorWT1, transp = 0)+plot(wtShow ? wt1 : na, style = plot.style_area, title = 'WT Wave 1', color = color.new(macdWTColorsShow ? macdWT1Color : colorWT1, 0))-plot(wtShow ? wt2 : na, style = plot.style_area, title = 'WT Wave 2', color = macdWTColorsShow ? macdWT2Color : darkMode ? colorWT2_ : colorWT2 , transp = 20)+plot(wtShow ? wt2 : na, style = plot.style_area, title = 'WT Wave 2', color = color.new(macdWTColorsShow ? macdWT2Color : darkMode ? colorWT2_ : colorWT2, 20) )// VWAP-plot(vwapShow ? wtVwap : na, title = 'VWAP', color = colorYellow, style = plot.style_area, linewidth = 2, transp = 45)+plot(vwapShow ? wtVwap : na, title = 'VWAP', color = color.new(colorYellow, 45), style = plot.style_area, linewidth = 2)// MFI AREA-rsiMFIplot = plot(rsiMFIShow ? rsiMFI: na, title = 'RSI+MFI Area', color = rsiMFIColor, transp = 20)+rsiMFIplot = plot(rsiMFIShow ? rsiMFI: na, title = 'RSI+MFI Area', color = color.new(rsiMFIColor, 20))-fill(rsiMFIplot, zLine, rsiMFIColor, transp = 40)+fill(rsiMFIplot, zLine, color.new(rsiMFIColor, 40))// WT Div⋯// RSI-plot(rsiShow ? rsi : na, title = 'RSI', color = rsiColor, linewidth = 2, transp = 25)+plot(rsiShow ? rsi : na, title = 'RSI', color = color.new(rsiColor, 25), linewidth = 2)// RSI Div⋯//plot(obLevel, title = 'Over Bought Level 1', color = colorWhite, linewidth = 1, style = plot.style_circles, transp = 85)-plot(obLevel2, title = 'Over Bought Level 2', color = colorWhite, linewidth = 1, style = plot.style_stepline, transp = 85)+plot(obLevel2, title = 'Over Bought Level 2', color = color.new(colorWhite, 85), linewidth = 1, style = plot.style_stepline)-plot(obLevel3, title = 'Over Bought Level 3', color = colorWhite, linewidth = 1, style = plot.style_circles, transp = 95)+plot(obLevel3, title = 'Over Bought Level 3', color = color.new(colorWhite, 95), linewidth = 1, style = plot.style_circles)//plot(osLevel, title = 'Over Sold Level 1', color = colorWhite, linewidth = 1, style = plot.style_circles, transp = 85)-plot(osLevel2, title = 'Over Sold Level 2', color = colorWhite, linewidth = 1, style = plot.style_stepline, transp = 85)+plot(osLevel2, title = 'Over Sold Level 2', color = color.new(colorWhite, 85), linewidth = 1, style = plot.style_stepline)// Sommi flag-plotchar(sommiFlagShow and sommiBearish ? 108 : na, title = 'Sommi bearish flag', char='⚑', color = colorPink, location = location.absolute, size = size.tiny, transp = 0)+plotchar(sommiFlagShow and sommiBearish ? 108 : na, title = 'Sommi bearish flag', char='⚑', color = color.new(colorPink, 0), location = location.absolute, size = size.tiny)-plotchar(sommiFlagShow and sommiBullish ? -108 : na, title = 'Sommi bullish flag', char='⚑', color = colorBluelight, location = location.absolute, size = size.tiny, transp = 0)+plotchar(sommiFlagShow and sommiBullish ? -108 : na, title = 'Sommi bullish flag', char='⚑', color = color.new(colorBluelight, 0), location = location.absolute, size = size.tiny)-plot(sommiShowVwap ? ema(hvwap, 3) : na, title = 'Sommi higher VWAP', color = colorYellow, linewidth = 2, style = plot.style_line, transp = 15)+plot(sommiShowVwap ? ta.ema(hvwap, 3) : na, title = 'Sommi higher VWAP', color = color.new(colorYellow, 15), linewidth = 2, style = plot.style_line)// Sommi diamond-plotchar(sommiDiamondShow and sommiBearishDiamond ? 108 : na, title = 'Sommi bearish diamond', char='◆', color = colorPink, location = location.absolute, size = size.tiny, transp = 0)+plotchar(sommiDiamondShow and sommiBearishDiamond ? 108 : na, title = 'Sommi bearish diamond', char='◆', color = color.new(colorPink, 0), location = location.absolute, size = size.tiny)-plotchar(sommiDiamondShow and sommiBullishDiamond ? -108 : na, title = 'Sommi bullish diamond', char='◆', color = colorBluelight, location = location.absolute, size = size.tiny, transp = 0)+plotchar(sommiDiamondShow and sommiBullishDiamond ? -108 : na, title = 'Sommi bullish diamond', char='◆', color = color.new(colorBluelight, 0), location = location.absolute, size = size.tiny)// Circles-plot(wtCross ? wt2 : na, title = 'Buy and sell circle', color = signalColor, style = plot.style_circles, linewidth = 3, transp = 15)+plot(wtCross ? wt2 : na, title = 'Buy and sell circle', color = color.new(signalColor, 15), style = plot.style_circles, linewidth = 3)-plotchar(wtBuyShow and buySignal ? -107 : na, title = 'Buy circle', char='·', color = colorGreen, location = location.absolute, size = size.small, transp = 50)+plotchar(wtBuyShow and buySignal ? -107 : na, title = 'Buy circle', char='·', color = color.new(colorGreen, 50), location = location.absolute, size = size.small)-plotchar(wtSellShow and sellSignal ? 105 : na , title = 'Sell circle', char='·', color = colorRed, location = location.absolute, size = size.small, transp = 50)+plotchar(wtSellShow and sellSignal ? 105 : na , title = 'Sell circle', char='·', color = color.new(colorRed, 50), location = location.absolute, size = size.small)-plotchar(wtDivShow and buySignalDiv ? -106 : na, title = 'Divergence buy circle', char='•', color = buySignalDiv_color, location = location.absolute, size = size.small, offset = -2, transp = 15)+plotchar(wtDivShow and buySignalDiv ? -106 : na, title = 'Divergence buy circle', char='•', color = color.new(buySignalDiv_color, 15), location = location.absolute, size = size.small, offset = -2)-plotchar(wtDivShow and sellSignalDiv ? 106 : na, title = 'Divergence sell circle', char='•', color = sellSignalDiv_color, location = location.absolute, size = size.small, offset = -2, transp = 15)+plotchar(wtDivShow and sellSignalDiv ? 106 : na, title = 'Divergence sell circle', char='•', color = color.new(sellSignalDiv_color, 15), location = location.absolute, size = size.small, offset = -2)-plotchar(wtGoldBuy and wtGoldShow ? -106 : na, title = 'Gold  buy gold circle', char='•', color = colorOrange, location = location.absolute, size = size.small, offset = -2, transp = 15)+plotchar(wtGoldBuy and wtGoldShow ? -106 : na, title = 'Gold  buy gold circle', char='•', color = color.new(colorOrange, 15), location = location.absolute, size = size.small, offset = -2)// } DRAW⋯th = input(20)-TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))+TrueRange = math.max(math.max(high-low, math.abs(high-nz(close[1]))), math.abs(low-nz(close[1])))-DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0+DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? math.max(high-nz(high[1]), 0): 0-DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0+DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? math.max(nz(low[1])-low, 0): 0SmoothedTrueRange = 0.0⋯DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100-DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100+DX = math.abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100-ADX = sma(DX, len)+ADX = ta.sma(DX, len)plot(ADX, color=color.white, title="ADX")⋯f_RelVol(_value, _length) =>-    min_value = lowest(_value, _length)+    min_value = ta.lowest(_value, _length)-    max_value = highest(_value, _length)+    max_value = ta.highest(_value, _length)-    stoch(_value, max_value, min_value, _length) / 100+    ta.stoch(_value, max_value, min_value, _length) / 100rsi1LengthInput = input(100, minval=1, title="RSI Length", group="RSI Settings")⋯vlookbk = input(20, 'Lookback (for Relative)', minval=1, group='Volume Parameters')-uprsi1 = rma(max(change(rsi1SourceInput), 0), rsi1LengthInput)+uprsi1 = ta.rma(math.max(ta.change(rsi1SourceInput), 0), rsi1LengthInput)-uprsi2 = rma(max(change(rsi2SourceInput), 0), rsi2LengthInput)+uprsi2 = ta.rma(math.max(ta.change(rsi2SourceInput), 0), rsi2LengthInput)-downrsi1 = rma(-min(change(rsi1SourceInput), 0), rsi1LengthInput)+downrsi1 = ta.rma(-math.min(ta.change(rsi1SourceInput), 0), rsi1LengthInput)-downrsi2 = rma(-min(change(rsi2SourceInput), 0), rsi2LengthInput)+downrsi2 = ta.rma(-math.min(ta.change(rsi2SourceInput), 0), rsi2LengthInput)rsi1 = downrsi1 == 0 ? 100 : uprsi1 == 0 ? 0 : 100 - (100 / (1 + uprsi1 / downrsi1))⋯  volume-R       = (highest(1) - lowest(1)) / 2                    // R is the 2-bar average bar range+R       = (ta.highest(1) - ta.lowest(1)) / 2                    // R is the 2-bar average bar range-sr      = change(price) / R                                  // calc ratio of change to R+sr      = ta.change(price) / R                                  // calc ratio of change to R-rsr     = max(min(sr, 1), -1)                         // ensure ratio is restricted to +1/-1 in case of big moves+rsr     = math.max(math.min(sr, 1), -1)                         // ensure ratio is restricted to +1/-1 in case of big movesc       = rsr * vola                                            // add volume accel-c_plus  = max(c, 0)                                        // calc directional vol-accel energy+c_plus  = math.max(c, 0)                                        // calc directional vol-accel energy-c_minus = -min(c, 0)+c_minus = -math.min(c, 0)// plot(c_plus)// plot(c_minus)-dem     = wma(c_plus, length) / wma(vola, length)         //average directional energy ratio+dem     = ta.wma(c_plus, length) / ta.wma(vola, length)         //average directional energy ratio-sup     = wma(c_minus, length) / wma(vola, length)+sup     = ta.wma(c_minus, length) / ta.wma(vola, length)// plot(vola, 'Vol Accel')-adp     = 1 * wma(dem, DER_avg)+adp     = 1 * ta.wma(dem, DER_avg)-asp     = 1 * wma(sup, DER_avg)+asp     = 1 * ta.wma(sup, DER_avg)anp     = adp - asp-anp_s   = wma(anp, smooth)+anp_s   = ta.wma(anp, smooth)// plot(rsi1, "RSI", color=#FF0033)⋯

Clean v5

VerifiedDownload the v5 script

Same 175 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 405: input() → input.int()
  • Line 406: input() → input.int()
  • Line 439: input() → input.int()
  • Line 440: input() → input.source()
  • Line 441: input() → input.int()
  • Line 442: input() → input.source()
9 more edits
  • Line 444: input() → input.int()
  • Line 445: input() → input.int()
  • Line 446: input() → input.int()
  • Line 447: input() → input.string()
  • Line 448: input() → input.int()
  • Line 505: when = long_entry → if block
  • Line 506: when = long_exit_entry → if block
  • Line 507: when = short_entry → if block
  • Line 508: when = short_exit_entry → if block
⋯// } DRAW-len = input(14)+len = input.int(14)-th = input(20)+th = input.int(20)TrueRange = math.max(math.max(high-low, math.abs(high-nz(close[1]))), math.abs(low-nz(close[1])))⋯    ta.stoch(_value, max_value, min_value, _length) / 100-rsi1LengthInput = input(100, minval=1, title="RSI Length", group="RSI Settings")+rsi1LengthInput = input.int(100, minval=1, title="RSI Length", group="RSI Settings")-rsi1SourceInput = input(close, "Source", group="RSI Settings")+rsi1SourceInput = input.source(close, "Source", group="RSI Settings")-rsi2LengthInput = input(25, minval=1, title="RSI Length", group="RSI Settings")+rsi2LengthInput = input.int(25, minval=1, title="RSI Length", group="RSI Settings")-rsi2SourceInput = input(close, "Source", group="RSI Settings")+rsi2SourceInput = input.source(close, "Source", group="RSI Settings")price   = close-length  = input(10, minval=1)+length  = input.int(10, minval=1)-DER_avg = input(5, 'Average',   minval=1, inline='DER', group='Directional Energy Ratio')+DER_avg = input.int(5, 'Average',   minval=1, inline='DER', group='Directional Energy Ratio')-smooth  = input(3, 'Smoothing', minval=1, inline='DER', group='Directional Energy Ratio')+smooth  = input.int(3, 'Smoothing', minval=1, inline='DER', group='Directional Energy Ratio')-v_calc  = input('Relative', 'Calculation', options=['Relative', 'Full', 'None'], group='Volume Parameters')+v_calc  = input.string('Relative', 'Calculation', options=['Relative', 'Full', 'None'], group='Volume Parameters')-vlookbk = input(20, 'Lookback (for Relative)', minval=1, group='Volume Parameters')+vlookbk = input.int(20, 'Lookback (for Relative)', minval=1, group='Volume Parameters')uprsi1 = ta.rma(math.max(ta.change(rsi1SourceInput), 0), rsi1LengthInput)⋯alertcondition(short_exit_entry, 'Sell', 'Short exit')-strategy.entry('long', strategy.long, when=long_entry)+if long_entry+    strategy.entry('long', strategy.long)-strategy.close('long', when=long_exit_entry, comment=closeStatus)+if long_exit_entry+    strategy.close('long', comment=closeStatus)-strategy.entry('short', strategy.short, when=short_entry)+if short_entry+    strategy.entry('short', strategy.short)-strategy.close('short', when=short_exit_entry, comment=closeStatus)+if short_exit_entry+    strategy.close('short', comment=closeStatus)// stopPer = input(100, title='Stop Loss %', type=input.float) / 100⋯

Does it run in Pine Script v6?

No

The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 175 before, 1 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © vumanchu-//@version=5+//@version=6//  Thanks to dynausmaux for the code⋯

Settings

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

SettingDefaultType and rangeFeeds
Show WaveTrendtrueboolWT Wave 1 WT Wave 2
Show Buy dotstrueboolBuy circle
Show Gold dotstrueboolGold buy gold circle
Show Sell dotstrueboolSell circle
Show Div. dotstrueboolDivergence buy circle Divergence sell circle
Show Fast WTtrueboolVWAP
WT Channel Length9int (written input.integer)wt1 wt2 wtVwap wtOversold wtOverbought wtCross wtCrossUp wtCrossDown hwt1 hwt2 hwtOversold hwtOverbought hwtCross hwtCrossUp hwtCrossDown hwtCrosslast hwtCrossUplast hwtCrossDownlast hwtVwap wtCross_last wtCrossUp_last wtCrossDown_last
WT Average Length12int (written input.integer)wt1 wt2 wtVwap wtOversold wtOverbought wtCross wtCrossUp wtCrossDown hwt1 hwt2 hwtOversold hwtOverbought hwtCross hwtCrossUp hwtCrossDown hwtCrosslast hwtCrossUplast hwtCrossDownlast hwtVwap wtCross_last wtCrossUp_last wtCrossDown_last
WT MA Sourcehlc3sourcewt1 wt2 wtVwap wtOversold wtOverbought wtCross wtCrossUp wtCrossDown hwt1 hwt2 hwtOversold hwtOverbought hwtCross hwtCrossUp hwtCrossDown hwtCrosslast hwtCrossUplast hwtCrossDownlast hwtVwap wtCross_last wtCrossUp_last wtCrossDown_last
WT MA Length3int (written input.integer)wt1 wt2 wtVwap wtOversold wtOverbought wtCross wtCrossUp wtCrossDown hwt1 hwt2 hwtOversold hwtOverbought hwtCross hwtCrossUp hwtCrossDown hwtCrosslast hwtCrossUplast hwtCrossDownlast hwtVwap wtCross_last wtCrossUp_last wtCrossDown_last
WT Overbought Level 153int (written input.integer)wtOverbought
WT Overbought Level 260int (written input.integer)Over Bought Level 2
WT Overbought Level 3100int (written input.integer)Over Bought Level 3
WT Oversold Level 1-53int (written input.integer)wtOversold
WT Oversold Level 2-60int (written input.integer)Over Sold Level 2
WT Oversold Level 3-75int (written input.integer)wtGoldBuy
Show WT Regular DivergencestrueboolwtBearDivColor wtBullDivColor wtBearDivColor_add wtBullDivColor_add buySignalDiv sellSignalDiv wtGoldBuy
Show WT Hidden DivergencesfalseboolwtBearDivColor wtBullDivColor wtBearDivColor_add wtBullDivColor_add
Not apply OB/OS Limits on Hidden DivergencestrueboolwtBearDivHidden_ wtBullDivHidden_ rsiBearDivHidden_ rsiBullDivHidden_
WT Bearish Divergence min45int (written input.integer)wtFractalTop wtFractalBot wtLow_prev wtBearDiv wtBullDiv wtBearDivHidden wtBullDivHidden
WT Bullish Divergence min-65int (written input.integer)wtFractalTop wtFractalBot wtLow_prev wtBearDiv wtBullDiv wtBearDivHidden wtBullDivHidden
Show 2nd WT Regular DivergencestrueboolwtBearDivColor_add wtBullDivColor_add
WT 2nd Bearish Divergence15int (written input.integer)wtFractalTop_add wtFractalBot_add wtLow_prev_add wtBearDiv_add wtBullDiv_add wtBearDivHidden_add wtBullDivHidden_add
WT 2nd Bullish Divergence 15 min-40int (written input.integer)wtFractalTop_add wtFractalBot_add wtLow_prev_add wtBearDiv_add wtBullDiv_add wtBearDivHidden_add wtBullDivHidden_add
Show MFItrueboolMFI Bar TOP Line MFI Bar BOTTOM Line RSI+MFI Area
MFI Period60int (written input.integer)hrsimfi rsiMFI
MFI Area multiplier150floathrsimfi rsiMFI
MFI Area Y Pos2.5floatline 163
Show RSIfalseboolRSI
RSI Sourceclosesourcersi
RSI Length14int (written input.integer)rsi
RSI Oversold30int (written input.integer) · min 50 · max 100rsiColor
RSI Overbought60int (written input.integer) · min 0 · max 50rsiColor
Show RSI Regular DivergencesfalseboolrsiBearDivColor rsiBullDivColor buySignalDiv buySignalDiv_color sellSignalDiv wtGoldBuy
Show RSI Hidden DivergencesfalseboolrsiBearDivColor rsiBullDivColor
RSI Bearish Divergence min60int (written input.integer)rsiFractalTop rsiFractalBot rsiLow_prev rsiBearDiv rsiBullDiv rsiBearDivHidden rsiBullDivHidden
RSI Bullish Divergence min30int (written input.integer)rsiFractalTop rsiFractalBot rsiLow_prev rsiBearDiv rsiBullDiv rsiBearDivHidden rsiBullDivHidden
Show Stochastic RSItrueboolStoch K Stoch D
Use Log?trueboolstochK stochD
Use Average of both K & DfalseboolstochK stochD
Stochastic RSI SourceclosesourcestochK stochD
Stochastic RSI Length14int (written input.integer)stochK stochD
RSI Length 14int (written input.integer)stochK stochD
Stochastic RSI K Smooth3int (written input.integer)stochK stochD
Stochastic RSI D Smooth3int (written input.integer)stochK stochD
Show Stoch Regular DivergencesfalseboolstochBearDivColor stochBullDivColor buySignalDiv sellSignalDiv
Show Stoch Hidden DivergencesfalseboolstochBearDivColor stochBullDivColor
Show Schaff TC linefalseboolSchaff Trend Cycle 1 Schaff Trend Cycle 2
Schaff TC SourceclosesourcetcVal
Schaff TC10int (written input.integer)tcVal
Schaff TC Fast Lenght23int (written input.integer)tcVal
Schaff TC Slow Length50int (written input.integer)tcVal
Schaff TC Factor0.5floatdelta stcReturn
Show Sommi flagfalseboolSommi bearish flag Sommi bullish flag
Show Sommi F. WavefalseboolSommi higher VWAP
Sommi F. Wave timeframe720stringsommiBearish sommiBullish hvwap
F. Wave Bear Level (less than)0int (written input.integer)bearPattern
F. Wave Bull Level (more than)0int (written input.integer)bullPattern
WT Bear Level (more than)0int (written input.integer)bearPattern
WT Bull Level (less than)0int (written input.integer)bullPattern
Money flow Bear Level (less than)0int (written input.integer)bearPattern
Money flow Bull Level (more than)0int (written input.integer)bullPattern
Show Sommi diamondfalseboolSommi bearish diamond Sommi bullish diamond
HTF Candle Res. 160stringsommiBearishDiamond sommiBullishDiamond
HTF Candle Res. 2240stringsommiBearishDiamond sommiBullishDiamond
WT Bear Level (More than)0int (written input.integer)bearPattern
WT Bull Level (Less than)0int (written input.integer)bullPattern
Show MACD ColorsfalseboolWT Wave 1 WT Wave 2
MACD Colors MACD TF240stringmacd signal hist macdWT1Color macdWT2Color
Dark modefalseboolbgcolor WT Wave 2
Len (no label in the script)14intSmoothedTrueRange SmoothedDirectionalMovementPlus SmoothedDirectionalMovementMinus ADX
Th (no label in the script)20intunused
Length (no label in the script)10int · min 1alpha beta epsilon zeta dem sup
RSI Settings
RSI Length100int · min 1uprsi1 downrsi1
Sourceclosesourceuprsi1 downrsi1
RSI Length25int · min 1uprsi2 downrsi2
Sourceclosesourceuprsi2 downrsi2
Directional Energy Ratio
Average5int · min 1adp asp
Smoothing3int · min 1anp_s
Volume Parameters
CalculationRelativestring · options ['Relative', 'Full', 'None']vola
Lookback (for Relative)20int · min 1vola

What it calculates

  • Valuewhen (valuewhen, ta.valuewhen in v5)fractalTop, src[2], 0highPrev · line 152
  • Valuewhen (valuewhen, ta.valuewhen in v5)fractalTop, high[2], 0highPrice · line 153
  • Valuewhen (valuewhen, ta.valuewhen in v5)fractalBot, src[2], 0lowPrev · line 154
  • Valuewhen (valuewhen, ta.valuewhen in v5)fractalBot, low[2], 0lowPrice · line 155
  • EMA (ema, ta.ema in v5)tfsrc, chlenesa · line 168
  • EMA (ema, ta.ema in v5)abs(tfsrc - esa), chlende · line 169
  • Cross (cross, ta.cross in v5)wt1[2], wt2[2]wtCrosslast · line 179
  • EMA (ema, ta.ema in v5)src, fastLengthema1 · line 185
  • EMA (ema, ta.ema in v5)src, slowLengthema2 · line 186
  • Lowest (lowest, ta.lowest in v5)macdVal, Length (10)alpha · line 188
  • Highest (highest, ta.highest in v5)macdVal, Length (10)beta · line 189
  • Lowest (lowest, ta.lowest in v5)delta, Length (10)epsilon · line 194
  • Highest (highest, ta.highest in v5)delta, Length (10)zeta · line 195
  • RSI (rsi, ta.rsi in v5)RSI Source (close), RSI Length (14)rsi · line 274
  • SMA / Stoch (sma, ta.sma in v5)stoch(rsi, rsi, rsi, _stochlen), _smoothkkk · line 205
  • SMA (sma, ta.sma in v5)kk, _smoothdd1 · line 206
  • EMA (ema, ta.ema in v5)src, fastlenfast_ma · line 212
  • EMA (ema, ta.ema in v5)src, slowlenslow_ma · line 213
  • Valuewhen (valuewhen, ta.valuewhen in v5)wtFractalBot, rsi[2], 0lastRsi · line 339
  • SMA (sma, ta.sma in v5)DX, Len (14)ADX · line 419
  • Lowest (lowest, ta.lowest in v5)_value, _lengthmin_value · line 436
  • Highest (highest, ta.highest in v5)_value, _lengthmax_value · line 437
  • RMA / Change (rma, ta.rma in v5)max(change(rsi1SourceInput), 0), RSI Length (100)uprsi1 · line 449
  • RMA / Change (rma, ta.rma in v5)max(change(rsi2SourceInput), 0), RSI Length (25)uprsi2 · line 450
  • RMA / Change (rma, ta.rma in v5)-min(change(rsi1SourceInput), 0), RSI Length (100)downrsi1 · line 451
  • RMA / Change (rma, ta.rma in v5)-min(change(rsi2SourceInput), 0), RSI Length (25)downrsi2 · line 452
  • Highest / Lowest (highest, ta.highest in v5)1R · line 459
  • Change (change, ta.change in v5)pricesr · line 460
  • WMA (wma, ta.wma in v5)c_plus, Length (10)dem · line 467
  • WMA (wma, ta.wma in v5)c_minus, Length (10)sup · line 468
  • WMA (wma, ta.wma in v5)dem, Average (5)adp · line 470
  • WMA (wma, ta.wma in v5)sup, Average (5)asp · line 471
  • WMA (wma, ta.wma in v5)anp, Smoothing (3)anp_s · line 473

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

Order rules

OrderFires whenBy defaultLine
Open long longlong_entrywt2 < wt1On505
Close longlong_exit_entryOn506
Open short shortshort_entrywt2 > wt1On507
Close shortshort_exit_entryOn508

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

Alerts

AlertCallMessageLine
BuyalertconditionLong entry501
BuyalertconditionLong exit502
SellalertconditionShort entry503
SellalertconditionShort exit504

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

9/58trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.

The script reads request.security() at the chart's own timeframe, which Zeal Terminal's engine answers one bar late in live mode but not in history, so this replay cannot tell repainting from that engine issue.

  • CheckHigher-timeframe data4 security call(s) use lookahead_on (line 230, 231, 232, 233). Without a [1] offset this reads future bars in history.
  • 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 heikinashi:SYMBOL 60, heikinashi:SYMBOL 240, BINANCE:BTCUSDT 720, heikinashi:BINANCE:BTCUSDT 60, heikinashi:BINANCE:BTCUSDT 240, BINANCE:BTCUSDT 240, and that data is not available here (a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data). Its results would rest on empty values.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market5942%−$978.24
Sideways market7441%$3,221.62
Falling market4245%$5,418.35

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

36.8%

The 95th percentile of the worst drawdown when the same 175 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 17.5% to 36.8%; the tick is what actually happened, 17.9%. Order luck alone moves it this much.

0%42%
The first 150 of 175 trades
SideEntryExitBarsP&L
short25 Feb 2024 51,568.2027 Feb 2024 54,476.502−$569.11
long27 Feb 2024 54,476.503 Mar 2024 61,987.305$1,373.38
short3 Mar 2024 61,987.3025 Mar 2024 67,210.0022−$847.76
long25 Mar 2024 67,210.002 Apr 2024 69,649.808$357.92
short2 Apr 2024 69,649.807 Apr 2024 68,896.005$103.26
long7 Apr 2024 68,896.0013 Apr 2024 67,116.506−$263.22
short13 Apr 2024 67,116.5020 Apr 2024 63,818.007$486.58
long20 Apr 2024 63,818.0026 Apr 2024 64,498.306$101.58
short26 Apr 2024 64,498.304 May 2024 62,882.008$245.66
long4 May 2024 62,882.009 May 2024 61,193.005−$273.53
short9 May 2024 61,193.0014 May 2024 62,940.105−$290.57
long14 May 2024 62,940.1024 May 2024 67,969.7010$793.90
short24 May 2024 67,969.704 Jun 2024 68,809.9011−$128.65
long4 Jun 2024 68,809.908 Jun 2024 69,355.604$74.29
short8 Jun 2024 69,355.6027 Jun 2024 60,865.0019$1,219.52
long27 Jun 2024 60,865.004 Jul 2024 60,208.607−$112.82
short4 Jul 2024 60,208.609 Jul 2024 56,714.605$575.45
long9 Jul 2024 56,714.6024 Jul 2024 65,936.0015$1,620.52
short24 Jul 2024 65,936.0028 Jul 2024 67,896.504−$302.41
long28 Jul 2024 67,896.5030 Jul 2024 66,784.702−$168.71
short30 Jul 2024 66,784.709 Aug 2024 61,686.0010$758.64
long9 Aug 2024 61,686.0016 Aug 2024 57,541.107−$676.78
short16 Aug 2024 57,541.1018 Aug 2024 59,492.002−$344.14
long18 Aug 2024 59,492.0028 Aug 2024 59,415.0010−$17.94
short28 Aug 2024 59,415.0010 Sep 2024 57,042.0013$394.49
long10 Sep 2024 57,042.0017 Sep 2024 58,214.007$200.41
short17 Sep 2024 58,214.0018 Sep 2024 60,314.001−$365.83
long18 Sep 2024 60,314.0024 Sep 2024 63,340.006$496.58
short24 Sep 2024 63,340.0028 Sep 2024 65,769.904−$388.73
long28 Sep 2024 65,769.9030 Sep 2024 65,602.002−$30.53
short30 Sep 2024 65,602.007 Oct 2024 62,819.907$419.19
long7 Oct 2024 62,819.9010 Oct 2024 60,636.003−$352.56
short10 Oct 2024 60,636.0013 Oct 2024 63,206.203−$428.98
long13 Oct 2024 63,206.2022 Oct 2024 67,377.509$654.78
short22 Oct 2024 67,377.5028 Oct 2024 68,021.706−$100.63
long28 Oct 2024 68,021.702 Nov 2024 69,496.005$211.69
short2 Nov 2024 69,496.007 Nov 2024 75,572.005−$879.51
long7 Nov 2024 75,572.0015 Nov 2024 87,325.608$1,549.90
short15 Nov 2024 87,325.6022 Nov 2024 98,317.107−$1,264.00
long22 Nov 2024 98,317.1024 Nov 2024 97,672.402−$70.56
short24 Nov 2024 97,672.4030 Nov 2024 97,460.006$16.75
long30 Nov 2024 97,460.002 Dec 2024 97,185.202−$33.19
short2 Dec 2024 97,185.205 Dec 2024 98,587.303−$149.31
long5 Dec 2024 98,587.3010 Dec 2024 97,276.505−$137.93
short10 Dec 2024 97,276.5013 Dec 2024 100,004.003−$285.49
long13 Dec 2024 100,004.0019 Dec 2024 100,204.006$14.97
short19 Dec 2024 100,204.0026 Dec 2024 99,429.607$72.30
long26 Dec 2024 99,429.6027 Dec 2024 95,791.601−$370.80
short27 Dec 2024 95,791.602 Jan 2025 94,591.806$120.28
long2 Jan 2025 94,591.809 Jan 2025 95,060.607$44.55
short9 Jan 2025 95,060.6015 Jan 2025 96,560.906−$162.86
long15 Jan 2025 96,560.9024 Jan 2025 103,910.009$755.94
short24 Jan 2025 103,910.0031 Jan 2025 104,723.007−$83.22
long31 Jan 2025 104,723.002 Feb 2025 100,636.002−$395.20
short2 Feb 2025 100,636.0011 Feb 2025 97,430.809$313.54
long11 Feb 2025 97,430.8018 Feb 2025 95,780.007−$174.39
short18 Feb 2025 95,780.0021 Feb 2025 98,305.003−$268.69
long21 Feb 2025 98,305.0024 Feb 2025 96,258.003−$213.18
short24 Feb 2025 96,258.002 Mar 2025 86,064.506$1,054.24
long2 Mar 2025 86,064.509 Mar 2025 86,222.507$13.34
short9 Mar 2025 86,222.5013 Mar 2025 83,680.104$289.93
long13 Mar 2025 83,680.1023 Mar 2025 83,840.6010$14.17
short23 Mar 2025 83,840.6024 Mar 2025 86,082.501−$272.47
long24 Mar 2025 86,082.5029 Mar 2025 84,424.405−$197.57
short29 Mar 2025 84,424.403 Apr 2025 82,516.305$221.07
long3 Apr 2025 82,516.304 Apr 2025 83,213.101$79.42
short4 Apr 2025 83,213.1010 Apr 2025 82,615.206$66.87
long10 Apr 2025 82,615.2027 Apr 2025 94,628.0017$1,448.70
short27 Apr 2025 94,628.003 May 2025 96,887.106−$243.80
long3 May 2025 96,887.104 May 2025 95,856.401−$111.36
short4 May 2025 95,856.408 May 2025 97,030.504−$127.51
long8 May 2025 97,030.5013 May 2025 102,791.005$588.56
short13 May 2025 102,791.0019 May 2025 106,454.006−$361.44
long19 May 2025 106,454.0025 May 2025 107,762.006$117.80
short25 May 2025 107,762.008 Jun 2025 105,552.0014$200.11
long8 Jun 2025 105,552.0013 Jun 2025 105,672.005$6.33
short13 Jun 2025 105,672.0017 Jun 2025 106,795.004−$111.28
long17 Jun 2025 106,795.0018 Jun 2025 104,551.001−$215.01
short18 Jun 2025 104,551.0024 Jun 2025 105,334.006−$79.89
long24 Jun 2025 105,334.002 Jul 2025 105,681.008$27.95
short2 Jul 2025 105,681.003 Jul 2025 108,850.001−$304.89
long3 Jul 2025 108,850.006 Jul 2025 108,198.003−$64.84
short6 Jul 2025 108,198.007 Jul 2025 109,204.001−$97.98
long7 Jul 2025 109,204.009 Jul 2025 108,923.002−$30.71
short9 Jul 2025 108,923.0010 Jul 2025 111,234.001−$217.22
long10 Jul 2025 111,234.0016 Jul 2025 117,758.006$581.37
short16 Jul 2025 117,758.0028 Jul 2025 119,416.0012−$145.79
long28 Jul 2025 119,416.0030 Jul 2025 117,951.002−$127.63
short30 Jul 2025 117,951.005 Aug 2025 115,055.006$240.56
long5 Aug 2025 115,055.0016 Aug 2025 117,342.0011$193.73
short16 Aug 2025 117,342.0024 Aug 2025 115,438.008$157.30
long24 Aug 2025 115,438.0025 Aug 2025 113,494.001−$173.40
short25 Aug 2025 113,494.0029 Aug 2025 112,567.004$76.67
long29 Aug 2025 112,567.0030 Aug 2025 108,377.001−$377.09
short30 Aug 2025 108,377.002 Sep 2025 109,237.003−$84.37
long2 Sep 2025 109,237.0016 Sep 2025 115,350.0014$554.40
short16 Sep 2025 115,350.0017 Sep 2025 116,789.001−$129.80
long17 Sep 2025 116,789.0018 Sep 2025 116,448.001−$34.22
short18 Sep 2025 116,448.0019 Sep 2025 117,074.001−$58.77
long19 Sep 2025 117,074.0020 Sep 2025 115,632.001−$128.07
short20 Sep 2025 115,632.0029 Sep 2025 112,164.009$295.03
long29 Sep 2025 112,164.008 Oct 2025 121,333.009$812.26
short8 Oct 2025 121,333.0021 Oct 2025 110,532.0013$885.41
long21 Oct 2025 110,532.0023 Oct 2025 107,567.002−$273.15
short23 Oct 2025 107,567.0024 Oct 2025 110,078.001−$238.47
long24 Oct 2025 110,078.0030 Oct 2025 110,021.006−$10.17
short30 Oct 2025 110,021.009 Nov 2025 102,313.0010$695.80
long9 Nov 2025 102,313.0013 Nov 2025 101,654.004−$69.35
short13 Nov 2025 101,654.0024 Nov 2025 86,830.0011$1,453.68
long24 Nov 2025 86,830.002 Dec 2025 86,286.008−$67.63
short2 Dec 2025 86,286.004 Dec 2025 93,429.902−$833.14
long4 Dec 2025 93,429.907 Dec 2025 89,236.803−$453.69
short7 Dec 2025 89,236.809 Dec 2025 90,634.402−$161.65
long9 Dec 2025 90,634.4013 Dec 2025 90,268.404−$45.36
short13 Dec 2025 90,268.4021 Dec 2025 88,360.908$206.37
long21 Dec 2025 88,360.9025 Dec 2025 87,669.404−$83.24
short25 Dec 2025 87,669.4027 Dec 2025 87,369.602$29.21
long27 Dec 2025 87,369.608 Jan 2026 91,364.2012$452.09
short8 Jan 2026 91,364.2014 Jan 2026 95,414.006−$448.37
long14 Jan 2026 95,414.0017 Jan 2026 95,550.903$9.35
short17 Jan 2026 95,550.9029 Jan 2026 89,300.0012$649.36
long29 Jan 2026 89,300.0030 Jan 2026 84,650.201−$525.57
short30 Jan 2026 84,650.208 Feb 2026 69,289.409$1,810.07
long8 Feb 2026 69,289.4019 Feb 2026 66,461.0011−$413.10
short19 Feb 2026 66,461.0021 Feb 2026 68,020.002−$239.63
long21 Feb 2026 68,020.0024 Feb 2026 64,656.003−$499.44
short24 Feb 2026 64,656.0026 Feb 2026 67,988.002−$520.48
long26 Feb 2026 67,988.001 Mar 2026 66,973.303−$154.22
short1 Mar 2026 66,973.302 Mar 2026 65,776.501$173.74
long2 Mar 2026 65,776.508 Mar 2026 67,262.906$220.93
short8 Mar 2026 67,262.9011 Mar 2026 69,948.603−$404.39
long11 Mar 2026 69,948.6019 Mar 2026 71,246.608$180.50
short19 Mar 2026 71,246.6026 Mar 2026 71,336.507−$17.63
long26 Mar 2026 71,336.5027 Mar 2026 68,820.301−$357.64
short27 Mar 2026 68,820.301 Apr 2026 68,284.505$72.88
long1 Apr 2026 68,284.504 Apr 2026 66,964.303−$198.29
short4 Apr 2026 66,964.305 Apr 2026 67,300.401−$55.21
long5 Apr 2026 67,300.4013 Apr 2026 70,741.608$506.18
short13 Apr 2026 70,741.6014 Apr 2026 74,418.001−$524.83
long14 Apr 2026 74,418.0020 Apr 2026 73,801.806−$87.78
short20 Apr 2026 73,801.8023 Apr 2026 78,178.203−$598.14
long23 Apr 2026 78,178.2026 Apr 2026 77,625.003−$75.75
short26 Apr 2026 77,625.002 May 2026 78,231.106−$83.10
long2 May 2026 78,231.109 May 2026 80,193.207$245.74
short9 May 2026 80,193.2011 May 2026 82,210.102−$256.57
long11 May 2026 82,210.1013 May 2026 80,504.502−$212.42
short13 May 2026 80,504.5025 May 2026 77,065.0012$422.35
long25 May 2026 77,065.0028 May 2026 74,449.303−$344.32
short28 May 2026 74,449.301 Jun 2026 73,674.404$99.11
long1 Jun 2026 73,674.402 Jun 2026 71,408.901−$312.42

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
VuManChu Cipher B + Divergences Strategy this page—v4 strategy+76.6%17518.4%
Top 40 High Low Strategy for SPY, 5min by PtGamblerrma sma cross ema rsi highest lowestv5 strategyNo trades on this market
SPX Scalping Strategy by connor2279sma ema lowest wma rma crossv5 strategy+1.5%1095.0%
Stochastic RSI + WMA + SMA strat by tweakerIDrsi sma wma lowest highest valuewhenv4 strategy−11.9%437.9%
MACD Willy Strategy by PtGamblerrma sma ema highest lowest wmav5 strategyNo trades on this market
TradeIQ - Crazy Scalping Trading Strategy [Kaspricci] by Kaspriccihighest lowest valuewhen sma cross rsiv5 strategy+1,326.3%61,046.4%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 110 msWith a workaround 1,000 bars in 1,021 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/// © vumanchu//@version=4//  Thanks to dynausmaux for the code//  Thanks to falconCoin for https://www.tradingview.com/script/KVfgBvDd-Market-Cipher-B-Free-version-with-Buy-and-sell/ inspired me to start this.//  Thanks to LazyBear for WaveTrend Oscillator https://www.tradingview.com/script/2KE8wTuF-Indicator-WaveTrend-Oscillator-WT///  Thanks to RicardoSantos for https://www.tradingview.com/script/3oeDh0Yq-RS-Price-Divergence-Detector-V2///  Thanks to LucemAnb for Plain Stochastic Divergence https://www.tradingview.com/script/FCUgF8ag-Plain-Stochastic-Divergence///  Thanks to andreholanda73 for MFI+RSI Area https://www.tradingview.com/script/UlGZzUAr///  I especially want to thank TradingView for its platform that facilitates development and learning.////  CIRCLES & TRIANGLES://    - LITTLE CIRCLE: They appear at all WaveTrend wave crossings.//    - GREEN CIRCLE: The wavetrend waves are at the oversold level and have crossed up (bullish).//    - RED CIRCLE: The wavetrend waves are at the overbought level and have crossed down (bearish).//    - GOLD/ORANGE CIRCLE: When RSI is below 20, WaveTrend waves are below or equal to -80 and have crossed up after good bullish divergence (DONT BUY WHEN GOLD CIRCLE APPEAR).//    - None of these circles are certain signs to trade. It is only information that can help you. //    - PURPLE TRIANGLE: Appear when a bullish or bearish divergence is formed and WaveTrend waves crosses at overbought and oversold points.////  NOTES://    - I am not an expert trader or know how to program pine script as such, in fact it is my first indicator only to study and all the code is copied and modified from other codes that are published in TradingView.//    - I am very grateful to the entire TV community that publishes codes so that other newbies like me can learn and present their results. This is an attempt to imitate Market Cipher B. //    - Settings by default are for 4h timeframe, divergences are more stronger and accurate. Haven't tested in all timeframes, only 2h and 4h.//    - If you get an interesting result in other timeframes I would be very grateful if you would comment your configuration to implement it or at least check it.////  CONTRIBUTIONS://    - Tip/Idea: Add higher timeframe analysis for bearish/bullish patterns at the current timeframe.//    + Bearish/Bullish FLAG://      - MFI+RSI Area are RED (Below 0).//      - Wavetrend waves are above 0 and crosses down.//      - VWAP Area are below 0 on higher timeframe.//      - This pattern reversed becomes bullish.//    - Tip/Idea: Check the last heikinashi candle from 2 higher timeframe//    + Bearish/Bullish DIAMOND://      - HT Candle is red//      - WT > 0 and crossed down// study(title = 'VuManChu B Divergences', shorttitle = 'VMC Cipher_B_Divergences')// PARAMETERS {// WaveTrendwtShow = input(true, title = 'Show WaveTrend', type = input.bool)wtBuyShow = input(true, title = 'Show Buy dots', type = input.bool)wtGoldShow = input(true, title = 'Show Gold dots', type = input.bool)wtSellShow = input(true, title = 'Show Sell dots', type = input.bool)wtDivShow = input(true, title = 'Show Div. dots', type = input.bool)vwapShow = input(true, title = 'Show Fast WT', type = input.bool)wtChannelLen = input(9, title = 'WT Channel Length', type = input.integer)wtAverageLen = input(12, title = 'WT Average Length', type = input.integer)wtMASource = input(hlc3, title = 'WT MA Source', type = input.source)wtMALen = input(3, title = 'WT MA Length', type = input.integer)// WaveTrend Overbought & Oversold linesobLevel = input(53, title = 'WT Overbought Level 1', type = input.integer)obLevel2 = input(60, title = 'WT Overbought Level 2', type = input.integer)obLevel3 = input(100, title = 'WT Overbought Level 3', type = input.integer)osLevel = input(-53, title = 'WT Oversold Level 1', type = input.integer)osLevel2 = input(-60, title = 'WT Oversold Level 2', type = input.integer)osLevel3 = input(-75, title = 'WT Oversold Level 3', type = input.integer)// Divergence WTwtShowDiv = input(true, title = 'Show WT Regular Divergences', type = input.bool)wtShowHiddenDiv = input(false, title = 'Show WT Hidden Divergences', type = input.bool)showHiddenDiv_nl = input(true, title = 'Not apply OB/OS Limits on Hidden Divergences', type = input.bool)wtDivOBLevel = input(45, title = 'WT Bearish Divergence min', type = input.integer)wtDivOSLevel = input(-65, title = 'WT Bullish Divergence min', type = input.integer)// Divergence extra rangewtDivOBLevel_addshow = input(true, title = 'Show 2nd WT Regular Divergences', type = input.bool)wtDivOBLevel_add = input(15, title = 'WT 2nd Bearish Divergence', type = input.integer)wtDivOSLevel_add = input(-40, title = 'WT 2nd Bullish Divergence 15 min', type = input.integer)// RSI+MFIrsiMFIShow = input(true, title = 'Show MFI', type = input.bool)rsiMFIperiod = input(60,title = 'MFI Period', type = input.integer)rsiMFIMultiplier = input(150, title = 'MFI Area multiplier', type = input.float)rsiMFIPosY = input(2.5, title = 'MFI Area Y Pos', type = input.float)// RSIrsiShow = input(false, title = 'Show RSI', type = input.bool)rsiSRC = input(close, title = 'RSI Source', type = input.source)rsiLen = input(14, title = 'RSI Length', type = input.integer)rsiOversold = input(30, title = 'RSI Oversold', minval = 50, maxval = 100, type = input.integer)rsiOverbought = input(60, title = 'RSI Overbought', minval = 0, maxval = 50, type = input.integer)// Divergence RSIrsiShowDiv = input(false, title = 'Show RSI Regular Divergences', type = input.bool)rsiShowHiddenDiv = input(false, title = 'Show RSI Hidden Divergences', type = input.bool)rsiDivOBLevel = input(60, title = 'RSI Bearish Divergence min', type = input.integer)rsiDivOSLevel = input(30, title = 'RSI Bullish Divergence min', type = input.integer)// RSI StochasticstochShow = input(true, title = 'Show Stochastic RSI', type = input.bool)stochUseLog = input(true, title=' Use Log?', type = input.bool)stochAvg = input(false, title='Use Average of both K & D', type = input.bool)stochSRC = input(close, title = 'Stochastic RSI Source', type = input.source)stochLen = input(14, title = 'Stochastic RSI Length', type = input.integer)stochRsiLen = input(14, title = 'RSI Length ', type = input.integer)stochKSmooth = input(3, title = 'Stochastic RSI K Smooth', type = input.integer)stochDSmooth = input(3, title = 'Stochastic RSI D Smooth', type = input.integer)// Divergence stochstochShowDiv = input(false, title = 'Show Stoch Regular Divergences', type = input.bool)stochShowHiddenDiv = input(false, title = 'Show Stoch Hidden Divergences', type = input.bool)// Schaff Trend CycletcLine = input(false, title="Show Schaff TC line", type=input.bool)tcSRC = input(close, title = 'Schaff TC Source', type = input.source)tclength = input(10, title="Schaff TC", type=input.integer)tcfastLength = input(23, title="Schaff TC Fast Lenght", type=input.integer)tcslowLength = input(50, title="Schaff TC Slow Length", type=input.integer)tcfactor = input(0.5, title="Schaff TC Factor", type=input.float)// Sommi FlagsommiFlagShow = input(false, title = 'Show Sommi flag', type = input.bool)sommiShowVwap = input(false, title = 'Show Sommi F. Wave', type = input.bool)sommiVwapTF = input('720', title = 'Sommi F. Wave timeframe', type = input.string)sommiVwapBearLevel = input(0, title = 'F. Wave Bear Level (less than)', type = input.integer)sommiVwapBullLevel = input(0, title = 'F. Wave Bull Level (more than)', type = input.integer)soomiFlagWTBearLevel = input(0, title = 'WT Bear Level (more than)', type = input.integer) soomiFlagWTBullLevel = input(0, title = 'WT Bull Level (less than)', type = input.integer) soomiRSIMFIBearLevel = input(0, title = 'Money flow Bear Level (less than)', type = input.integer) soomiRSIMFIBullLevel = input(0, title = 'Money flow Bull Level (more than)', type = input.integer) // Sommi DiamondsommiDiamondShow = input(false, title = 'Show Sommi diamond', type = input.bool)sommiHTCRes = input('60', title = 'HTF Candle Res. 1', type = input.string)sommiHTCRes2 = input('240', title = 'HTF Candle Res. 2', type = input.string)soomiDiamondWTBearLevel = input(0, title = 'WT Bear Level (More than)', type = input.integer)soomiDiamondWTBullLevel = input(0, title = 'WT Bull Level (Less than)', type = input.integer)// macd ColorsmacdWTColorsShow = input(false, title = 'Show MACD Colors', type = input.bool)macdWTColorsTF = input('240', title = 'MACD Colors MACD TF', type = input.string)darkMode = input(false, title = 'Dark mode', type = input.bool)// ColorscolorRed = #ff0000colorPurple = #e600e6colorGreen = #3fff00colorOrange = #e2a400colorYellow = #ffe500colorWhite = #ffffffcolorPink = #ff00f0colorBluelight = #31c0ffcolorWT1 = #90caf9colorWT2 = #0d47a1colorWT2_ = #131722colormacdWT1a = #4caf58colormacdWT1b = #af4c4ccolormacdWT1c = #7ee57ecolormacdWT1d = #ff3535colormacdWT2a = #305630colormacdWT2b = #310101colormacdWT2c = #132213colormacdWT2d = #770000// } PARAMETERS// FUNCTIONS {  // Divergences f_top_fractal(src) => src[4] < src[2] and src[3] < src[2] and src[2] > src[1] and src[2] > src[0]f_bot_fractal(src) => src[4] > src[2] and src[3] > src[2] and src[2] < src[1] and src[2] < src[0]f_fractalize(src) => f_top_fractal(src) ? 1 : f_bot_fractal(src) ? -1 : 0f_findDivs(src, topLimit, botLimit, useLimits) =>    fractalTop = f_fractalize(src) > 0 and (useLimits ? src[2] >= topLimit : true) ? src[2] : na    fractalBot = f_fractalize(src) < 0 and (useLimits ? src[2] <= botLimit : true) ? src[2] : na    highPrev = valuewhen(fractalTop, src[2], 0)[2]    highPrice = valuewhen(fractalTop, high[2], 0)[2]    lowPrev = valuewhen(fractalBot, src[2], 0)[2]    lowPrice = valuewhen(fractalBot, low[2], 0)[2]    bearSignal = fractalTop and high[2] > highPrice and src[2] < highPrev    bullSignal = fractalBot and low[2] < lowPrice and src[2] > lowPrev    bearDivHidden = fractalTop and high[2] < highPrice and src[2] > highPrev    bullDivHidden = fractalBot and low[2] > lowPrice and src[2] < lowPrev    [fractalTop, fractalBot, lowPrev, bearSignal, bullSignal, bearDivHidden, bullDivHidden]        // RSI+MFIf_rsimfi(_period, _multiplier, _tf) => security(syminfo.tickerid, _tf, sma(((close - open) / (high - low)) * _multiplier, _period) - rsiMFIPosY)   // WaveTrendf_wavetrend(src, chlen, avg, malen, tf) =>    tfsrc = security(syminfo.tickerid, tf, src)    esa = ema(tfsrc, chlen)    de = ema(abs(tfsrc - esa), chlen)    ci = (tfsrc - esa) / (0.015 * de)    wt1 = security(syminfo.tickerid, tf, ema(ci, avg))    wt2 = security(syminfo.tickerid, tf, sma(wt1, malen))    wtVwap = wt1 - wt2    wtOversold = wt2 <= osLevel    wtOverbought = wt2 >= obLevel    wtCross = cross(wt1, wt2)    wtCrossUp = wt2 - wt1 <= 0    wtCrossDown = wt2 - wt1 >= 0    wtCrosslast = cross(wt1[2], wt2[2])    wtCrossUplast = wt2[2] - wt1[2] <= 0    wtCrossDownlast = wt2[2] - wt1[2] >= 0    [wt1, wt2, wtOversold, wtOverbought, wtCross, wtCrossUp, wtCrossDown, wtCrosslast, wtCrossUplast, wtCrossDownlast, wtVwap]// Schaff Trend Cyclef_tc(src, length, fastLength, slowLength) =>    ema1 = ema(src, fastLength)    ema2 = ema(src, slowLength)    macdVal = ema1 - ema2       alpha = lowest(macdVal, length)    beta = highest(macdVal, length) - alpha    gamma = (macdVal - alpha) / beta * 100    gamma := beta > 0 ? gamma : nz(gamma[1])    delta = gamma    delta := na(delta[1]) ? delta : delta[1] + tcfactor * (gamma - delta[1])    epsilon = lowest(delta, length)    zeta = highest(delta, length) - epsilon    eta = (delta - epsilon) / zeta * 100    eta := zeta > 0 ? eta : nz(eta[1])    stcReturn = eta    stcReturn := na(stcReturn[1]) ? stcReturn : stcReturn[1] + tcfactor * (eta - stcReturn[1])    stcReturn// Stochastic RSIf_stochrsi(_src, _stochlen, _rsilen, _smoothk, _smoothd, _log, _avg) =>    src = _log ? log(_src) : _src    rsi = rsi(src, _rsilen)    kk = sma(stoch(rsi, rsi, rsi, _stochlen), _smoothk)    d1 = sma(kk, _smoothd)    avg_1 = avg(kk, d1)    k = _avg ? avg_1 : kk    [k, d1]// MACDf_macd(src, fastlen, slowlen, sigsmooth, tf) =>    fast_ma = security(syminfo.tickerid, tf, ema(src, fastlen))    slow_ma = security(syminfo.tickerid, tf, ema(src, slowlen))    macd = fast_ma - slow_ma,    signal = security(syminfo.tickerid, tf, sma(macd, sigsmooth))    hist = macd - signal    [macd, signal, hist]// MACD Colors on WT    f_macdWTColors(tf) =>    hrsimfi = f_rsimfi(rsiMFIperiod, rsiMFIMultiplier, tf)    [macd, signal, hist] = f_macd(close, 28, 42, 9, macdWTColorsTF)    macdup = macd >= signal    macddown = macd <= signal    macdWT1Color = macdup ? hrsimfi > 0 ? colormacdWT1c : colormacdWT1a : macddown ? hrsimfi < 0 ? colormacdWT1d : colormacdWT1b : na    macdWT2Color = macdup ? hrsimfi < 0 ? colormacdWT2c : colormacdWT2a : macddown ? hrsimfi < 0 ? colormacdWT2d : colormacdWT2b : na     [macdWT1Color, macdWT2Color]    // Get higher timeframe candlef_getTFCandle(_tf) =>     _open  = security(heikinashi(syminfo.tickerid), _tf, open, barmerge.gaps_off, barmerge.lookahead_on)    _close = security(heikinashi(syminfo.tickerid), _tf, close, barmerge.gaps_off, barmerge.lookahead_on)    _high  = security(heikinashi(syminfo.tickerid), _tf, high, barmerge.gaps_off, barmerge.lookahead_on)    _low   = security(heikinashi(syminfo.tickerid), _tf, low, barmerge.gaps_off, barmerge.lookahead_on)    hl2   = (_high + _low) / 2.0    newBar = change(_open)    candleBodyDir = _close > _open    [candleBodyDir, newBar]// Sommi flagf_findSommiFlag(tf, wt1, wt2, rsimfi, wtCross, wtCrossUp, wtCrossDown) =>        [hwt1, hwt2, hwtOversold, hwtOverbought, hwtCross, hwtCrossUp, hwtCrossDown, hwtCrosslast, hwtCrossUplast, hwtCrossDownlast, hwtVwap] = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, tf)              bearPattern = rsimfi < soomiRSIMFIBearLevel and                   wt2 > soomiFlagWTBearLevel and                    wtCross and                    wtCrossDown and                    hwtVwap < sommiVwapBearLevel                       bullPattern = rsimfi > soomiRSIMFIBullLevel and                    wt2 < soomiFlagWTBullLevel and                    wtCross and                    wtCrossUp and                    hwtVwap > sommiVwapBullLevel        [bearPattern, bullPattern, hwtVwap]    f_findSommiDiamond(tf, tf2, wt1, wt2, wtCross, wtCrossUp, wtCrossDown) =>    [candleBodyDir, newBar] = f_getTFCandle(tf)    [candleBodyDir2, newBar2] = f_getTFCandle(tf2)    bearPattern = wt2 >= soomiDiamondWTBearLevel and                   wtCross and                   wtCrossDown and                   not candleBodyDir and                   not candleBodyDir2                       bullPattern = wt2 <= soomiDiamondWTBullLevel and                   wtCross and                   wtCrossUp and                   candleBodyDir and                   candleBodyDir2     [bearPattern, bullPattern] // } FUNCTIONS  // CALCULATE INDICATORS {// RSIrsi = rsi(rsiSRC, rsiLen)rsiColor = rsi <= rsiOversold ? colorGreen : rsi >= rsiOverbought ? colorRed : colorPurple// RSI + MFI ArearsiMFI = f_rsimfi(rsiMFIperiod, rsiMFIMultiplier, timeframe.period)rsiMFIColor = rsiMFI > 0 ? #3ee145 : #ff3d2e// Calculates WaveTrend[wt1, wt2, wtOversold, wtOverbought, wtCross, wtCrossUp, wtCrossDown, wtCross_last, wtCrossUp_last, wtCrossDown_last, wtVwap] = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, timeframe.period) // Stochastic RSI[stochK, stochD] = f_stochrsi(stochSRC, stochLen, stochRsiLen, stochKSmooth, stochDSmooth, stochUseLog, stochAvg)// Schaff Trend CycletcVal = f_tc(tcSRC, tclength, tcfastLength, tcslowLength)// Sommi flag[sommiBearish, sommiBullish, hvwap] = f_findSommiFlag(sommiVwapTF, wt1, wt2, rsiMFI, wtCross,  wtCrossUp, wtCrossDown)//Sommi diamond[sommiBearishDiamond, sommiBullishDiamond] = f_findSommiDiamond(sommiHTCRes, sommiHTCRes2, wt1, wt2, wtCross, wtCrossUp, wtCrossDown)// macd colors[macdWT1Color, macdWT2Color] = f_macdWTColors(macdWTColorsTF)// WT Divergences[wtFractalTop, wtFractalBot, wtLow_prev, wtBearDiv, wtBullDiv, wtBearDivHidden, wtBullDivHidden] = f_findDivs(wt2, wtDivOBLevel, wtDivOSLevel, true)    [wtFractalTop_add, wtFractalBot_add, wtLow_prev_add, wtBearDiv_add, wtBullDiv_add, wtBearDivHidden_add, wtBullDivHidden_add] =  f_findDivs(wt2, wtDivOBLevel_add, wtDivOSLevel_add, true)[wtFractalTop_nl, wtFractalBot_nl, wtLow_prev_nl, wtBearDiv_nl, wtBullDiv_nl, wtBearDivHidden_nl, wtBullDivHidden_nl] =  f_findDivs(wt2, 0, 0, false)wtBearDivHidden_ = showHiddenDiv_nl ? wtBearDivHidden_nl : wtBearDivHiddenwtBullDivHidden_ = showHiddenDiv_nl ? wtBullDivHidden_nl : wtBullDivHiddenwtBearDivColor = (wtShowDiv and wtBearDiv) or (wtShowHiddenDiv and wtBearDivHidden_) ? colorRed : nawtBullDivColor = (wtShowDiv and wtBullDiv) or (wtShowHiddenDiv and wtBullDivHidden_) ? colorGreen : nawtBearDivColor_add = (wtShowDiv and (wtDivOBLevel_addshow and wtBearDiv_add)) or (wtShowHiddenDiv and (wtDivOBLevel_addshow and wtBearDivHidden_add)) ? #9a0202 : nawtBullDivColor_add = (wtShowDiv and (wtDivOBLevel_addshow and wtBullDiv_add)) or (wtShowHiddenDiv and (wtDivOBLevel_addshow and wtBullDivHidden_add)) ? #1b5e20 : na// RSI Divergences[rsiFractalTop, rsiFractalBot, rsiLow_prev, rsiBearDiv, rsiBullDiv, rsiBearDivHidden, rsiBullDivHidden] = f_findDivs(rsi, rsiDivOBLevel, rsiDivOSLevel, true)[rsiFractalTop_nl, rsiFractalBot_nl, rsiLow_prev_nl, rsiBearDiv_nl, rsiBullDiv_nl, rsiBearDivHidden_nl, rsiBullDivHidden_nl] = f_findDivs(rsi, 0, 0, false)rsiBearDivHidden_ = showHiddenDiv_nl ? rsiBearDivHidden_nl : rsiBearDivHiddenrsiBullDivHidden_ = showHiddenDiv_nl ? rsiBullDivHidden_nl : rsiBullDivHiddenrsiBearDivColor = (rsiShowDiv and rsiBearDiv) or (rsiShowHiddenDiv and rsiBearDivHidden_) ? colorRed : narsiBullDivColor = (rsiShowDiv and rsiBullDiv) or (rsiShowHiddenDiv and rsiBullDivHidden_) ? colorGreen : na // Stoch Divergences[stochFractalTop, stochFractalBot, stochLow_prev, stochBearDiv, stochBullDiv, stochBearDivHidden, stochBullDivHidden] = f_findDivs(stochK, 0, 0, false)stochBearDivColor = (stochShowDiv and stochBearDiv) or (stochShowHiddenDiv and stochBearDivHidden) ? colorRed : nastochBullDivColor = (stochShowDiv and stochBullDiv) or (stochShowHiddenDiv and stochBullDivHidden) ? colorGreen : na// Small Circles WT CrosssignalColor = wt2 - wt1 > 0 ? color.red : color.lime// Buy signal.buySignal = wtCross and wtCrossUp and wtOversoldbuySignalDiv = (wtShowDiv and wtBullDiv) or                (wtShowDiv and wtBullDiv_add) or                (stochShowDiv and stochBullDiv) or                (rsiShowDiv and rsiBullDiv)    buySignalDiv_color = wtBullDiv ? colorGreen :                      wtBullDiv_add ? color.new(colorGreen, 60) :                      rsiShowDiv ? colorGreen : na// Sell signalsellSignal = wtCross and wtCrossDown and wtOverbought             sellSignalDiv = (wtShowDiv and wtBearDiv) or                (wtShowDiv and wtBearDiv_add) or               (stochShowDiv and stochBearDiv) or               (rsiShowDiv and rsiBearDiv)                    sellSignalDiv_color = wtBearDiv ? colorRed :                      wtBearDiv_add ? color.new(colorRed, 60) :                      rsiBearDiv ? colorRed : na// Gold Buy lastRsi = valuewhen(wtFractalBot, rsi[2], 0)[2]wtGoldBuy = ((wtShowDiv and wtBullDiv) or (rsiShowDiv and rsiBullDiv)) and           wtLow_prev <= osLevel3 and           wt2 > osLevel3 and           wtLow_prev - wt2 <= -5 and           lastRsi < 30                     // } CALCULATE INDICATORS// DRAW {bgcolor(darkMode ? color.new(#000000, 80) : na)zLine = plot(0, color = color.new(colorWhite, 50))//  MFI BARrsiMfiBarTopLine = plot(rsiMFIShow ? -95 : na, title = 'MFI Bar TOP Line', transp = 100)rsiMfiBarBottomLine = plot(rsiMFIShow ? -99 : na, title = 'MFI Bar BOTTOM Line', transp = 100)fill(rsiMfiBarTopLine, rsiMfiBarBottomLine, title = 'MFI Bar Colors', color = rsiMFIColor, transp = 75)// WT Areasplot(wtShow ? wt1 : na, style = plot.style_area, title = 'WT Wave 1', color = macdWTColorsShow ? macdWT1Color : colorWT1, transp = 0)plot(wtShow ? wt2 : na, style = plot.style_area, title = 'WT Wave 2', color = macdWTColorsShow ? macdWT2Color : darkMode ? colorWT2_ : colorWT2 , transp = 20)// VWAPplot(vwapShow ? wtVwap : na, title = 'VWAP', color = colorYellow, style = plot.style_area, linewidth = 2, transp = 45)// MFI AREArsiMFIplot = plot(rsiMFIShow ? rsiMFI: na, title = 'RSI+MFI Area', color = rsiMFIColor, transp = 20)fill(rsiMFIplot, zLine, rsiMFIColor, transp = 40)// WT Divplot(series = wtFractalTop ? wt2[2] : na, title = 'WT Bearish Divergence', color = wtBearDivColor, linewidth = 2, offset = -2)plot(series = wtFractalBot ? wt2[2] : na, title = 'WT Bullish Divergence', color = wtBullDivColor, linewidth = 2, offset = -2)// WT 2nd Divplot(series = wtFractalTop_add ? wt2[2] : na, title = 'WT 2nd Bearish Divergence', color = wtBearDivColor_add, linewidth = 2, offset = -2)plot(series = wtFractalBot_add ? wt2[2] : na, title = 'WT 2nd Bullish Divergence', color = wtBullDivColor_add, linewidth = 2, offset = -2)// RSIplot(rsiShow ? rsi : na, title = 'RSI', color = rsiColor, linewidth = 2, transp = 25)// RSI Divplot(series = rsiFractalTop ? rsi[2] : na, title='RSI Bearish Divergence', color = rsiBearDivColor, linewidth = 1, offset = -2)plot(series = rsiFractalBot ? rsi[2] : na, title='RSI Bullish Divergence', color = rsiBullDivColor, linewidth = 1, offset = -2)// Stochastic RSIstochKplot = plot(stochShow ? stochK : na, title = 'Stoch K', color = color.new(#21baf3, 0), linewidth = 2)stochDplot = plot(stochShow ? stochD : na, title = 'Stoch D', color = color.new(#673ab7, 60), linewidth = 1)stochFillColor = stochK >= stochD ? color.new(#21baf3, 75) : color.new(#673ab7, 60)fill(stochKplot, stochDplot, title='KD Fill', color=stochFillColor)// Stoch Divplot(series = stochFractalTop ? stochK[2] : na, title='Stoch Bearish Divergence', color = stochBearDivColor, linewidth = 1, offset = -2)plot(series = stochFractalBot ? stochK[2] : na, title='Stoch Bullish Divergence', color = stochBullDivColor, linewidth = 1, offset = -2)// Schaff Trend Cycleplot(tcLine ? tcVal : na, color = color.new(#673ab7, 25), linewidth = 2, title = "Schaff Trend Cycle 1")plot(tcLine ? tcVal : na, color = color.new(colorWhite, 50), linewidth = 1, title = "Schaff Trend Cycle 2")// Draw Overbought & Oversold lines//plot(obLevel, title = 'Over Bought Level 1', color = colorWhite, linewidth = 1, style = plot.style_circles, transp = 85)plot(obLevel2, title = 'Over Bought Level 2', color = colorWhite, linewidth = 1, style = plot.style_stepline, transp = 85)plot(obLevel3, title = 'Over Bought Level 3', color = colorWhite, linewidth = 1, style = plot.style_circles, transp = 95)//plot(osLevel, title = 'Over Sold Level 1', color = colorWhite, linewidth = 1, style = plot.style_circles, transp = 85)plot(osLevel2, title = 'Over Sold Level 2', color = colorWhite, linewidth = 1, style = plot.style_stepline, transp = 85)// Sommi flagplotchar(sommiFlagShow and sommiBearish ? 108 : na, title = 'Sommi bearish flag', char='⚑', color = colorPink, location = location.absolute, size = size.tiny, transp = 0)plotchar(sommiFlagShow and sommiBullish ? -108 : na, title = 'Sommi bullish flag', char='⚑', color = colorBluelight, location = location.absolute, size = size.tiny, transp = 0)plot(sommiShowVwap ? ema(hvwap, 3) : na, title = 'Sommi higher VWAP', color = colorYellow, linewidth = 2, style = plot.style_line, transp = 15)// Sommi diamondplotchar(sommiDiamondShow and sommiBearishDiamond ? 108 : na, title = 'Sommi bearish diamond', char='◆', color = colorPink, location = location.absolute, size = size.tiny, transp = 0)plotchar(sommiDiamondShow and sommiBullishDiamond ? -108 : na, title = 'Sommi bullish diamond', char='◆', color = colorBluelight, location = location.absolute, size = size.tiny, transp = 0)// Circlesplot(wtCross ? wt2 : na, title = 'Buy and sell circle', color = signalColor, style = plot.style_circles, linewidth = 3, transp = 15)plotchar(wtBuyShow and buySignal ? -107 : na, title = 'Buy circle', char='·', color = colorGreen, location = location.absolute, size = size.small, transp = 50)plotchar(wtSellShow and sellSignal ? 105 : na , title = 'Sell circle', char='·', color = colorRed, location = location.absolute, size = size.small, transp = 50)plotchar(wtDivShow and buySignalDiv ? -106 : na, title = 'Divergence buy circle', char='•', color = buySignalDiv_color, location = location.absolute, size = size.small, offset = -2, transp = 15)plotchar(wtDivShow and sellSignalDiv ? 106 : na, title = 'Divergence sell circle', char='•', color = sellSignalDiv_color, location = location.absolute, size = size.small, offset = -2, transp = 15)plotchar(wtGoldBuy and wtGoldShow ? -106 : na, title = 'Gold  buy gold circle', char='•', color = colorOrange, location = location.absolute, size = size.small, offset = -2, transp = 15)// } DRAWlen = input(14)th = input(20)TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1])))DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0SmoothedTrueRange = 0.0SmoothedTrueRange := nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/len) + TrueRangeSmoothedDirectionalMovementPlus = 0.0SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlusSmoothedDirectionalMovementMinus = 0.0SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinusDIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100ADX = sma(DX, len)plot(ADX, color=color.white, title="ADX")// ALERTS {  // BUY// alertcondition(buySignal, 'Buy (Big green circle)', 'Green circle WaveTrend Oversold')// alertcondition(buySignalDiv, 'Buy (Big green circle + Div)', 'Buy & WT Bullish Divergence & WT Overbought')// alertcondition(wtGoldBuy, 'GOLD Buy (Big GOLDEN circle)', 'Green & GOLD circle WaveTrend Overbought')// alertcondition(sommiBullish or sommiBullishDiamond, 'Sommi bullish flag/diamond', 'Blue flag/diamond')// alertcondition(wtCross and wtCrossUp, 'Buy (Small green dot)', 'Buy small circle')// SELL// alertcondition(sommiBearish or sommiBearishDiamond, 'Sommi bearish flag/diamond', 'Purple flag/diamond')// alertcondition(sellSignal, 'Sell (Big red circle)', 'Red Circle WaveTrend Overbought')// alertcondition(sellSignalDiv, 'Sell (Big red circle + Div)', 'Buy & WT Bearish Divergence & WT Overbought')// alertcondition(wtCross and wtCrossDown, 'Sell (Small red dot)', 'Sell small circle')// } ALERTSf_RelVol(_value, _length) =>    min_value = lowest(_value, _length)    max_value = highest(_value, _length)    stoch(_value, max_value, min_value, _length) / 100rsi1LengthInput = input(100, minval=1, title="RSI Length", group="RSI Settings")rsi1SourceInput = input(close, "Source", group="RSI Settings")rsi2LengthInput = input(25, minval=1, title="RSI Length", group="RSI Settings")rsi2SourceInput = input(close, "Source", group="RSI Settings")price   = closelength  = input(10, minval=1)DER_avg = input(5, 'Average',   minval=1, inline='DER', group='Directional Energy Ratio')smooth  = input(3, 'Smoothing', minval=1, inline='DER', group='Directional Energy Ratio')v_calc  = input('Relative', 'Calculation', options=['Relative', 'Full', 'None'], group='Volume Parameters')vlookbk = input(20, 'Lookback (for Relative)', minval=1, group='Volume Parameters')uprsi1 = rma(max(change(rsi1SourceInput), 0), rsi1LengthInput)uprsi2 = rma(max(change(rsi2SourceInput), 0), rsi2LengthInput)downrsi1 = rma(-min(change(rsi1SourceInput), 0), rsi1LengthInput)downrsi2 = rma(-min(change(rsi2SourceInput), 0), rsi2LengthInput)rsi1 = downrsi1 == 0 ? 100 : uprsi1 == 0 ? 0 : 100 - (100 / (1 + uprsi1 / downrsi1))rsi2 = downrsi2 == 0 ? 100 : uprsi2 == 0 ? 0 : 100 - (100 / (1 + uprsi2 / downrsi2))vola    =   v_calc == 'None' or na(volume) ? 1 :   v_calc == 'Relative' ? f_RelVol(volume, vlookbk) :   volumeR       = (highest(1) - lowest(1)) / 2                    // R is the 2-bar average bar rangesr      = change(price) / R                                  // calc ratio of change to Rrsr     = max(min(sr, 1), -1)                         // ensure ratio is restricted to +1/-1 in case of big movesc       = rsr * vola                                            // add volume accelc_plus  = max(c, 0)                                        // calc directional vol-accel energyc_minus = -min(c, 0)// plot(c_plus)// plot(c_minus)dem     = wma(c_plus, length) / wma(vola, length)         //average directional energy ratiosup     = wma(c_minus, length) / wma(vola, length)// plot(vola, 'Vol Accel')adp     = 1 * wma(dem, DER_avg)asp     = 1 * wma(sup, DER_avg)anp     = adp - aspanp_s   = wma(anp, smooth)// plot(rsi1, "RSI", color=#FF0033)rsi1UpperBand = hline(70, "RSI Upper Band", color=#787B86)// hline(50, "RSI Middle Band", color=color.new(#787B86, 50))rsi1LowerBand = hline(30, "RSI Lower Band", color=#787B86)// plot(rsi2, "RSI", color=#FFFF00)rsi2UpperBand = hline(70, "RSI Upper Band", color=#787B86)// hline(50, "RSI Middle Band", color=color.new(#787B86, 50))rsi2LowerBand = hline(30, "RSI Lower Band", color=#787B86)c_adp   = color.new(color.aqua, 50)c_asp   = color.new(color.orange, 50)c_zero  = color.new(color.yellow, 70)c_fd    = color.new(color.green, 80)c_fs    = color.new(color.red, 80)c_up    = color.new(#33ff00, 0)c_dn    = color.new(#ff1111, 0)up      = anp_s >= 0strategy(title='VMC', shorttitle='VMC', overlay=true, precision=3, commission_value=0.025, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000)//=== Buy/Sell ===closeStatus = strategy.openprofit > 0 ? 'win' : 'lose'// long_entry = (signalColor == color.lime and wtCross and up)// long_exit_entry = (signalColor == color.red or sellSignal or sellSignalDiv)// short_entry = (signalColor == color.red and wtCross and not up)// short_exit_entry = (signalColor == color.lime or buySignal or buySignalDiv)long_entry = wt2 < wt1 //and up and rsi2 > rsi1long_exit_entry = signalColor == color.red or sellSignal or sellSignalDivshort_entry = wt2 > wt1 //and not up and rsi2 < rsi1short_exit_entry = signalColor == color.lime or buySignal or buySignalDivalertcondition(long_entry, 'Buy', 'Long entry')alertcondition(long_exit_entry, 'Buy', 'Long exit')alertcondition(short_entry, 'Sell', 'Short entry')alertcondition(short_exit_entry, 'Sell', 'Short exit')strategy.entry('long', strategy.long, when=long_entry)strategy.close('long', when=long_exit_entry, comment=closeStatus)strategy.entry('short', strategy.short, when=short_entry)strategy.close('short', when=short_exit_entry, comment=closeStatus)// stopPer = input(100, title='Stop Loss %', type=input.float) / 100// takePer = input(100, title='Take Profit %', type=input.float) / 100// // Determine where you've entered and in what direction// longStop = strategy.position_avg_price * (1 - stopPer)// shortStop = strategy.position_avg_price * (1 + stopPer)// shortTake = strategy.position_avg_price * (1 - takePer)// longTake = strategy.position_avg_price * (1 + takePer)// if strategy.position_size > 0 //     strategy.exit(id="Close Long", stop=longStop, limit=longTake)// if strategy.position_size < 0 //     strategy.exit(id="Close Short", stop=shortStop, limit=shortTake)