mod note:
This is a MACD with engineered context around it — volatility structure, squeeze states, momentum polarity, and directional acceleration.
Instead of MACD firing blindly, the script now understands whether the market is:
Staright Forward standard MACD with Squeeze Pro zero line . . . Please Comment
This is a MACD with engineered context around it — volatility structure, squeeze states, momentum polarity, and directional acceleration.
Instead of MACD firing blindly, the script now understands whether the market is:
pre‑compressing
in a standard squeeze
in an extreme volatility contraction
A massive upgrade in signal quality.Staright Forward standard MACD with Squeeze Pro zero line . . . Please Comment
| Signal | What You Look For | What It Means / What to Do |
|---|---|---|
| Momentum engine | Bars rising above zero or falling below zero | Rising above zero shows buyers taking control; falling below shows sellers taking control. Trade in the direction of the polarity. |
| Momentum slope | Bars increasing or decreasing in height | Increasing height shows momentum building; decreasing height shows momentum fading. Press when it builds; manage risk when it fades. |
| Histogram colors | Green shades in positive territory; red shades in negative territory | Green shows bullish pressure; red shows bearish pressure. Stay with the dominant color until it weakens or flips. |
| Color flips | Green → dark green → red, or red → dark red → green | A flip signals a shift in pressure. Prepare for a change in direction or a pause in the current move. |
| Squeeze line | Line at zero turning light orange → red → dark red | Light orange shows early compression; red shows standard squeeze; dark red shows extreme compression. Expect expansion when the squeeze releases. |
| Breakout arrows | Arrow up or down at the zero line | Arrow up confirms bullish breakout; arrow down confirms bearish breakout. Use as confirmation for entries, adds, or exits. |
Code:
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input showBreakoutSignals = no;
input price = close;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.SIMPLE;
input displace = 0;
def sDev = StDev(data = price[-displace], length = length);
def MidLineBB = MovingAverage(averageType, data = price[-displace], length = length);
def LowerBandBB = MidLineBB + Num_Dev_Dn * sDev;
def UpperBandBB = MidLineBB + Num_Dev_up * sDev;
input factorhigh = 1.0;
input factormid = 1.5;
input factorlow = 2.0;
input trueRangeAverageType = AverageType.SIMPLE;
def shifthigh = factorhigh * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def shiftMid = factormid * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def shiftlow = factorlow * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, price, length);
def Avg = average[-displace];
def UpperBandKCLow = average[-displace] + shiftlow[-displace];
def LowerBandKCLow = average[-displace] - shiftlow[-displace];
def UpperBandKCMid = average[-displace] + shiftMid[-displace];
def LowerBandKCMid = average[-displace] - shiftMid[-displace];
def UpperBandKCHigh = average[-displace] + shifthigh[-displace];
def LowerBandKCHigh = average[-displace] - shifthigh[-displace];
def K = (Highest(high, length) + Lowest(low, length)) /
2 + ExpAverage(close, length);
def momo = Inertia(price - K / 2, length);
def pos = momo>= 0;
def neg = momo< 0;
def up = momo >= momo[1];
def dn = momo < momo[1];
def presqueeze = LowerBandBB > LowerBandKCLow and UpperBandBB < UpperBandKCLow;
def originalSqueeze = LowerBandBB > LowerBandKCMid and UpperBandBB < UpperBandKCMid;
def ExtrSqueeze = LowerBandBB > LowerBandKCHigh and UpperBandBB < UpperBandKCHigh;
def PosUp = pos and up;
def PosDn = pos and dn;
def NegDn = neg and dn;
def NegUp = neg and up;
plot squeezeline = 0;
squeezeline.SetPaintingStrategy(PaintingStrategy.POINTS);
squeezeline.AssignValueColor(if ExtrSqueeze then Color.Dark_reD else if originalSqueeze then Color.red else if presqueeze then Color.light_oRANGE else Color.greeN);
plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg1 = MovingAverage(averageType, Value, MACDLength);
plot Diff = Value - Avg1;
plot ZeroLine = 0;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
Value.SetDefaultColor(GetColor(1));
Avg1.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Last edited by a moderator: