Indicator · Pine Script v5 · On the chart

Trend Correlation Heatmap

by AubakirovArman· code credited to Steversteves

Shows a heatmap of trend strength for up to four user-chosen timeframes.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code264
Settings6inputs
LicenceMIT
Last update3 months ago26 Jul 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

264 lines of Pine Script v5 from pine/6-trend-correlation-heatmap.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

6-trend-correlation-heatmap.pine
//  /$$$$$$   /$$                                                         /$$                                            
// /$$__  $$ | $$                                                        | $$                                            
//| $$  \__//$$$$$$    /$$$$$$  /$$    /$$ /$$$$$$   /$$$$$$   /$$$$$$$ /$$$$$$    /$$$$$$  /$$    /$$ /$$$$$$   /$$$$$$$
//|  $$$$$$|_  $$_/   /$$__  $$|  $$  /$$//$$__  $$ /$$__  $$ /$$_____/|_  $$_/   /$$__  $$|  $$  /$$//$$__  $$ /$$_____/
// \____  $$ | $$    | $$$$$$$$ \  $$/$$/| $$$$$$$$| $$  \__/|  $$$$$$   | $$    | $$$$$$$$ \  $$/$$/| $$$$$$$$|  $$$$$$ 
// /$$  \ $$ | $$ /$$| $$_____/  \  $$$/ | $$_____/| $$       \____  $$  | $$ /$$| $$_____/  \  $$$/ | $$_____/ \____  $$
//|  $$$$$$/ |  $$$$/|  $$$$$$$   \  $/  |  $$$$$$$| $$       /$$$$$$$/  |  $$$$/|  $$$$$$$   \  $/  |  $$$$$$$ /$$$$$$$/
// \______/   \___/   \_______/    \_/    \_______/|__/      |_______/    \___/   \_______/    \_/    \_______/|_______/ 

//       ___________________
//      /                   \
//     /  _____        _____ \
//    /  /     \      /     \  \
// __/__/       \____/       \__\_____
//|           ___________           ____|
// \_________/           \_________/
//            \  /////// /
//             \/////////
// © Steversteves
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///                                                           Information                                                                               ///
///                                                                                                                                                     ///
///The trend heatmap indicator looks at various trend correlations on up to 4 user defined timeframes.                                                  ///
///It will plot the trend from 50 to 500 by increments of 50 on each specified timeframe.                                                               ///
///It will assign a colour code to the trend correlation which specifies the strength and direction of the trend.                                       ///
/// A legend is provided within the indicator and can be toggled on our off. The default setting is to toggle it on.                                    ///
/// The indicator will provide the overall Strongest and Weakest trend based on the specified timeframes.                                               /// 
/// For example, if you select the following: 1 minute, 5 minute, 30 minute and 60 minute, the indicator will identify the strongest an weaknest trend  ///
/// between all of those designated timeframes.                                                                                                         ///
///                                                                                                                                                     ///
///The indicator will also identify the strongest uptrend and downtrend for each specified timeframe.                                                   ///
/// It is important to note that a significant downtrend or uptrend per timeframe is defined as the largest positive and negative correlation +         /// 
/// having a Pearon correaltion coefficient (R value) of greater than or = to 0.5 or -0.5 respectively.                                                 ///
///                                                                                                                                                     /// 
///                                                     Why care about trend correlations?                                                              ///
///                                                                                                                                                     ///
/// Trend correlations to time offer an objective way to mathmatically measure the strength of an uptrend or downtrend.                                 ///
/// Identifying where significant trends rest within a ticker can also allow you to adjust other indicators you use to the correct timeframe.           ///
/// For example, if you are using an EMA to scalp a specific ticker on the 1 minute timeframe, if there is a strong uptrend correlation                 ///
/// at 100 candles, it may be more appropriate to adjust your EMA to the 100 tf, as this is the tf with the most reliable trend.                        ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//@version=5
indicator("Trend Correlation Heatmap", shorttitle = "Trend Heatmap", overlay=true)

// User inputs 
timeframe1 = input.timeframe("1", "Timeframe One")  
timeframe2 = input.timeframe("5", "Timeframe Two") 
timeframe3 = input.timeframe("30", "Timeframe Three") 
timeframe4 = input.timeframe("1D", "Timeframe Four") 
showchange = input.bool(false, "Show Max and Min Change")
showlegend = input.bool(true, "Show Colour Legend") 

// Correlation 
f_correlation(timeframe, len) => 
    result = request.security(syminfo.ticker, timeframe, ta.correlation(close, time, len)) 

// Timeframe1 
cor1_50 = f_correlation(timeframe1, 50) 
cor1_100 = f_correlation(timeframe1, 100)
cor1_150 = f_correlation(timeframe1, 150) 
cor1_200 = f_correlation(timeframe1, 200)
cor1_250 = f_correlation(timeframe1, 250) 
cor1_300 = f_correlation(timeframe1, 300) 
cor1_350 = f_correlation(timeframe1, 350) 
cor1_400 = f_correlation(timeframe1, 400) 
cor1_450 = f_correlation(timeframe1, 450) 
cor1_500 = f_correlation(timeframe1, 500) 

// Timeframe2
cor5_50 = f_correlation(timeframe2, 50)
cor5_100 = f_correlation(timeframe2, 100)
cor5_150 = f_correlation(timeframe2, 150)
cor5_200 = f_correlation(timeframe2, 200)
cor5_250 = f_correlation(timeframe2, 250)
cor5_300 = f_correlation(timeframe2, 300)
cor5_350 = f_correlation(timeframe2, 350)
cor5_400 = f_correlation(timeframe2, 400)
cor5_450 = f_correlation(timeframe2, 450)
cor5_500 = f_correlation(timeframe2, 500)

// Timeframe3
cor30_50 = f_correlation(timeframe3, 50)
cor30_100 = f_correlation(timeframe3, 100)
cor30_150 = f_correlation(timeframe3, 150)
cor30_200 = f_correlation(timeframe3, 200)
cor30_250 = f_correlation(timeframe3, 250)
cor30_300 = f_correlation(timeframe3, 300)
cor30_350 = f_correlation(timeframe3, 350)
cor30_400 = f_correlation(timeframe3, 400)
cor30_450 = f_correlation(timeframe3, 450)
cor30_500 = f_correlation(timeframe3, 500)

// Timeframe4 
cor60_50 = f_correlation(timeframe4, 50)
cor60_100 = f_correlation(timeframe4, 100)
cor60_150 = f_correlation(timeframe4, 150)
cor60_200 = f_correlation(timeframe4, 200)
cor60_250 = f_correlation(timeframe4, 250)
cor60_300 = f_correlation(timeframe4, 300)
cor60_350 = f_correlation(timeframe4, 350) 
cor60_400 = f_correlation(timeframe4, 400)
cor60_450 = f_correlation(timeframe4, 450)
cor60_500 = f_correlation(timeframe4, 500)

// averages 
avg50 = math.avg(cor1_50, cor5_50, cor30_50, cor60_50) 
avg100 = math.avg(cor1_100, cor5_100, cor30_100, cor60_100)
avg150 = math.avg(cor1_150, cor5_150, cor30_150, cor60_150) 
avg200 = math.avg(cor1_200, cor5_200, cor30_200, cor60_200)
avg250 = math.avg(cor1_250, cor5_250, cor30_250, cor60_250)
avg300 = math.avg(cor1_300, cor5_300, cor30_300, cor60_300)
avg350 = math.avg(cor1_350, cor5_350, cor30_350, cor60_350) 
avg400 = math.avg(cor1_400, cor5_400, cor30_400, cor60_400)
avg450 = math.avg(cor1_450, cor5_450, cor30_450, cor60_450)
avg500 = math.avg(cor1_500, cor5_500, cor30_500, cor60_500)

// Min and Max 
cor1_max = math.max(cor1_50, cor1_100, cor1_150, cor1_200, cor1_250, cor1_300, cor1_350, cor1_400, cor1_450, cor1_500) 
cor1_min = math.min(cor1_50, cor1_100, cor1_150, cor1_200, cor1_250, cor1_300, cor1_350, cor1_400, cor1_450, cor1_500) 

cor5_max = math.max(cor5_50, cor5_100, cor5_150, cor5_200, cor5_250, cor5_300, cor5_350, cor5_400, cor5_450, cor5_500) 
cor5_min = math.min(cor5_50, cor5_100, cor5_150, cor5_200, cor5_250, cor5_300, cor5_350, cor5_400, cor5_450, cor5_500) 

cor30_max = math.max(cor30_50, cor30_100, cor30_150, cor30_200, cor30_250, cor30_300, cor30_350, cor30_400, cor30_450, cor30_500)
cor30_min = math.min(cor30_50, cor30_100, cor30_150, cor30_200, cor30_250, cor30_300, cor30_350, cor30_400, cor30_450, cor30_500)

cor60_max = math.max(cor60_50, cor60_100, cor60_150, cor60_200, cor60_250, cor60_300, cor60_350, cor60_400, cor60_450, cor60_500)
cor60_min = math.min(cor60_50, cor60_100, cor60_150, cor60_200, cor60_250, cor60_300, cor60_350, cor60_400, cor60_450, cor60_500)

total_max = math.max(cor1_50, cor1_100, cor1_150, cor1_200, cor1_250, cor1_300, cor1_350, cor1_400, cor1_450, cor1_500, cor5_50, cor5_100, cor5_150, cor5_200, cor5_250, cor5_300, cor5_350, cor5_400, cor5_450, cor5_500, cor30_50, cor30_100, cor30_150, cor30_200, cor30_250, cor30_300, cor30_350, cor30_400, cor30_450, cor30_500, cor60_50, cor60_100, cor60_150, cor60_200, cor60_250, cor60_300, cor60_350, cor60_400, cor60_450, cor60_500)
total_min = math.min(cor1_50, cor1_100, cor1_150, cor1_200, cor1_250, cor1_300, cor1_350, cor1_400, cor1_450, cor1_500, cor5_50, cor5_100, cor5_150, cor5_200, cor5_250, cor5_300, cor5_350, cor5_400, cor5_450, cor5_500, cor30_50, cor30_100, cor30_150, cor30_200, cor30_250, cor30_300, cor30_350, cor30_400, cor30_450, cor30_500, cor60_50, cor60_100, cor60_150, cor60_200, cor60_250, cor60_300, cor60_350, cor60_400, cor60_450, cor60_500)

// Colour Function
f_colour(variable, totalmax, totalmin, max, min) =>
    color green = color.lime 
    color red = color.red 
    color orange = color.orange 
    color yellow = color.yellow 
    color purple = color.purple
    color aqua = color.aqua 
    color blackfill = color.rgb(0, 0, 0) 


    variable == totalmax and variable >= 0.5 ? purple : variable == totalmin and variable <= -0.5 ? aqua : variable == max and variable >= 0.5 ? green : variable == min and variable <= -0.5 ? red : variable <= -0.5 and variable >= -1 ? orange : variable >= 0.5 and variable <= 1 ? yellow : blackfill

f_text_colour(variable, max, min) => 
    color purple = color.purple 
    color black = color.rgb(0, 0, 0) 
    color white = color.white
    variable == max and variable >= 0.5 ? white : variable == min and variable <= -0.5 ? white : variable <= -0.5 and variable >= -1 ? black : variable >= 0.5 and variable <= 1 ? black : white

// Table Colours 
color black =   color.rgb(0, 0, 0) 
color white =   color.white 

// Legend Colours 
color green =   color.lime 
color red =     color.red 
color orange =  color.orange 
color yellow =  color.yellow 
color purple =  color.purple
color aqua =    color.aqua 

var trendtable = table.new(position.top_right, 10, 12, bgcolor = black) 

table.cell(trendtable, 1, 1, text = "Length", bgcolor = black, text_color=white) 
table.cell(trendtable, 2, 1, text = str.tostring(timeframe1), bgcolor = black, text_color=white) 
table.cell(trendtable, 3, 1, text = str.tostring(timeframe2), bgcolor = black, text_color=white) 
table.cell(trendtable, 4, 1, text = str.tostring(timeframe3), bgcolor = black, text_color=white) 
table.cell(trendtable, 5, 1, text = str.tostring(timeframe4), bgcolor = black, text_color=white) 
table.cell(trendtable, 6, 1, text = "Average", bgcolor = black, text_color=white) 
// Reference
table.cell(trendtable, 1, 2, text = "50", bgcolor = black, text_color=white) 
table.cell(trendtable, 1, 3, text = "100", bgcolor = black, text_color=white) 
table.cell(trendtable, 1, 4, text = "150", bgcolor = black, text_color=white) 
table.cell(trendtable, 1, 5, text = "200", bgcolor = black, text_color=white) 
table.cell(trendtable, 1, 6, text = "250", bgcolor = black, text_color=white) 
table.cell(trendtable, 1, 7, text = "300", bgcolor = black, text_color=white) 
table.cell(trendtable, 1, 8, text = "350", bgcolor = black, text_color=white) 
table.cell(trendtable, 1, 9, text = "400", bgcolor = black, text_color=white)
table.cell(trendtable, 1, 10, text = "450", bgcolor = black, text_color=white)
table.cell(trendtable, 1, 11, text = "500", bgcolor = black, text_color=white)
// 1 minute
table.cell(trendtable, 2, 2, text = str.tostring(math.round(cor1_50, 2)), bgcolor=f_colour(cor1_50, total_max, total_min, cor1_max, cor1_min), text_color=f_text_colour(cor1_50, cor1_max, cor1_min))
table.cell(trendtable, 2, 3, text = str.tostring(math.round(cor1_100, 2)), bgcolor=f_colour(cor1_100, total_max, total_min, cor1_max, cor1_min), text_color=f_text_colour(cor1_100, cor1_max, cor1_min))
table.cell(trendtable, 2, 4, text = str.tostring(math.round(cor1_150, 2)), bgcolor=f_colour(cor1_150, total_max, total_min, cor1_max, cor1_min), text_color=f_text_colour(cor1_150, cor1_max, cor1_min))
table.cell(trendtable, 2, 5, text = str.tostring(math.round(cor1_200, 2)), bgcolor=f_colour(cor1_200, total_max, total_min, cor1_max, cor1_min), text_color=f_text_colour(cor1_200, cor1_max, cor1_min))
table.cell(trendtable, 2, 6, text = str.tostring(math.round(cor1_250, 2)), bgcolor=f_colour(cor1_250, total_max, total_min, cor1_max, cor1_min), text_color=f_text_colour(cor1_250, cor1_max, cor1_min))
table.cell(trendtable, 2, 7, text = str.tostring(math.round(cor1_300, 2)), bgcolor=f_colour(cor1_300, total_max, total_min, cor1_max, cor1_min), text_color=f_text_colour(cor1_300, cor1_max, cor1_min))
table.cell(trendtable, 2, 8, text = str.tostring(math.round(cor1_350, 2)), bgcolor=f_colour(cor1_350, total_max, total_min, cor1_max, cor1_min), text_color=f_text_colour(cor1_350, cor1_max, cor1_min))
table.cell(trendtable, 2, 9, text = str.tostring(math.round(cor1_400, 2)), bgcolor=f_colour(cor1_400, total_max, total_min, cor1_max, cor1_min), text_color=f_text_colour(cor1_400, cor1_max, cor1_min))
table.cell(trendtable, 2, 10, text = str.tostring(math.round(cor1_450, 2)), bgcolor=f_colour(cor1_450, total_max, total_min, cor1_max, cor1_min), text_color=f_text_colour(cor1_450, cor1_max, cor1_min))
table.cell(trendtable, 2, 11, text = str.tostring(math.round(cor1_500, 2)), bgcolor=f_colour(cor1_500, total_max, total_min, cor1_max, cor1_min), text_color=f_text_colour(cor1_500, cor1_max, cor1_min))
// 5 Minute
table.cell(trendtable, 3, 2, text = str.tostring(math.round(cor5_50, 2)), bgcolor=f_colour(cor5_50, total_max, total_min, cor30_max, cor30_min), text_color=f_text_colour(cor5_50, cor5_max, cor5_min))
table.cell(trendtable, 3, 3, text = str.tostring(math.round(cor5_100, 2)), bgcolor=f_colour(cor5_100, total_max, total_min, cor5_max, cor5_min), text_color=f_text_colour(cor5_100, cor5_max, cor5_min))
table.cell(trendtable, 3, 4, text = str.tostring(math.round(cor5_150, 2)), bgcolor=f_colour(cor5_150, total_max, total_min, cor5_max, cor5_min), text_color=f_text_colour(cor5_150, cor5_max, cor5_min))
table.cell(trendtable, 3, 5, text = str.tostring(math.round(cor5_200, 2)), bgcolor=f_colour(cor5_200, total_max, total_min, cor5_max, cor5_min), text_color=f_text_colour(cor5_200, cor5_max, cor5_min))
table.cell(trendtable, 3, 6, text = str.tostring(math.round(cor5_250, 2)), bgcolor=f_colour(cor5_250, total_max, total_min, cor5_max, cor5_min), text_color=f_text_colour(cor5_250, cor5_max, cor5_min))
table.cell(trendtable, 3, 7, text = str.tostring(math.round(cor5_300, 2)), bgcolor=f_colour(cor5_300, total_max, total_min, cor5_max, cor5_min), text_color=f_text_colour(cor5_300, cor5_max, cor5_min))
table.cell(trendtable, 3, 8, text = str.tostring(math.round(cor5_350, 2)), bgcolor=f_colour(cor5_350, total_max, total_min, cor5_max, cor5_min), text_color=f_text_colour(cor5_350, cor5_max, cor5_min))
table.cell(trendtable, 3, 9, text = str.tostring(math.round(cor5_400, 2)), bgcolor=f_colour(cor5_400, total_max, total_min, cor5_max, cor5_min), text_color=f_text_colour(cor5_400, cor5_max, cor5_min))
table.cell(trendtable, 3, 10, text = str.tostring(math.round(cor5_450, 2)), bgcolor=f_colour(cor5_450, total_max, total_min, cor5_max, cor5_min), text_color=f_text_colour(cor5_450, cor5_max, cor5_min))
table.cell(trendtable, 3, 11, text = str.tostring(math.round(cor5_500, 2)), bgcolor=f_colour(cor5_500, total_max, total_min, cor5_max, cor5_min), text_color=f_text_colour(cor5_500, cor5_max, cor5_min))
// 30 Minute
table.cell(trendtable, 4, 2, text = str.tostring(math.round(cor30_50, 2)), bgcolor=f_colour(cor30_50, total_max, total_min, cor30_max, cor30_min), text_color=f_text_colour(cor30_50, cor30_max, cor30_min))
table.cell(trendtable, 4, 3, text = str.tostring(math.round(cor30_100, 2)), bgcolor=f_colour(cor30_100, total_max, total_min, cor30_max, cor30_min), text_color=f_text_colour(cor30_100, cor30_max, cor30_min))
table.cell(trendtable, 4, 4, text = str.tostring(math.round(cor30_150, 2)), bgcolor=f_colour(cor30_150, total_max, total_min, cor30_max, cor30_min), text_color=f_text_colour(cor30_150, cor30_max, cor30_min))
table.cell(trendtable, 4, 5, text = str.tostring(math.round(cor30_200, 2)), bgcolor=f_colour(cor30_200, total_max, total_min, cor30_max, cor30_min), text_color=f_text_colour(cor30_200, cor30_max, cor30_min))
table.cell(trendtable, 4, 6, text = str.tostring(math.round(cor30_250, 2)), bgcolor=f_colour(cor30_250, total_max, total_min, cor30_max, cor30_min), text_color=f_text_colour(cor30_250, cor30_max, cor30_min))
table.cell(trendtable, 4, 7, text = str.tostring(math.round(cor30_300, 2)), bgcolor=f_colour(cor30_300, total_max, total_min, cor30_max, cor30_min), text_color=f_text_colour(cor30_300, cor30_max, cor30_min))
table.cell(trendtable, 4, 8, text = str.tostring(math.round(cor30_350, 2)), bgcolor=f_colour(cor30_350, total_max, total_min, cor30_max, cor30_min), text_color=f_text_colour(cor30_350, cor30_max, cor30_min))
table.cell(trendtable, 4, 9, text = str.tostring(math.round(cor30_400, 2)), bgcolor=f_colour(cor30_400, total_max, total_min, cor30_max, cor30_min), text_color=f_text_colour(cor30_400, cor30_max, cor30_min))
table.cell(trendtable, 4, 10, text = str.tostring(math.round(cor30_450, 2)), bgcolor=f_colour(cor30_450, total_max, total_min, cor30_max, cor30_min), text_color=f_text_colour(cor30_450, cor30_max, cor30_min))
table.cell(trendtable, 4, 11, text = str.tostring(math.round(cor30_500, 2)), bgcolor=f_colour(cor30_500, total_max, total_min, cor30_max, cor30_min), text_color=f_text_colour(cor30_500, cor30_max, cor30_min))
// 1 hour 
table.cell(trendtable, 5, 2, text = str.tostring(math.round(cor60_50, 2)), bgcolor=f_colour(cor60_50, total_max, total_min, cor60_max, cor60_min), text_color=f_text_colour(cor60_50, cor60_max, cor60_min))
table.cell(trendtable, 5, 3, text = str.tostring(math.round(cor60_100, 2)), bgcolor=f_colour(cor60_100, total_max, total_min, cor60_max, cor60_min), text_color=f_text_colour(cor60_100, cor60_max, cor60_min))
table.cell(trendtable, 5, 4, text = str.tostring(math.round(cor60_150, 2)), bgcolor=f_colour(cor60_150, total_max, total_min, cor60_max, cor60_min), text_color=f_text_colour(cor60_150, cor60_max, cor60_min))
table.cell(trendtable, 5, 5, text = str.tostring(math.round(cor60_200, 2)), bgcolor=f_colour(cor60_200, total_max, total_min, cor60_max, cor60_min), text_color=f_text_colour(cor60_200, cor60_max, cor60_min))
table.cell(trendtable, 5, 6, text = str.tostring(math.round(cor60_250, 2)), bgcolor=f_colour(cor60_250, total_max, total_min, cor60_max, cor60_min), text_color=f_text_colour(cor60_250, cor60_max, cor60_min))
table.cell(trendtable, 5, 7, text = str.tostring(math.round(cor60_300, 2)), bgcolor=f_colour(cor60_300, total_max, total_min, cor60_max, cor60_min), text_color=f_text_colour(cor60_300, cor60_max, cor60_min))
table.cell(trendtable, 5, 8, text = str.tostring(math.round(cor60_350, 2)), bgcolor=f_colour(cor60_350, total_max, total_min, cor60_max, cor60_min), text_color=f_text_colour(cor60_350, cor60_max, cor60_min))
table.cell(trendtable, 5, 9, text = str.tostring(math.round(cor60_400, 2)), bgcolor=f_colour(cor60_400, total_max, total_min, cor60_max, cor60_min), text_color=f_text_colour(cor60_400, cor60_max, cor60_min))
table.cell(trendtable, 5, 10, text = str.tostring(math.round(cor60_450, 2)), bgcolor=f_colour(cor60_450, total_max, total_min, cor60_max, cor60_min), text_color=f_text_colour(cor60_450, cor60_max, cor60_min))
table.cell(trendtable, 5, 11, text = str.tostring(math.round(cor60_500, 2)), bgcolor=f_colour(cor60_500, total_max, total_min, cor60_max, cor60_min), text_color=f_text_colour(cor60_500, cor60_max, cor60_min))
// Average
table.cell(trendtable, 6, 2, text = str.tostring(math.round(avg50, 2)), bgcolor=black, text_color=white)
table.cell(trendtable, 6, 3, text = str.tostring(math.round(avg100, 2)), bgcolor=black, text_color=white)
table.cell(trendtable, 6, 4, text = str.tostring(math.round(avg150, 2)), bgcolor=black, text_color=white)
table.cell(trendtable, 6, 5, text = str.tostring(math.round(avg200, 2)), bgcolor=black, text_color=white)
table.cell(trendtable, 6, 6, text = str.tostring(math.round(avg250, 2)), bgcolor=black, text_color=white)
table.cell(trendtable, 6, 7, text = str.tostring(math.round(avg300, 2)), bgcolor=black, text_color=white)
table.cell(trendtable, 6, 8, text = str.tostring(math.round(avg350, 2)), bgcolor=black, text_color=white)
table.cell(trendtable, 6, 9, text = str.tostring(math.round(avg400, 2)), bgcolor=black, text_color=white)
table.cell(trendtable, 6, 10, text = str.tostring(math.round(avg450, 2)), bgcolor=black, text_color=white)
table.cell(trendtable, 6, 11, text = str.tostring(math.round(avg500, 2)), bgcolor=black, text_color=white)


// Strongest and Weaknest 

total_max_change = ta.change(total_max, 14) 
total_min_change = ta.change(total_min, 14) 

var datatable = table.new(position.bottom_right, 3, 9, bgcolor = black) 
if showchange
    table.cell(datatable, 1, 1, text = "Max Change:", bgcolor = black, text_color = total_max_change > 0 ? green : red) 
    table.cell(datatable, 2, 1, text = str.tostring(math.round(total_max_change,4)), bgcolor = black, text_color = total_max_change > 0 ? green: red) 
    table.cell(datatable, 1, 2, text = "Min Change:", bgcolor = black, text_color = total_min_change > 0 ? green : red) 
    table.cell(datatable, 2, 2, text = str.tostring(math.round(total_min_change,4)), bgcolor = black, text_color = total_min_change > 0 ? green : red) 
if showlegend  
    table.cell(datatable, 1, 3, text = "Strongest Overall Uptrend", bgcolor = black, text_color = white) 
    table.cell(datatable, 2, 3, text = "         ", bgcolor = purple)
    table.cell(datatable, 1, 4, text = "Strongest Overall Downtrend", bgcolor = black, text_color=white) 
    table.cell(datatable, 2, 4, text = "         ", bgcolor = aqua)
    table.cell(datatable, 1, 5, text = "Strongest Uptrend (per timeframe)", bgcolor = black, text_color=white) 
    table.cell(datatable, 2, 5, text = "         ", bgcolor = green)
    table.cell(datatable, 1, 6, text = "Strongest Downtrend (per timeframe)", bgcolor = black, text_color=white) 
    table.cell(datatable, 2, 6, text = "         ", bgcolor = red)
    table.cell(datatable, 1, 7, text = "Significant Uptrend (per timeframe)", bgcolor = black, text_color=white)
    table.cell(datatable, 2, 7, text = "         ", bgcolor = yellow, text_color=white)
    table.cell(datatable, 1, 8, text = "Significant Downtrend (per timeframe)", bgcolor = black, text_color=white)
    table.cell(datatable, 2, 8, text = "         ", bgcolor = orange, text_color=white)

Overview

For each timeframe it measures the Pearson correlation of price with time over lookbacks from 50 to 500 bars in steps of 50, and colours each cell by strength and direction. It reports the strongest and weakest trends across the chosen timeframes and per timeframe, treating correlations of 0.5 or more in either direction as significant. A colour legend and a maximum and minimum change display are optional.

Details

Published by

AubakirovArman on GitHub

Code credit

Steversteves, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Screeners & dashboards

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.

Topics

backtestingbinanceblocklybybitchartingcryptono-codereactself-hostedtechnical-analysis

Settings

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

SettingTypeDefaultVariable
Timeframe Onetimeframe1timeframe1
Timeframe Twotimeframe5timeframe2
Timeframe Threetimeframe30timeframe3
Timeframe Fourtimeframe1Dtimeframe4
Show Max and Min Changeboolfalseshowchange
Show Colour Legendbooltrueshowlegend
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

257 stars

This indicator overlays an intraday SPX and ES chart with a midnight session range, regular-trading-hours opening levels, and a VWAP projection box. It draws the midnight high, mid, and low, flags edge rejections within an absolute tolerance, and plots optiona

Indicator v6 TrendSupport & resistance
Updated 6 weeks ago · None stated GitHub repository of SPX Midnight Box + Snag Logic
218 stars

TradersPost Trading Checklist is an overlay indicator that evaluates a suite of popular technical conditions for long and short trade setups. It checks session-anchored VWAP, fast and slow EMA alignments and crosses, 200 SMA, RSI overbought or oversold conditi

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of TradersPost Trading Checklist
92 stars

This indicator classifies the market into gamma regime types (negative gamma trend, positive gamma mean-reversion, or transition) by calculating a composite score based on daily ATR ratios, session VWAP crossover frequencies, and opening range displacement. It

Indicator v5 Volatility & bandsTrend
Updated 2 months ago · Custom licence GitHub repository of Moon Dev GEX Regime & Trap

EMA Ribbon Overlay

by iamrichardD
57 stars

Calculates exponential moving averages for fast, pivot, and slow lengths along with optional 50, 100, and 200 simple moving average context lines. It visualizes bullish and bearish ribbon fills on the main price chart alongside MACD calculations to generate ea

Indicator v6 TrendMoving averages
Updated 1 year ago · Apache-2.0 GitHub repository of EMA Ribbon Overlay
53 stars

Apex Trend & Liquidity Master calculates a trend cloud using customizable moving averages expanded by a volatility multiplier directly on the main price chart. It identifies dynamic support and resistance liquidity zones from swing high and low pivots, extendi

Indicator v6 TrendSupport & resistance
Updated 2 months ago · MPL-2.0 GitHub repository of Apex Trend & Liquidity Master

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