Modified MACD Momentum Indicator for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP


thinkScript Code

Code:
#
# Grimes Modified MACD + Highest / Lowest Momentum Indicator
# Grimes_Modified_MACD_HILO_GMACDHILO
#
# Author: Kory Gill, @korygill
#
# Version History :
# 20191007-KG - Created.
#
# Assembled by Kory Gill for BenTen at useThinkScript.com
# Original idea: https://www.tradingview.com/script/eVnQUwKW-Grimes-Modified-MACD-Supply-Demand/
#

declare lower;
declare once_per_bar;

input FastLength = 3;
input SlowLength = 10;
input SignalLength = 16;
input HighestLength = 20; #Hint HighestLength: Highest MACD Reading Within N Bars
input LowestLength = 20; #Hint LowestLength: Lowest MACD Reading Within N Bars

def vClose = close;
def vHigh = high;
def vLow = low;
def bn = BarNumber();
def nan = double.NaN;

def fastMA = MovingAverage(AverageType.SIMPLE, vClose, fastLength);
def slowMA = MovingAverage(AverageType.SIMPLE, vClose, slowLength);
def macd = fastMA - slowMA;
def signal = MovingAverage(AverageType.SIMPLE, macd, signalLength);
def higher = MovingAverage(AverageType.SIMPLE, Highest(macd, HighestLength), HighestLength);
def lower = MovingAverage(AverageType.SIMPLE, Lowest(macd, LowestLength), HighestLength);
def macdAbove = if macd > higher then macd else nan; #macdAbove[1];
def macdBelow = if macd < lower then macd else nan; #macdBelow[1];

plot zeroLine = 0;
plot pma = macdAbove;
plot pmb = macdBelow;
plot phi = higher;
plot plo = lower;
plot pmacd = macd;
plot psignal = signal;

zeroLine.SetDefaultColor(Color.White);
zeroLine.SetPaintingStrategy(PaintingStrategy.DASHES);
pmacd.SetDefaultColor(Color.Black);
psignal.SetDefaultColor(Color.Orange);
phi.SetDefaultColor(Color.Cyan);
plo.SetDefaultColor(Color.Cyan);
phi.SetPaintingStrategy(PaintingStrategy.DASHES);
plo.SetPaintingStrategy(PaintingStrategy.DASHES);

AddCloud(pma, phi, Color.Green, Color.Black);
AddCloud(pmb, plo, Color.Black, Color.Red);

# END - Grimes_Modified_MACD_HILO_GMACDHILO
 
BenTen

BenTen

Administrative
Staff
VIP
@Craighaber71 Sorry for the late response, for some reason I didn't see this. I believe when the MACD line crosses the upper band or the lower band, it means the trend toward that direction is overextended. You can use it as areas of support/resistance for the future (as illustrated in the original author's post).
 

Top