Indicator · Pine Script v4 · Own pane

Angular Momentum Heat Map

by mikeyhu70

A Pine v4 pane indicator that builds a stack of up to 28 rows of moving average based momentum readings and colors them as a heat map, with greens for positive and reds for negative momentum.

View on GitHub

GitHub stars1on the repository
Pine versionv4older, still runs
Lines of code353
Settings11inputs
LicenceNone statedfile: MPL-2.0
Last update6 months ago15 Apr 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

353 lines of Pine Script v4 from Angular Momentum/Angular Momentum Heatmap.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Angular Momentum Heatmap.txt
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

//@version=4
study("Angular Momentum Heat Map", shorttitle="AMHM", overlay=false)

_source = close

src = close
MA =        input(title="MA", options=["SMA", "EMA", "WMA"], defval="EMA")
sm =        input(false, title="Smooth Momentum")
smp =       input(2, title="Smoothing Period")
Theme =     input(title="Theme", options=["Theme 1", "Theme 2", "Theme 3"], defval="Theme 2")
inc =       input(title="Increment", defval=1)
smooth =    input(title="Smooth", defval=1, type=input.integer)
smoothSlow= input(title="Smooth Slow", defval=10, type=input.integer)
plotNumber= input(title="Plot Number", defval=28, minval=1, maxval=28, type=input.integer)
PaintBars = input(title="Paint Bars", defval=false, type=input.bool)
IncType =   input(title="Waves", defval=false, type=input.bool)
loopback =  input(title="Loopback Length to Normalize (def 3 x multiple of Plot Number (i.e 28)", defval=84, type=input.integer)


nma(src, length1, length2) =>
    lambda = length1 / length2
    alpha = lambda * (length1 - 1) / (length1 - lambda)
    ma1 = ema(src, length1)
    ma2 = ema(ma1, length2)
    nma = (1 + alpha) * ma1 - alpha * ma2
    
dema(src, len) => 
    ma1 = ema(src, len)
    ma2 = ema(ma1, len)
    2 * ma1 - ma2
    
eTma(_src, _len) =>
    _tma = ema(ema(_src, _len), _len)
    
tma(_src, _len) =>
  _tma = sma(sma(_src, _len), _len)
    
noma(_src,_len) =>
    _noma = _src

tema(src, len) => 
    ma1 = ema(src, len)
    ma2 = ema(ma1, len)
    ma3 = ema(ma2, len)
    3 * (ma1 - ma2) + ma3

tdema(src, len) => 
    ma1 = dema(src, len)
    ma2 = dema(ma1, len)
    ma3 = dema(ma2, len)
    3 * (ma1 - ma2) + ma3

ttema(src, len) => 
    ma1 = tema(src, len)
    ma2 = tema(ma1, len)
    ma3 = tema(ma2, len)
    3 * (ma1 - ma2) + ma3

tnma(src, len) => 
    ma1 = nma(src, len, 3)
    ma2 = nma(ma1, len, 3)
    ma3 = nma(ma2, len, 3)
    3 * (ma1 - ma2) + ma3

thma(src, len) => 
    ma1 = hma(src, len)
    ma2 = hma(ma1, len)
    ma3 = hma(ma2, len)
    3 * (ma1 - ma2) + ma3

zlema(src, len) =>
    lag = round((len - 1) / 2)
    zlsrc = src + (src - src[lag])
    ema(zlsrc, len)

zldema(src, len) =>
    lag = round((len - 1) / 2)
    zlsrc = src + (src - src[lag])
    dema(zlsrc, len)
    
zltema(src, len) =>
    lag = round((len - 1) / 2)
    zlsrc = src + (src - src[lag])
    tema(zlsrc, len)
    
dzlema(src, len) => 
    ma1 = zlema(src, len)
    ma2 = zlema(ma1, len)
    2 * ma1 - ma2

tzlema(src, len) => 
    ma1 = zlema(src, len)
    ma2 = zlema(ma1, len)
    ma3 = zlema(ma2, len)
    3 * (ma1 - ma2) + ma3

llema(src, len) =>
    srcnew = 0.25*src + 0.5*src[1] + 0.25*src[2]
    ema(srcnew, len)
    
llsma(src, len) =>
    srcnew = 0.25*src + 0.5*src[1] + 0.25*src[2]
    sma(srcnew, len)
    
llhma(src, len) =>
    srcnew = 0.25*src + 0.5*src[1] + 0.25*src[2]
    hma(srcnew, len)
    
llwma(src, len) =>
    srcnew = 0.25*src + 0.5*src[1] + 0.25*src[2]
    wma(srcnew, len)
    
llrma(src, len) =>
    srcnew = 0.25*src + 0.5*src[1] + 0.25*src[2]
    rma(srcnew, len)
    
lltema(src, len) =>
    srcnew = 0.25*src + 0.5*src[1] + 0.25*src[2]
    tema(srcnew, len)

trans = 0

cp1 = color.new(#01ff00, trans)
cp2 = color.new(#05d904, trans)
cp3 = color.new(#04b504, trans)
cp4 = color.new(#039103, trans)
cp5 = color.new(#027502, trans)

cn0 = color.new(#eb0000, trans)
cn1 = color.new(#ff0505, trans)
cn2 = color.new(#d60606, trans)
cn3 = color.new(#b80606, trans)
cn4 = color.new(#910303, trans)
cn5 = color.new(#750202, trans)

cp6 =  color.new(#00ddff, trans)
cp7 =  color.new(#04bcd9, trans)
cp8 =  color.new(#049cb3, trans)
cp9 =  color.new(#047f91, trans)
cp10 = color.new(#046775, trans)

cn6a =  color.new(#c200e6, trans)
cn6 =  color.new(#d800ff, trans)
cn7 =  color.new(#bb04db, trans)
cn8 =  color.new(#9b05b5, trans)
cn9 =  color.new(#7b038f, trans)
cn10 = color.new(#640275, trans)

cp11 = color.new(#cf0000, trans)
cp12 = color.new(#f22b11, trans)
cp13 = color.new(#f29811, trans)
cp14 = color.new(#eef211, trans)
cp15 = color.new(#3af211, trans)

cn11a = color.new(#022085, trans)
cn11 = color.new(#02269e, trans)
cn12 = color.new(#0039f5, trans)
cn13 = color.new(#1176f2, trans)
cn14 = color.new(#11aff2, trans)
cn15 = color.new(#11e7f2, trans)

fc1 = color.new(color.white, 0)
sc1 = color.new(color.silver, 0)
//fc2 = color.new(color.white, 0)
fc2 = color.new(color.fuchsia, 0)
//sc2 = color.new(color.blue, 0)
sc2 = color.new(color.white, 0)
fc3 = color.new(color.white, 0)
sc3 = color.new(color.orange, 0)

fastColour = Theme == "Theme 1" ? fc1 : Theme == "Theme 2" ? fc2  : fc3
slowColour = Theme == "Theme 1" ? sc1 : Theme == "Theme 2" ? sc2  : sc3

pColour1 = Theme == "Theme 1" ? cp1 : Theme == "Theme 2" ? cp6  : cp11
pColour2 = Theme == "Theme 1" ? cp2 : Theme == "Theme 2" ? cp7  : cp12
pColour3 = Theme == "Theme 1" ? cp3 : Theme == "Theme 2" ? cp8  : cp13
pColour4 = Theme == "Theme 1" ? cp4 : Theme == "Theme 2" ? cp9  : cp14
pColour5 = Theme == "Theme 1" ? cp5 : Theme == "Theme 2" ? cp10 : cp15

nColour0 = Theme == "Theme 1" ? cn0 : Theme == "Theme 2" ? cn6a  : cn11a
nColour1 = Theme == "Theme 1" ? cn1 : Theme == "Theme 2" ? cn6  : cn11
nColour2 = Theme == "Theme 1" ? cn2 : Theme == "Theme 2" ? cn7  : cn12
nColour3 = Theme == "Theme 1" ? cn3 : Theme == "Theme 2" ? cn8  : cn13
nColour4 = Theme == "Theme 1" ? cn4 : Theme == "Theme 2" ? cn9  : cn14
nColour5 = Theme == "Theme 1" ? cn5 : Theme == "Theme 2" ? cn10 : cn15


//getStoch(i, incr) =>
//    c = (i * inc)
//    s = smooth + incr
//    if MA == "SMA"
//        sma(stoch(_source, high, low, c), s)
//    else
//        if MA == "EMA"
//            ema(stoch(_source, high, low, c), s)
//        else
//            if MA == "WMA"
//                wma(stoch(_source, high, low, c), s)

var c_maxval = array.new_float(1)
var c_minval = array.new_float(1)
                
getStoch(i, incr) =>
    c = (i * inc)
    p = 2 * c + 1
    ema_1 = tzlema(src, smp)
    //amom = 100 * ((sm ? ema_1 : src) / dema(src, p) - 1)
    amom = (100*((sm ? ema_1 : src) / dema(src, p) - 1)) + 0.5
    array.set(c_maxval, 0, highest(amom, loopback))
    array.set(c_minval, 0, lowest(amom, loopback))
    ret = amom
    

a_mid = (array.get(c_maxval,0) + array.get(c_minval,0))/2
//a_mid = 0
a_upper_increment = abs(array.get(c_maxval,0) - a_mid)/20
a_lower_increment = abs(a_mid - array.get(c_minval,0))/20

getColour(a) =>
    if(a >= a_mid + 14*a_upper_increment)
        pColour1
    else
        if(a >= a_mid + 10*a_upper_increment)
            pColour2
        else
            if(a >= a_mid + 5*a_upper_increment)
                pColour3
            else
                if(a >= a_mid + 1*a_upper_increment)
                    pColour4
                else
                    if(a >= a_mid)
                        pColour5
                    else
                        if(a >= a_mid -1*a_lower_increment)
                            nColour5
                        else
                            if(a >= a_mid - 4*a_lower_increment)
                                nColour4
                            else
                                if(a >= a_mid - 8*a_lower_increment)
                                    nColour3
                                else
                                    if(a >= a_mid - 11*a_lower_increment)
                                        nColour2
                                    else
                                        if(a >= a_mid - 14*a_lower_increment)
                                            nColour1
                                        else
                                            nColour0
                                            
                                            
                                            
stoch1 =  plotNumber > 0  ? getStoch(IncType ? 1   : 1 , IncType ? 1  : 0) : 0
stoch2 =  plotNumber > 1  ? getStoch(IncType ? 2   : 2 , IncType ? 2  : 0) : 0
stoch3 =  plotNumber > 2  ? getStoch(IncType ? 3   : 3 , IncType ? 3  : 0) : 0
stoch4 =  plotNumber > 3  ? getStoch(IncType ? 4   : 4 , IncType ? 4  : 0) : 0
stoch5 =  plotNumber > 4  ? getStoch(IncType ? 5   : 5 , IncType ? 5  : 0) : 0
stoch6 =  plotNumber > 5  ? getStoch(IncType ? 6   : 6 , IncType ? 6  : 0) : 0
stoch7 =  plotNumber > 6  ? getStoch(IncType ? 7   : 7 , IncType ? 7  : 0) : 0
stoch8 =  plotNumber > 7  ? getStoch(IncType ? 8   : 8 , IncType ? 8  : 0) : 0
stoch9 =  plotNumber > 8  ? getStoch(IncType ? 9   : 9 , IncType ? 9  : 0) : 0
stoch10 = plotNumber > 9  ? getStoch(IncType ? 10  : 10, IncType ? 10 : 0) : 0
stoch11 = plotNumber > 10 ? getStoch(IncType ? 15  : 11, IncType ? 11 : 0) : 0
stoch12 = plotNumber > 11 ? getStoch(IncType ? 20  : 12, IncType ? 12 : 0) : 0
stoch13 = plotNumber > 12 ? getStoch(IncType ? 25  : 13, IncType ? 13 : 0) : 0
stoch14 = plotNumber > 13 ? getStoch(IncType ? 30  : 14, IncType ? 14 : 0) : 0
stoch15 = plotNumber > 14 ? getStoch(IncType ? 35  : 15, IncType ? 15 : 0) : 0
stoch16 = plotNumber > 15 ? getStoch(IncType ? 40  : 16, IncType ? 16 : 0) : 0
stoch17 = plotNumber > 16 ? getStoch(IncType ? 45  : 17, IncType ? 17 : 0) : 0
stoch18 = plotNumber > 17 ? getStoch(IncType ? 50  : 18, IncType ? 18 : 0) : 0
stoch19 = plotNumber > 18 ? getStoch(IncType ? 55  : 19, IncType ? 19 : 0) : 0
stoch20 = plotNumber > 19 ? getStoch(IncType ? 60  : 20, IncType ? 20 : 0) : 0
stoch21 = plotNumber > 20 ? getStoch(IncType ? 70  : 21, IncType ? 21 : 0) : 0
stoch22 = plotNumber > 21 ? getStoch(IncType ? 80  : 22, IncType ? 22 : 0) : 0
stoch23 = plotNumber > 22 ? getStoch(IncType ? 90  : 23, IncType ? 23 : 0) : 0
stoch24 = plotNumber > 23 ? getStoch(IncType ? 100 : 24, IncType ? 24 : 0) : 0
stoch25 = plotNumber > 24 ? getStoch(IncType ? 110 : 25, IncType ? 25 : 0) : 0
stoch26 = plotNumber > 25 ? getStoch(IncType ? 120 : 26, IncType ? 26 : 0) : 0
stoch27 = plotNumber > 26 ? getStoch(IncType ? 140 : 27, IncType ? 27 : 0) : 0
stoch28 = plotNumber > 27 ? getStoch(IncType ? 160 : 28, IncType ? 28 : 0) : 0

colour1 =  getColour(stoch1) 
colour2 =  getColour(stoch2) 
colour3 =  getColour(stoch3) 
colour4 =  getColour(stoch4) 
colour5 =  getColour(stoch5) 
colour6 =  getColour(stoch6) 
colour7 =  getColour(stoch7) 
colour8 =  getColour(stoch8) 
colour9 =  getColour(stoch9) 
colour10 = getColour(stoch10)
colour11 = getColour(stoch11)
colour12 = getColour(stoch12)
colour13 = getColour(stoch13)
colour14 = getColour(stoch14)
colour15 = getColour(stoch15)
colour16 = getColour(stoch16)
colour17 = getColour(stoch17)
colour18 = getColour(stoch18)
colour19 = getColour(stoch19)
colour20 = getColour(stoch20)
colour21 = getColour(stoch21)
colour22 = getColour(stoch22)
colour23 = getColour(stoch23)
colour24 = getColour(stoch24)
colour25 = getColour(stoch25)
colour26 = getColour(stoch26)
colour27 = getColour(stoch27)
colour28 = getColour(stoch28)

getAverage = (stoch1 + stoch2 + stoch3 + stoch4 + stoch5 + stoch6 + stoch7 + stoch8 + stoch9 + stoch10 + stoch11 + stoch12 + stoch13 + stoch14 + stoch15 + stoch16 + stoch17 + stoch18 + stoch19 + stoch20 + stoch21 + stoch22 + stoch23 + stoch24 + stoch25 + stoch26 + stoch27 + stoch28) / plotNumber
fast = ((getAverage / 100) * plotNumber)
slow = MA == "SMA" ? sma(fast, smoothSlow) : MA == "EMA" ? dema(fast, smoothSlow) : wma(fast, smoothSlow)
barColour = getColour(getAverage)

plot1 =  plot(plotNumber > 0  ? 0 : na, color=colour1, linewidth=1)
plot2 =  plot(plotNumber > 1  ? 1 : na, color=colour2, linewidth=1)
plot3 =  plot(plotNumber > 2  ? 2 : na, color=colour3, linewidth=1)
plot4 =  plot(plotNumber > 3  ? 3 : na, color=colour4, linewidth=1)
plot5 =  plot(plotNumber > 4  ? 4 : na, color=colour5, linewidth=1)
plot6 =  plot(plotNumber > 5  ? 5 : na, color=colour6, linewidth=1)
plot7 =  plot(plotNumber > 6  ? 6 : na, color=colour7, linewidth=1)
plot8 =  plot(plotNumber > 7  ? 7 : na, color=colour8, linewidth=1)
plot9 =  plot(plotNumber > 8  ? 8 : na, color=colour9, linewidth=1)
plot10 = plot(plotNumber > 9  ? 9 : na, color=colour10, linewidth=1)
plot11 = plot(plotNumber > 10 ? 10 : na, color=colour11, linewidth=1)
plot12 = plot(plotNumber > 11 ? 11 : na, color=colour12, linewidth=1)
plot13 = plot(plotNumber > 12 ? 12 : na, color=colour13, linewidth=1)
plot14 = plot(plotNumber > 13 ? 13 : na, color=colour14, linewidth=1)
plot15 = plot(plotNumber > 14 ? 14 : na, color=colour15, linewidth=1)
plot16 = plot(plotNumber > 15 ? 15 : na, color=colour16, linewidth=1)
plot17 = plot(plotNumber > 16 ? 16 : na, color=colour17, linewidth=1)
plot18 = plot(plotNumber > 17 ? 17 : na, color=colour18, linewidth=1)
plot19 = plot(plotNumber > 18 ? 18 : na, color=colour19, linewidth=1)
plot20 = plot(plotNumber > 19 ? 19 : na, color=colour20, linewidth=1)
plot21 = plot(plotNumber > 20 ? 20 : na, color=colour21, linewidth=1)
plot22 = plot(plotNumber > 21 ? 21 : na, color=colour22, linewidth=1)
plot23 = plot(plotNumber > 22 ? 22 : na, color=colour23, linewidth=1)
plot24 = plot(plotNumber > 23 ? 23 : na, color=colour24, linewidth=1)
plot25 = plot(plotNumber > 24 ? 24 : na, color=colour25, linewidth=1)
plot26 = plot(plotNumber > 25 ? 25 : na, color=colour26, linewidth=1)
plot27 = plot(plotNumber > 26 ? 26 : na, color=colour27, linewidth=1)
plot28 = plot(plotNumber > 27 ? 27 : na, color=colour28, linewidth=1)
plot29 = plot(plotNumber, color=colour28, linewidth=1)

//plot(slow, color=slowColour, linewidth=1, style=plot.style_line)
//plot(fast, color=fastColour, linewidth=2, style=plot.style_line)

barcolor(PaintBars ? barColour : na)
// -->

Overview

The moving average type can be SMA, EMA or WMA, momentum can be smoothed, and three color themes are available. The increment, smoothing, number of rows plotted and the normalization lookback are adjustable. Bars can optionally be painted, and a waves option changes the row spacing.

Details

Published by

mikeyhu70 on GitHub

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Category

Oscillators & momentum, Trend

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
MAstringEMAMA
Smooth Momentumboolfalsesm
Smoothing Periodint2smp
ThemestringTheme 2Theme
Incrementint1inc
Smoothint1smooth
Smooth Slowint10smoothSlow
Plot Numberint28plotNumber
Paint BarsboolfalsePaintBars
WavesboolfalseIncType
Loopback Length to Normalize (def 3 x multiple of Plot Number (i.e 28)int84loopback
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Schaff Trend Cycle

by everget
947 stars

This indicator plots the Schaff Trend Cycle in a separate pane. It subtracts a slow exponential moving average from a fast one, applies a stochastic cycle twice, and smooths each result to form a 0–100 oscillator. Line color follows the slope, or the upper and

Indicator v4 Oscillators & momentumTrend
Updated 11 days ago · GPL-3.0 GitHub repository of Schaff Trend Cycle

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop

[RS]Standardized Trend Map

by ricardosantos79
261 stars

Standardized Trend Map calculates series momentum relative to active price range across 40 distinct lookback periods ranging from 2 to 80 bars on an exponential moving average source. Each standardized calculation rounds to an integer values of -1, 0, or 1 to

Indicator v4 TrendOscillators & momentum
Updated 4 years ago · None stated GitHub repository of [RS]Standardized Trend Map
228 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

ADX Histogram

by harryguiacorn
220 stars

This indicator calculates and displays the Average Directional Index (ADX) as a column histogram in a separate pane. It evaluates market trend strength by calculating directional movement metrics based on specified smoothing and DI length inputs. When the ADX

Indicator v5 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of ADX Histogram

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers