Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

pine script - trying to debug this source code, stuck on some simple syntax errors

I keep getting the error no viable alternative character at line 147 where // functions start. Not quite sure what I'm missing. Any help is appreciated. Im trying to debug a source code I got that resembles MarketCipher, this is too focus on divergence.

//@version=4
study(title = "VuManChu B Divergences", shorttitle = "VMC Cipher_B_Divergences")

// PARAMETERS {

// WaveTrend
wtShow = 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 lines
obLevel = 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 WT
wtShowDiv = 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 range
wtDivOBLevel_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+MFI
rsiMFIShow = 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)

// RSI
rsiShow = 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 RSI
rsiShowDiv = 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 Stochastic
stochShow = 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 stoch
stochShowDiv = input(false, title = "Show Stoch Regular Divergences", type = input.bool)
stochShowHiddenDiv = input(false, title = "Show Stoch Hidden Divergences", type = input.bool)

// Schaff Trend Cycle
tcLine = 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 Flag
sommiFlagShow = 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 Diamond
sommiDiamondShow = 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 Colors
macdWTColorsShow = 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)

// Colors
colorRed = #ff0000
colorPurple = #e600e6
colorGreen = #3fff00
colorOrange = #e2a400
colorYellow = #ffe500
colorWhite = #ffffff
colorPink = #ff00f0
colorBluelight = #31c0ff

colorWT1 = #90caf9
colorWT2 = #0d47a1

colorWT2_ = #131722

colormacdWT1a = #4caf58
colormacdWT1b = #af4c4c
colormacdWT1c = #7ee57e
colormacdWT1d = #ff3535

colormacdWT2a = #305630
colormacdWT2b = #310101
colormacdWT2c = #132213
colormacdWT2d = #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 : 0

f_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, 
    highPrev]

// RSI+MFI
 f_rsimfi(_period, _multiplier, _tf) => security(syminfo.tickerid, _tf, sma(((close – open) / 
(high – low)) * _multiplier, _period) – rsiMFIPosY)

// WaveTrend
f_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 Cycle
f_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 RSI
f_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]

// MACD
f_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 candle
f_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, 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Another bad copy-paste job.
There were multiple issues with this script (mostly indentation), and the minus signs were hyphens.

This will compile and plot.

//@version=4
study(title = "VuManChu B Divergences", shorttitle = "VMC Cipher_B_Divergences")

// PARAMETERS {

// WaveTrend
wtShow = 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 lines
obLevel = 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 WT
wtShowDiv = 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 range
wtDivOBLevel_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+MFI
rsiMFIShow = 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)

// RSI
rsiShow = 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 RSI
rsiShowDiv = 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 Stochastic
stochShow = 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 stoch
stochShowDiv = input(false, title = "Show Stoch Regular Divergences", type = input.bool)
stochShowHiddenDiv = input(false, title = "Show Stoch Hidden Divergences", type = input.bool)

// Schaff Trend Cycle
tcLine = 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 Flag
sommiFlagShow = 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 Diamond
sommiDiamondShow = 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 Colors
macdWTColorsShow = 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)

// Colors
colorRed = #ff0000
colorPurple = #e600e6
colorGreen = #3fff00
colorOrange = #e2a400
colorYellow = #ffe500
colorWhite = #ffffff
colorPink = #ff00f0
colorBluelight = #31c0ff

colorWT1 = #90caf9
colorWT2 = #0d47a1

colorWT2_ = #131722

colormacdWT1a = #4caf58
colormacdWT1b = #af4c4c
colormacdWT1c = #7ee57e
colormacdWT1d = #ff3535

colormacdWT2a = #305630
colormacdWT2b = #310101
colormacdWT2c = #132213
colormacdWT2d = #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 : 0

f_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] //, highPrev]

// RSI+MFI
f_rsimfi(_period, _multiplier, _tf) => 
    security(syminfo.tickerid, _tf, sma(((close - open) / (high - low)) * _multiplier, _period)) - rsiMFIPosY

// WaveTrend
f_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 Cycle
f_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 RSI
f_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]

// MACD
f_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 candle
f_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.t

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...