MACD Histogram Crossover Indicator for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Warehouse
MACDHistogramCrossover_Paris
Chatroom Request
8.30.2018
Displays number of bars since the last MACDHistogram Crossover signal
Added logic to display direction of last crossover signal


Pay attention to yellow and blue arrows.

thinkScript Code

Rich (BB code):
input ShowEducationLabels = yes;  added by JQ for education purposes

input fastLength = 12;

input slowLength = 26;

input MACDLength = 9;

input averageType = AverageType.EXPONENTIAL;

def Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;

def XUp;

def XDn;

if Crosses(Diff, 0, CrossingDirection.BELOW) {

    XUp = no;

    XDn = yes;
}


else if (Crosses(Diff, 0, CrossingDirection.ABOVE)) {

    XUp = yes;

    XDn = no;

} 

else {

    XUp = XUp[1];

    XDn = XDn[1];

}

def crossBarUp = if XUp and !XUp[1] then BarNumber() else crossBarUp[1];

def crossBarDn = if XDn and !XDn[1] then BarNumber() else crossBarDn[1];

addlabel(yes,"crossBarUp: " + crossBarUp, color.lime);  added by JQ for education

addlabel(yes,"crossBarDn: " + crossBarDn, color.lime);  added by JQ for education

addlabel(yes,"BarNumber(): " + BarNumber(), color.lime);  added by JQ for education

plot bullSig = if XUp and !XUp[1] then low else Double.NaN;

     bullSig.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

     bullSig.SetDefaultColor(Color.YELLOW);

     bullSig.SetLineWeight(3);

plot bearSig = if XDn and !XDn[1] then high else Double.NaN;

     bearSig.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

     bearSig.SetDefaultColor(Color.CYAN);

     bearSig.SetLineWeight(3);

AddLabel(1, "Bars since last MACD Histogram " + 

    (if crossBarUp > crossBarDn then "BULLISH" 

                                else "BEARISH") + " Crossover:  " + 

    (if crossBarUp > crossBarDn then BarNumber() - crossBarUp 

                                else BarNumber() - crossBarDn), 

    if crossBarUp > crossBarDn then Color.YELLOW else Color.CYAN);

# END STUDY
To use with Supertrend and other momentum indicators for additional confirmations.
 
Last edited:
J

jerrydinvestor

New member
VIP
What are the other two bottom indicators on the screenshot?

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@jerrydinvestor I'll be sharing them soon.

 
Last edited:
J

jerrydinvestor

New member
VIP
Modified Macd_Break and added MA lines from the original MACD indicator. It seems to be more accurate than original MACD indicator by one candle.



 
Last edited:
J

joshuadstout

New member
VIP
Warehouse
This reminds me of a script I saw with 32, 59, 9 exponential positive to negative indicator but have never seen it very often, also with negative to positive
 

Top