예스스탁
예스스탁 답변
2024-10-18 15:03:31
안녕하세요
예스스탁입니다.
input : fastLength(12);
input : slowLength(26);
input : signalLength(9);
input : MacdEmaLength(9);
input : useEma(1);//1:Ema 0 : ma
input : useOldAlgo(1);
input : dotsDistance(1.5);
var : source(0),ma1(0),ma2(0),zerolagEMA(0);
var : mas1(0),mas2(0),zerolagslowMA(0),ZeroLagMACD(0);
var : emasig1(0),emasig2(0),signal(0),hist(0),upHist(0),downHist(0);
var :circleYPosition(0),ribbonDiff2(0),tx(0);
source = close;
// Fast line
ma1 = iff(useEma == 1 , ema(source, fastLength) , ma(source, fastLength));
ma2 = iff(useEma == 1, ema(ma1,fastLength) , ma(ma1,fastLength));
zerolagEMA = ((2 * ma1) - ma2);
// Slow line
mas1 = iff(useEma == 1 , ema(source , slowLength) , ma(source , slowLength));
mas2 = iff(useEma == 1 , ema(mas1 , slowLength), ma(mas1 , slowLength));
zerolagslowMA = ((2 * mas1) - mas2);
// MACD line
ZeroLagMACD = zerolagEMA - zerolagslowMA;
// Signal line
emasig1 = ema(ZeroLagMACD, signalLength);
emasig2 = ema(emasig1, signalLength);
signal = iff(useOldAlgo == 1 , ma(ZeroLagMACD, signalLength) , (2 * emasig1) - emasig2);
hist = ZeroLagMACD - signal;
upHist = IFF((hist > 0) , hist , 0);
downHist = IFF((hist <= 0) , hist , 0);
plot1(upHist,"Positive delta",Green);
plot2(downHist,"Negative delta",Purple) ;
plot3(ZeroLagMACD,"MACD line",Black);
plot4(signal,"Signal",Gray);
circleYPosition = signal*dotsDistance;
ribbonDiff2 = iff(hist > 0 , green , purple);
plot5(ema(ZeroLagMACD,MacdEmaLength) ,"EMA on MACD line",Red);
if CrossUp(ZeroLagMACD, signal) or CrossDown(ZeroLagMACD, signal) Then
{
tx = Text_New_Self(sDate,sTime,circleYPosition,"●");
Text_SetStyle(tx,2,2);
Text_SetColor(tx,ribbonDiff2);
}
즐거운 하루되세요
> bw 님이 쓴 글입니다.
> 제목 : 부탁드립니다.
> TradingView의 Zero Lag 지표인데 수식변환 부탁드립니다.
source = close
fastLength = input(12, title="Fast MM period", minval=1)
slowLength = input(26,title="Slow MM period", minval=1)
signalLength =input(9,title="Signal MM period", minval=1)
MacdEmaLength =input(9, title="MACD EMA period", minval=1)
useEma = input(true, title="Use EMA (otherwise SMA)")
useOldAlgo = input(false, title="Use Glaz algo (otherwise 'real' original zero lag)")
showDots = input(true, title="Show symbols to indicate crossing")
dotsDistance = input(1.5, title="Symbols distance factor", minval=0.1)
// Fast line
ma1= useEma ? ema(source, fastLength) : sma(source, fastLength)
ma2 = useEma ? ema(ma1,fastLength) : sma(ma1,fastLength)
zerolagEMA = ((2 * ma1) - ma2)
// Slow line
mas1= useEma ? ema(source , slowLength) : sma(source , slowLength)
mas2 = useEma ? ema(mas1 , slowLength): sma(mas1 , slowLength)
zerolagslowMA = ((2 * mas1) - mas2)
// MACD line
ZeroLagMACD = zerolagEMA - zerolagslowMA
// Signal line
emasig1 = ema(ZeroLagMACD, signalLength)
emasig2 = ema(emasig1, signalLength)
signal = useOldAlgo ? sma(ZeroLagMACD, signalLength) : (2 * emasig1) - emasig2
hist = ZeroLagMACD - signal
upHist = (hist > 0) ? hist : 0
downHist = (hist <= 0) ? hist : 0
p1 = plot(upHist, color=green, transp=40, style=columns, title='Positive delta')
p2 = plot(downHist, color=purple, transp=40, style=columns, title='Negative delta')
zeroLine = plot(ZeroLagMACD, color=black, transp=0, linewidth=2, title='MACD line')
signalLine = plot(signal, color=gray, transp=0, linewidth=2, title='Signal')
ribbonDiff = hist > 0 ? green : purple
fill(zeroLine, signalLine, color=ribbonDiff)
circleYPosition = signal*dotsDistance
plot(ema(ZeroLagMACD,MacdEmaLength) , color=red, transp=0, linewidth=2, title='EMA on MACD line')
ribbonDiff2 = hist > 0 ? green : purple
plot(showDots and cross(ZeroLagMACD, signal) ? circleYPosition : na,style=circles, linewidth=4, color=ribbonDiff2, title='Dots')