declare lower; input MomLength = 12; input SmoothLength = 21; DefineGlobalColor("IndicatorColor", Color.BLUE); DefineGlobalColor("SigLineColor", Color.CYAN); DefineGlobalColor("PosHistUpColor", Color.GREEN); DefineGlobalColor("PosHistDnColor", Color.DARK_GREEN); DefineGlobalColor("NegHistUpColor", Color.DARK_RED); DefineGlobalColor("NegHistDnColor", Color.RED); # PosHistDnColor(DarkGreen), # NegHistDnColor(Red), # NegHistUpColor(DarkRed); #def CSmooth = 0.000001; def H = high; def L = low; #{Momentum calculations} def Candle = ((H + L) / 2 - (H[1] + L[1]) / 2); def CSmooth = Max((ExpAverage(ExpAverage(AbsValue(Candle), MomLength), SmoothLength)), 0.000001); plot CMom = 100 * ((ExpAverage(ExpAverage(Candle, MomLength), SmoothLength)) / CSmooth); def CLag = ExpAverage(CMom, 9); plot CSigLine = CMom[1]; plot MomHist = 2 * (CMom - CLag); MomHist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM); def hc = if MomHist >= 0 and MomHist >= MomHist[1] then 1 else if MomHist >= 0 and MomHist < MomHist[1] then 2 else if MomHist < 0 and MomHist <= MomHist[1] then 3 else if MomHist < 0 and MomHist > MomHist[1] then 4 else 0; MomHist.AssignValueColor(if hc == 1 then GlobalColor("PosHistUpColor") else if hc == 2 then GlobalColor("PosHistDnColor") else if hc == 3 then GlobalColor("NegHistDnColor") else if hc == 4 then GlobalColor("NegHistUpColor") else Color.BLACK); #Plot1(CMom, "MomLine",IndicatorColor); #Plot2(CSigLine, "SigLine", SigLineColor); #Plot3(MomHist * 2, "Hist"); #{Set color of histogram} #If MomHist >= 0 and MomHist >= MomHist[1] then SetPlotColor(3,PosHistUpColor); #if MomHist >= 0 and MomHist < MomHist[1] then SetPlotColor(3,PosHistDnColor); #if MomHist < 0 and MomHist <= MomHist[1] then SetPlotColor(3,NegHistDnColor); #if MomHist < 0 and MomHist > MomHist[1] then SetPlotColor(3,NegHistUpColor);