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
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
VerifiedSame 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)⋯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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Show WaveTrend | true | bool | WT Wave 1 WT Wave 2 |
| Show Buy dots | true | bool | Buy circle |
| Show Gold dots | true | bool | Gold buy gold circle |
| Show Sell dots | true | bool | Sell circle |
| Show Div. dots | true | bool | Divergence buy circle Divergence sell circle |
| Show Fast WT | true | bool | VWAP |
| WT Channel Length | 9 | int (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 Length | 12 | int (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 Source | hlc3 | source | 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 Length | 3 | int (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 1 | 53 | int (written input.integer) | wtOverbought |
| WT Overbought Level 2 | 60 | int (written input.integer) | Over Bought Level 2 |
| WT Overbought Level 3 | 100 | int (written input.integer) | Over Bought Level 3 |
| WT Oversold Level 1 | -53 | int (written input.integer) | wtOversold |
| WT Oversold Level 2 | -60 | int (written input.integer) | Over Sold Level 2 |
| WT Oversold Level 3 | -75 | int (written input.integer) | wtGoldBuy |
| Show WT Regular Divergences | true | bool | wtBearDivColor wtBullDivColor wtBearDivColor_add wtBullDivColor_add buySignalDiv sellSignalDiv wtGoldBuy |
| Show WT Hidden Divergences | false | bool | wtBearDivColor wtBullDivColor wtBearDivColor_add wtBullDivColor_add |
| Not apply OB/OS Limits on Hidden Divergences | true | bool | wtBearDivHidden_ wtBullDivHidden_ rsiBearDivHidden_ rsiBullDivHidden_ |
| WT Bearish Divergence min | 45 | int (written input.integer) | wtFractalTop wtFractalBot wtLow_prev wtBearDiv wtBullDiv wtBearDivHidden wtBullDivHidden |
| WT Bullish Divergence min | -65 | int (written input.integer) | wtFractalTop wtFractalBot wtLow_prev wtBearDiv wtBullDiv wtBearDivHidden wtBullDivHidden |
| Show 2nd WT Regular Divergences | true | bool | wtBearDivColor_add wtBullDivColor_add |
| WT 2nd Bearish Divergence | 15 | int (written input.integer) | wtFractalTop_add wtFractalBot_add wtLow_prev_add wtBearDiv_add wtBullDiv_add wtBearDivHidden_add wtBullDivHidden_add |
| WT 2nd Bullish Divergence 15 min | -40 | int (written input.integer) | wtFractalTop_add wtFractalBot_add wtLow_prev_add wtBearDiv_add wtBullDiv_add wtBearDivHidden_add wtBullDivHidden_add |
| Show MFI | true | bool | MFI Bar TOP Line MFI Bar BOTTOM Line RSI+MFI Area |
| MFI Period | 60 | int (written input.integer) | hrsimfi rsiMFI |
| MFI Area multiplier | 150 | float | hrsimfi rsiMFI |
| MFI Area Y Pos | 2.5 | float | line 163 |
| Show RSI | false | bool | RSI |
| RSI Source | close | source | rsi |
| RSI Length | 14 | int (written input.integer) | rsi |
| RSI Oversold | 30 | int (written input.integer) · min 50 · max 100 | rsiColor |
| RSI Overbought | 60 | int (written input.integer) · min 0 · max 50 | rsiColor |
| Show RSI Regular Divergences | false | bool | rsiBearDivColor rsiBullDivColor buySignalDiv buySignalDiv_color sellSignalDiv wtGoldBuy |
| Show RSI Hidden Divergences | false | bool | rsiBearDivColor rsiBullDivColor |
| RSI Bearish Divergence min | 60 | int (written input.integer) | rsiFractalTop rsiFractalBot rsiLow_prev rsiBearDiv rsiBullDiv rsiBearDivHidden rsiBullDivHidden |
| RSI Bullish Divergence min | 30 | int (written input.integer) | rsiFractalTop rsiFractalBot rsiLow_prev rsiBearDiv rsiBullDiv rsiBearDivHidden rsiBullDivHidden |
| Show Stochastic RSI | true | bool | Stoch K Stoch D |
| Use Log? | true | bool | stochK stochD |
| Use Average of both K & D | false | bool | stochK stochD |
| Stochastic RSI Source | close | source | stochK stochD |
| Stochastic RSI Length | 14 | int (written input.integer) | stochK stochD |
| RSI Length | 14 | int (written input.integer) | stochK stochD |
| Stochastic RSI K Smooth | 3 | int (written input.integer) | stochK stochD |
| Stochastic RSI D Smooth | 3 | int (written input.integer) | stochK stochD |
| Show Stoch Regular Divergences | false | bool | stochBearDivColor stochBullDivColor buySignalDiv sellSignalDiv |
| Show Stoch Hidden Divergences | false | bool | stochBearDivColor stochBullDivColor |
| Show Schaff TC line | false | bool | Schaff Trend Cycle 1 Schaff Trend Cycle 2 |
| Schaff TC Source | close | source | tcVal |
| Schaff TC | 10 | int (written input.integer) | tcVal |
| Schaff TC Fast Lenght | 23 | int (written input.integer) | tcVal |
| Schaff TC Slow Length | 50 | int (written input.integer) | tcVal |
| Schaff TC Factor | 0.5 | float | delta stcReturn |
| Show Sommi flag | false | bool | Sommi bearish flag Sommi bullish flag |
| Show Sommi F. Wave | false | bool | Sommi higher VWAP |
| Sommi F. Wave timeframe | 720 | string | sommiBearish sommiBullish hvwap |
| F. Wave Bear Level (less than) | 0 | int (written input.integer) | bearPattern |
| F. Wave Bull Level (more than) | 0 | int (written input.integer) | bullPattern |
| WT Bear Level (more than) | 0 | int (written input.integer) | bearPattern |
| WT Bull Level (less than) | 0 | int (written input.integer) | bullPattern |
| Money flow Bear Level (less than) | 0 | int (written input.integer) | bearPattern |
| Money flow Bull Level (more than) | 0 | int (written input.integer) | bullPattern |
| Show Sommi diamond | false | bool | Sommi bearish diamond Sommi bullish diamond |
| HTF Candle Res. 1 | 60 | string | sommiBearishDiamond sommiBullishDiamond |
| HTF Candle Res. 2 | 240 | string | sommiBearishDiamond sommiBullishDiamond |
| WT Bear Level (More than) | 0 | int (written input.integer) | bearPattern |
| WT Bull Level (Less than) | 0 | int (written input.integer) | bullPattern |
| Show MACD Colors | false | bool | WT Wave 1 WT Wave 2 |
| MACD Colors MACD TF | 240 | string | macd signal hist macdWT1Color macdWT2Color |
| Dark mode | false | bool | bgcolor WT Wave 2 |
| Len (no label in the script) | 14 | int | SmoothedTrueRange SmoothedDirectionalMovementPlus SmoothedDirectionalMovementMinus ADX |
| Th (no label in the script) | 20 | int | unused |
| Length (no label in the script) | 10 | int · min 1 | alpha beta epsilon zeta dem sup |
| RSI Settings | |||
| RSI Length | 100 | int · min 1 | uprsi1 downrsi1 |
| Source | close | source | uprsi1 downrsi1 |
| RSI Length | 25 | int · min 1 | uprsi2 downrsi2 |
| Source | close | source | uprsi2 downrsi2 |
| Directional Energy Ratio | |||
| Average | 5 | int · min 1 | adp asp |
| Smoothing | 3 | int · min 1 | anp_s |
| Volume Parameters | |||
| Calculation | Relative | string · options ['Relative', 'Full', 'None'] | vola |
| Lookback (for Relative) | 20 | int · min 1 | vola |
What it calculates
- Valuewhen (
valuewhen,ta.valuewhenin v5)fractalTop, src[2], 0highPrev · line 152 - Valuewhen (
valuewhen,ta.valuewhenin v5)fractalTop, high[2], 0highPrice · line 153 - Valuewhen (
valuewhen,ta.valuewhenin v5)fractalBot, src[2], 0lowPrev · line 154 - Valuewhen (
valuewhen,ta.valuewhenin v5)fractalBot, low[2], 0lowPrice · line 155 - EMA (
ema,ta.emain v5)tfsrc, chlenesa · line 168 - EMA (
ema,ta.emain v5)abs(tfsrc - esa), chlende · line 169 - Cross (
cross,ta.crossin v5)wt1[2], wt2[2]wtCrosslast · line 179 - EMA (
ema,ta.emain v5)src, fastLengthema1 · line 185 - EMA (
ema,ta.emain v5)src, slowLengthema2 · line 186 - Lowest (
lowest,ta.lowestin v5)macdVal, Length (10)alpha · line 188 - Highest (
highest,ta.highestin v5)macdVal, Length (10)beta · line 189 - Lowest (
lowest,ta.lowestin v5)delta, Length (10)epsilon · line 194 - Highest (
highest,ta.highestin v5)delta, Length (10)zeta · line 195 - RSI (
rsi,ta.rsiin v5)RSI Source (close), RSI Length (14)rsi · line 274 - SMA / Stoch (
sma,ta.smain v5)stoch(rsi, rsi, rsi, _stochlen), _smoothkkk · line 205 - SMA (
sma,ta.smain v5)kk, _smoothdd1 · line 206 - EMA (
ema,ta.emain v5)src, fastlenfast_ma · line 212 - EMA (
ema,ta.emain v5)src, slowlenslow_ma · line 213 - Valuewhen (
valuewhen,ta.valuewhenin v5)wtFractalBot, rsi[2], 0lastRsi · line 339 - SMA (
sma,ta.smain v5)DX, Len (14)ADX · line 419 - Lowest (
lowest,ta.lowestin v5)_value, _lengthmin_value · line 436 - Highest (
highest,ta.highestin v5)_value, _lengthmax_value · line 437 - RMA / Change (
rma,ta.rmain v5)max(change(rsi1SourceInput), 0), RSI Length (100)uprsi1 · line 449 - RMA / Change (
rma,ta.rmain v5)max(change(rsi2SourceInput), 0), RSI Length (25)uprsi2 · line 450 - RMA / Change (
rma,ta.rmain v5)-min(change(rsi1SourceInput), 0), RSI Length (100)downrsi1 · line 451 - RMA / Change (
rma,ta.rmain v5)-min(change(rsi2SourceInput), 0), RSI Length (25)downrsi2 · line 452 - Highest / Lowest (
highest,ta.highestin v5)1R · line 459 - Change (
change,ta.changein v5)pricesr · line 460 - WMA (
wma,ta.wmain v5)c_plus, Length (10)dem · line 467 - WMA (
wma,ta.wmain v5)c_minus, Length (10)sup · line 468 - WMA (
wma,ta.wmain v5)dem, Average (5)adp · line 470 - WMA (
wma,ta.wmain v5)sup, Average (5)asp · line 471 - WMA (
wma,ta.wmain 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
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open long long | long_entrywt2 < wt1 | On | 505 |
| Close long | long_exit_entry | On | 506 |
| Open short short | short_entrywt2 > wt1 | On | 507 |
| Close short | short_exit_entry | On | 508 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Alerts
| Alert | Call | Message | Line |
|---|---|---|---|
| Buy | alertcondition | Long entry | 501 |
| Buy | alertcondition | Long exit | 502 |
| Sell | alertcondition | Short entry | 503 |
| Sell | alertcondition | Short exit | 504 |
Does it repaint?
Yes
At least one pattern in the source can repaint; it is marked Check below.
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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 59 | 42% | −$978.24 |
| Sideways market | 74 | 41% | $3,221.62 |
| Falling market | 42 | 45% | $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.
The first 150 of 175 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 25 Feb 2024 51,568.20 | 27 Feb 2024 54,476.50 | 2 | −$569.11 |
| long | 27 Feb 2024 54,476.50 | 3 Mar 2024 61,987.30 | 5 | $1,373.38 |
| short | 3 Mar 2024 61,987.30 | 25 Mar 2024 67,210.00 | 22 | −$847.76 |
| long | 25 Mar 2024 67,210.00 | 2 Apr 2024 69,649.80 | 8 | $357.92 |
| short | 2 Apr 2024 69,649.80 | 7 Apr 2024 68,896.00 | 5 | $103.26 |
| long | 7 Apr 2024 68,896.00 | 13 Apr 2024 67,116.50 | 6 | −$263.22 |
| short | 13 Apr 2024 67,116.50 | 20 Apr 2024 63,818.00 | 7 | $486.58 |
| long | 20 Apr 2024 63,818.00 | 26 Apr 2024 64,498.30 | 6 | $101.58 |
| short | 26 Apr 2024 64,498.30 | 4 May 2024 62,882.00 | 8 | $245.66 |
| long | 4 May 2024 62,882.00 | 9 May 2024 61,193.00 | 5 | −$273.53 |
| short | 9 May 2024 61,193.00 | 14 May 2024 62,940.10 | 5 | −$290.57 |
| long | 14 May 2024 62,940.10 | 24 May 2024 67,969.70 | 10 | $793.90 |
| short | 24 May 2024 67,969.70 | 4 Jun 2024 68,809.90 | 11 | −$128.65 |
| long | 4 Jun 2024 68,809.90 | 8 Jun 2024 69,355.60 | 4 | $74.29 |
| short | 8 Jun 2024 69,355.60 | 27 Jun 2024 60,865.00 | 19 | $1,219.52 |
| long | 27 Jun 2024 60,865.00 | 4 Jul 2024 60,208.60 | 7 | −$112.82 |
| short | 4 Jul 2024 60,208.60 | 9 Jul 2024 56,714.60 | 5 | $575.45 |
| long | 9 Jul 2024 56,714.60 | 24 Jul 2024 65,936.00 | 15 | $1,620.52 |
| short | 24 Jul 2024 65,936.00 | 28 Jul 2024 67,896.50 | 4 | −$302.41 |
| long | 28 Jul 2024 67,896.50 | 30 Jul 2024 66,784.70 | 2 | −$168.71 |
| short | 30 Jul 2024 66,784.70 | 9 Aug 2024 61,686.00 | 10 | $758.64 |
| long | 9 Aug 2024 61,686.00 | 16 Aug 2024 57,541.10 | 7 | −$676.78 |
| short | 16 Aug 2024 57,541.10 | 18 Aug 2024 59,492.00 | 2 | −$344.14 |
| long | 18 Aug 2024 59,492.00 | 28 Aug 2024 59,415.00 | 10 | −$17.94 |
| short | 28 Aug 2024 59,415.00 | 10 Sep 2024 57,042.00 | 13 | $394.49 |
| long | 10 Sep 2024 57,042.00 | 17 Sep 2024 58,214.00 | 7 | $200.41 |
| short | 17 Sep 2024 58,214.00 | 18 Sep 2024 60,314.00 | 1 | −$365.83 |
| long | 18 Sep 2024 60,314.00 | 24 Sep 2024 63,340.00 | 6 | $496.58 |
| short | 24 Sep 2024 63,340.00 | 28 Sep 2024 65,769.90 | 4 | −$388.73 |
| long | 28 Sep 2024 65,769.90 | 30 Sep 2024 65,602.00 | 2 | −$30.53 |
| short | 30 Sep 2024 65,602.00 | 7 Oct 2024 62,819.90 | 7 | $419.19 |
| long | 7 Oct 2024 62,819.90 | 10 Oct 2024 60,636.00 | 3 | −$352.56 |
| short | 10 Oct 2024 60,636.00 | 13 Oct 2024 63,206.20 | 3 | −$428.98 |
| long | 13 Oct 2024 63,206.20 | 22 Oct 2024 67,377.50 | 9 | $654.78 |
| short | 22 Oct 2024 67,377.50 | 28 Oct 2024 68,021.70 | 6 | −$100.63 |
| long | 28 Oct 2024 68,021.70 | 2 Nov 2024 69,496.00 | 5 | $211.69 |
| short | 2 Nov 2024 69,496.00 | 7 Nov 2024 75,572.00 | 5 | −$879.51 |
| long | 7 Nov 2024 75,572.00 | 15 Nov 2024 87,325.60 | 8 | $1,549.90 |
| short | 15 Nov 2024 87,325.60 | 22 Nov 2024 98,317.10 | 7 | −$1,264.00 |
| long | 22 Nov 2024 98,317.10 | 24 Nov 2024 97,672.40 | 2 | −$70.56 |
| short | 24 Nov 2024 97,672.40 | 30 Nov 2024 97,460.00 | 6 | $16.75 |
| long | 30 Nov 2024 97,460.00 | 2 Dec 2024 97,185.20 | 2 | −$33.19 |
| short | 2 Dec 2024 97,185.20 | 5 Dec 2024 98,587.30 | 3 | −$149.31 |
| long | 5 Dec 2024 98,587.30 | 10 Dec 2024 97,276.50 | 5 | −$137.93 |
| short | 10 Dec 2024 97,276.50 | 13 Dec 2024 100,004.00 | 3 | −$285.49 |
| long | 13 Dec 2024 100,004.00 | 19 Dec 2024 100,204.00 | 6 | $14.97 |
| short | 19 Dec 2024 100,204.00 | 26 Dec 2024 99,429.60 | 7 | $72.30 |
| long | 26 Dec 2024 99,429.60 | 27 Dec 2024 95,791.60 | 1 | −$370.80 |
| short | 27 Dec 2024 95,791.60 | 2 Jan 2025 94,591.80 | 6 | $120.28 |
| long | 2 Jan 2025 94,591.80 | 9 Jan 2025 95,060.60 | 7 | $44.55 |
| short | 9 Jan 2025 95,060.60 | 15 Jan 2025 96,560.90 | 6 | −$162.86 |
| long | 15 Jan 2025 96,560.90 | 24 Jan 2025 103,910.00 | 9 | $755.94 |
| short | 24 Jan 2025 103,910.00 | 31 Jan 2025 104,723.00 | 7 | −$83.22 |
| long | 31 Jan 2025 104,723.00 | 2 Feb 2025 100,636.00 | 2 | −$395.20 |
| short | 2 Feb 2025 100,636.00 | 11 Feb 2025 97,430.80 | 9 | $313.54 |
| long | 11 Feb 2025 97,430.80 | 18 Feb 2025 95,780.00 | 7 | −$174.39 |
| short | 18 Feb 2025 95,780.00 | 21 Feb 2025 98,305.00 | 3 | −$268.69 |
| long | 21 Feb 2025 98,305.00 | 24 Feb 2025 96,258.00 | 3 | −$213.18 |
| short | 24 Feb 2025 96,258.00 | 2 Mar 2025 86,064.50 | 6 | $1,054.24 |
| long | 2 Mar 2025 86,064.50 | 9 Mar 2025 86,222.50 | 7 | $13.34 |
| short | 9 Mar 2025 86,222.50 | 13 Mar 2025 83,680.10 | 4 | $289.93 |
| long | 13 Mar 2025 83,680.10 | 23 Mar 2025 83,840.60 | 10 | $14.17 |
| short | 23 Mar 2025 83,840.60 | 24 Mar 2025 86,082.50 | 1 | −$272.47 |
| long | 24 Mar 2025 86,082.50 | 29 Mar 2025 84,424.40 | 5 | −$197.57 |
| short | 29 Mar 2025 84,424.40 | 3 Apr 2025 82,516.30 | 5 | $221.07 |
| long | 3 Apr 2025 82,516.30 | 4 Apr 2025 83,213.10 | 1 | $79.42 |
| short | 4 Apr 2025 83,213.10 | 10 Apr 2025 82,615.20 | 6 | $66.87 |
| long | 10 Apr 2025 82,615.20 | 27 Apr 2025 94,628.00 | 17 | $1,448.70 |
| short | 27 Apr 2025 94,628.00 | 3 May 2025 96,887.10 | 6 | −$243.80 |
| long | 3 May 2025 96,887.10 | 4 May 2025 95,856.40 | 1 | −$111.36 |
| short | 4 May 2025 95,856.40 | 8 May 2025 97,030.50 | 4 | −$127.51 |
| long | 8 May 2025 97,030.50 | 13 May 2025 102,791.00 | 5 | $588.56 |
| short | 13 May 2025 102,791.00 | 19 May 2025 106,454.00 | 6 | −$361.44 |
| long | 19 May 2025 106,454.00 | 25 May 2025 107,762.00 | 6 | $117.80 |
| short | 25 May 2025 107,762.00 | 8 Jun 2025 105,552.00 | 14 | $200.11 |
| long | 8 Jun 2025 105,552.00 | 13 Jun 2025 105,672.00 | 5 | $6.33 |
| short | 13 Jun 2025 105,672.00 | 17 Jun 2025 106,795.00 | 4 | −$111.28 |
| long | 17 Jun 2025 106,795.00 | 18 Jun 2025 104,551.00 | 1 | −$215.01 |
| short | 18 Jun 2025 104,551.00 | 24 Jun 2025 105,334.00 | 6 | −$79.89 |
| long | 24 Jun 2025 105,334.00 | 2 Jul 2025 105,681.00 | 8 | $27.95 |
| short | 2 Jul 2025 105,681.00 | 3 Jul 2025 108,850.00 | 1 | −$304.89 |
| long | 3 Jul 2025 108,850.00 | 6 Jul 2025 108,198.00 | 3 | −$64.84 |
| short | 6 Jul 2025 108,198.00 | 7 Jul 2025 109,204.00 | 1 | −$97.98 |
| long | 7 Jul 2025 109,204.00 | 9 Jul 2025 108,923.00 | 2 | −$30.71 |
| short | 9 Jul 2025 108,923.00 | 10 Jul 2025 111,234.00 | 1 | −$217.22 |
| long | 10 Jul 2025 111,234.00 | 16 Jul 2025 117,758.00 | 6 | $581.37 |
| short | 16 Jul 2025 117,758.00 | 28 Jul 2025 119,416.00 | 12 | −$145.79 |
| long | 28 Jul 2025 119,416.00 | 30 Jul 2025 117,951.00 | 2 | −$127.63 |
| short | 30 Jul 2025 117,951.00 | 5 Aug 2025 115,055.00 | 6 | $240.56 |
| long | 5 Aug 2025 115,055.00 | 16 Aug 2025 117,342.00 | 11 | $193.73 |
| short | 16 Aug 2025 117,342.00 | 24 Aug 2025 115,438.00 | 8 | $157.30 |
| long | 24 Aug 2025 115,438.00 | 25 Aug 2025 113,494.00 | 1 | −$173.40 |
| short | 25 Aug 2025 113,494.00 | 29 Aug 2025 112,567.00 | 4 | $76.67 |
| long | 29 Aug 2025 112,567.00 | 30 Aug 2025 108,377.00 | 1 | −$377.09 |
| short | 30 Aug 2025 108,377.00 | 2 Sep 2025 109,237.00 | 3 | −$84.37 |
| long | 2 Sep 2025 109,237.00 | 16 Sep 2025 115,350.00 | 14 | $554.40 |
| short | 16 Sep 2025 115,350.00 | 17 Sep 2025 116,789.00 | 1 | −$129.80 |
| long | 17 Sep 2025 116,789.00 | 18 Sep 2025 116,448.00 | 1 | −$34.22 |
| short | 18 Sep 2025 116,448.00 | 19 Sep 2025 117,074.00 | 1 | −$58.77 |
| long | 19 Sep 2025 117,074.00 | 20 Sep 2025 115,632.00 | 1 | −$128.07 |
| short | 20 Sep 2025 115,632.00 | 29 Sep 2025 112,164.00 | 9 | $295.03 |
| long | 29 Sep 2025 112,164.00 | 8 Oct 2025 121,333.00 | 9 | $812.26 |
| short | 8 Oct 2025 121,333.00 | 21 Oct 2025 110,532.00 | 13 | $885.41 |
| long | 21 Oct 2025 110,532.00 | 23 Oct 2025 107,567.00 | 2 | −$273.15 |
| short | 23 Oct 2025 107,567.00 | 24 Oct 2025 110,078.00 | 1 | −$238.47 |
| long | 24 Oct 2025 110,078.00 | 30 Oct 2025 110,021.00 | 6 | −$10.17 |
| short | 30 Oct 2025 110,021.00 | 9 Nov 2025 102,313.00 | 10 | $695.80 |
| long | 9 Nov 2025 102,313.00 | 13 Nov 2025 101,654.00 | 4 | −$69.35 |
| short | 13 Nov 2025 101,654.00 | 24 Nov 2025 86,830.00 | 11 | $1,453.68 |
| long | 24 Nov 2025 86,830.00 | 2 Dec 2025 86,286.00 | 8 | −$67.63 |
| short | 2 Dec 2025 86,286.00 | 4 Dec 2025 93,429.90 | 2 | −$833.14 |
| long | 4 Dec 2025 93,429.90 | 7 Dec 2025 89,236.80 | 3 | −$453.69 |
| short | 7 Dec 2025 89,236.80 | 9 Dec 2025 90,634.40 | 2 | −$161.65 |
| long | 9 Dec 2025 90,634.40 | 13 Dec 2025 90,268.40 | 4 | −$45.36 |
| short | 13 Dec 2025 90,268.40 | 21 Dec 2025 88,360.90 | 8 | $206.37 |
| long | 21 Dec 2025 88,360.90 | 25 Dec 2025 87,669.40 | 4 | −$83.24 |
| short | 25 Dec 2025 87,669.40 | 27 Dec 2025 87,369.60 | 2 | $29.21 |
| long | 27 Dec 2025 87,369.60 | 8 Jan 2026 91,364.20 | 12 | $452.09 |
| short | 8 Jan 2026 91,364.20 | 14 Jan 2026 95,414.00 | 6 | −$448.37 |
| long | 14 Jan 2026 95,414.00 | 17 Jan 2026 95,550.90 | 3 | $9.35 |
| short | 17 Jan 2026 95,550.90 | 29 Jan 2026 89,300.00 | 12 | $649.36 |
| long | 29 Jan 2026 89,300.00 | 30 Jan 2026 84,650.20 | 1 | −$525.57 |
| short | 30 Jan 2026 84,650.20 | 8 Feb 2026 69,289.40 | 9 | $1,810.07 |
| long | 8 Feb 2026 69,289.40 | 19 Feb 2026 66,461.00 | 11 | −$413.10 |
| short | 19 Feb 2026 66,461.00 | 21 Feb 2026 68,020.00 | 2 | −$239.63 |
| long | 21 Feb 2026 68,020.00 | 24 Feb 2026 64,656.00 | 3 | −$499.44 |
| short | 24 Feb 2026 64,656.00 | 26 Feb 2026 67,988.00 | 2 | −$520.48 |
| long | 26 Feb 2026 67,988.00 | 1 Mar 2026 66,973.30 | 3 | −$154.22 |
| short | 1 Mar 2026 66,973.30 | 2 Mar 2026 65,776.50 | 1 | $173.74 |
| long | 2 Mar 2026 65,776.50 | 8 Mar 2026 67,262.90 | 6 | $220.93 |
| short | 8 Mar 2026 67,262.90 | 11 Mar 2026 69,948.60 | 3 | −$404.39 |
| long | 11 Mar 2026 69,948.60 | 19 Mar 2026 71,246.60 | 8 | $180.50 |
| short | 19 Mar 2026 71,246.60 | 26 Mar 2026 71,336.50 | 7 | −$17.63 |
| long | 26 Mar 2026 71,336.50 | 27 Mar 2026 68,820.30 | 1 | −$357.64 |
| short | 27 Mar 2026 68,820.30 | 1 Apr 2026 68,284.50 | 5 | $72.88 |
| long | 1 Apr 2026 68,284.50 | 4 Apr 2026 66,964.30 | 3 | −$198.29 |
| short | 4 Apr 2026 66,964.30 | 5 Apr 2026 67,300.40 | 1 | −$55.21 |
| long | 5 Apr 2026 67,300.40 | 13 Apr 2026 70,741.60 | 8 | $506.18 |
| short | 13 Apr 2026 70,741.60 | 14 Apr 2026 74,418.00 | 1 | −$524.83 |
| long | 14 Apr 2026 74,418.00 | 20 Apr 2026 73,801.80 | 6 | −$87.78 |
| short | 20 Apr 2026 73,801.80 | 23 Apr 2026 78,178.20 | 3 | −$598.14 |
| long | 23 Apr 2026 78,178.20 | 26 Apr 2026 77,625.00 | 3 | −$75.75 |
| short | 26 Apr 2026 77,625.00 | 2 May 2026 78,231.10 | 6 | −$83.10 |
| long | 2 May 2026 78,231.10 | 9 May 2026 80,193.20 | 7 | $245.74 |
| short | 9 May 2026 80,193.20 | 11 May 2026 82,210.10 | 2 | −$256.57 |
| long | 11 May 2026 82,210.10 | 13 May 2026 80,504.50 | 2 | −$212.42 |
| short | 13 May 2026 80,504.50 | 25 May 2026 77,065.00 | 12 | $422.35 |
| long | 25 May 2026 77,065.00 | 28 May 2026 74,449.30 | 3 | −$344.32 |
| short | 28 May 2026 74,449.30 | 1 Jun 2026 73,674.40 | 4 | $99.11 |
| long | 1 Jun 2026 73,674.40 | 2 Jun 2026 71,408.90 | 1 | −$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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| VuManChu Cipher B + Divergences Strategy this page | — | v4 strategy | +76.6% | 175 | 18.4% |
| Top 40 High Low Strategy for SPY, 5min by PtGambler | rma sma cross ema rsi highest lowest | v5 strategy | No trades on this market | ||
| SPX Scalping Strategy by connor2279 | sma ema lowest wma rma cross | v5 strategy | +1.5% | 109 | 5.0% |
| Stochastic RSI + WMA + SMA strat by tweakerID | rsi sma wma lowest highest valuewhen | v4 strategy | −11.9% | 4 | 37.9% |
| MACD Willy Strategy by PtGambler | rma sma ema highest lowest wma | v5 strategy | No trades on this market | ||
| TradeIQ - Crazy Scalping Trading Strategy [Kaspricci] by Kaspricci | highest lowest valuewhen sma cross rsi | v5 strategy | +1,326.3% | 6 | 1,046.4% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 110 ms | With a workaround 1,000 bars in 1,021 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © 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)