커뮤니티
부탁드립니다
수고하십니다
아래수식을 오류 없게 수정부탁드립니다
inputs:
Length(15),
ShowLevels(True),
UpColor(Color.Green),
DnColor(Color.Blue);
variables:
emaValue(0),
correction(0),
zlma(0),
zlmaLag3(0),
zlmaColor(0),
emaColor(0),
signalUp(False),
signalDn(False),
atrValue(0),
topLevel(0),
botLevel(0),
lastBoxTop(0),
lastBoxBot(0),
lastSignal(0),
barsSinceSignal(0);
{Calculate Zero-Lag Moving Average}
emaValue = Average(Close, Length);
correction = Close + (Close - emaValue);
zlma = Average(correction, Length);
{Get previous ZLMA value (3 bars ago)}
zlmaLag3 = zlma[3];
{Determine ZLMA color based on direction}
if zlma > zlmaLag3 then
zlmaColor = UpColor
else if zlma < zlmaLag3 then
zlmaColor = DnColor
else
zlmaColor = RGB(128, 128, 128); {Gray for neutral}
{Determine EMA color}
if emaValue < zlma then
emaColor = UpColor
else
emaColor = DnColor;
{Calculate signals}
signalUp = CrossOver(zlma, emaValue);
signalDn = CrossUnder(zlma, emaValue);
{Calculate ATR for trend levels}
atrValue = AvgTrueRange(200);
{Plot the moving averages}
Plot1(zlma, "ZLMA", zlmaColor);
Plot2(emaValue, "EMA", emaColor);
{Plot signals as diamonds}
if signalUp then
PlotPaint(zlma, "SignalUp", UpColor, 0, 3)
else if signalDn then
PlotPaint(zlma, "SignalDn", DnColor, 0, 3);
{Handle trend levels (boxes)}
if ShowLevels then begin
if signalUp then begin
topLevel = zlma;
botLevel = zlma - atrValue;
lastBoxTop = topLevel;
lastBoxBot = botLevel;
lastSignal = 1; {1 for up signal}
barsSinceSignal = 0;
end
else if signalDn then begin
topLevel = zlma + atrValue;
botLevel = zlma;
lastBoxTop = topLevel;
lastBoxBot = botLevel;
lastSignal = -1; {-1 for down signal}
barsSinceSignal = 0;
end;
barsSinceSignal = barsSinceSignal + 1;
{Draw trend level based on last signal}
if lastSignal = 1 then begin
{Draw horizontal line for bullish trend level}
DrawLine("BullTrendTop", BarIndex-barsSinceSignal, lastBoxTop, BarIndex, lastBoxTop, UpColor);
DrawLine("BullTrendBot", BarIndex-barsSinceSignal, lastBoxBot, BarIndex, lastBoxBot, UpColor);
end
else if lastSignal = -1 then begin
{Draw horizontal line for bearish trend level}
DrawLine("BearTrendTop", BarIndex-barsSinceSignal, lastBoxTop, BarIndex, lastBoxTop, DnColor);
DrawLine("BearTrendBot", BarIndex-barsSinceSignal, lastBoxBot, BarIndex, lastBoxBot, DnColor);
end;
{Add labels when price crosses trend levels}
if lastSignal = 1 and CrossUnder(High, lastBoxBot) and emaValue > zlma then
DrawText("DownArrow", "▼", BarIndex, High, 0, DnColor);
if lastSignal = -1 and CrossOver(Low, lastBoxTop) and emaValue < zlma then
DrawText("UpArrow", "▲", BarIndex, Low, 0, UpColor);
end;
답변 1
예스스탁 예스스탁 답변
2025-11-10 13:22:16