Impulse MACD is a modified MACD, formed by filtering out the values in a MA range (region between MAs of high and low), thereby reducing whipsaw typical in a sideways market. This is usually plotted as histogram. This also plots the traditional histogram (MACD - Signal), to help in finding entries/exits.
Is there a hero to code the indicator or strategy?
Colors legend:
Impulse MACD: Possible colors => Lime / Green / Orange / Red, based on the ImpulseMACD position with respect to MidLine and Signal.
Impulse MACD Signal: Maroon line.
Blue histogram: (ImpulseMACD - Signal).
https://www.tradingview.com/script/qt6x ... -LazyBear/
impluse MACD
- faraz
- Posts: 204
- Joined: Feb 25 2011
- Location: 1stchoicestrategy.com
- Has thanked: 26 times
- Been thanked: 67 times
Code: Select all
Inputs: lengthMA(34), lengthSignal(9), ebc(false);
Vars: smmaHigh(0), smmaLow(0), zlema(0), md(0), sb(0), sh(0), mdc(0);
Vars: smmaHighPrev(0), smmaLowPrev(0), zlemaPrev(0);
Vars: ema1(0), ema2(0), diff(0);
{ Calculate SMMA for High }
if CurrentBar = 1 then
smmaHigh = AverageFC(High, lengthMA)
else
smmaHigh = (smmaHighPrev * (lengthMA - 1) + High) / lengthMA;
{ Calculate SMMA for Low }
if CurrentBar = 1 then
smmaLow = AverageFC(Low, lengthMA)
else
smmaLow = (smmaLowPrev * (lengthMA - 1) + Low) / lengthMA;
{ Calculate ZLEMA }
ema1 = XAverage((High + Low + Close) / 3, lengthMA);
ema2 = XAverage(ema1, lengthMA);
diff = ema1 - ema2;
zlema = ema1 + diff;
{ Store previous values for next bar }
smmaHighPrev = smmaHigh;
smmaLowPrev = smmaLow;
zlemaPrev = zlema;
{ Main Calculation }
md = iff(zlema > smmaHigh, zlema - smmaHigh, iff(zlema < smmaLow, zlema - smmaLow, 0));
sb = AverageFC(md, lengthSignal);
sh = md - sb;
mdc = iff((High + Low + Close) / 3 > zlema, iff((High + Low + Close) / 3 > smmaHigh, RGB(0, 255, 0), RGB(0, 128, 0)), iff((High + Low + Close) / 3 < smmaLow, RGB(255, 0, 0), RGB(255, 165, 0)));
{ Plotting }
Plot1(0, "MidLine", RGB(128, 128, 128));
Plot2(md, "ImpulseMACD", mdc, Default, 3); // 3 represents Histogram
Plot3(sh, "ImpulseHisto", RGB(0, 0, 255), Default, 3); // 3 represents Histogram
Plot4(sb, "ImpulseMACDCDSignal", RGB(128, 0, 0));
{ Bar Color }
if ebc then
SetPlotColor(1, mdc);
Trading Excellence ! ! !
1stChoiceStrategy.com
- Attachments
-
- MultiCharts1.png
- (77.31 KiB) Not downloaded yet