Indicator · Pine Script v6 · Own pane

Correlation HeatMap Sessions Data Science Stats

by regalouisei· code credited to TFlab

This indicator plots a multi-asset correlation heatmap in a separate pane to measure statistical relationships between assets.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code387
Settings25inputs
LicenceNone statedfile: MPL-2.0
Last update8 months ago25 Feb 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

387 lines of Pine Script v6 from pinescript/editors_picks/correlation-heatmap-tradingfinder-sessions-data-science-stats.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

correlation-heatmap-tradingfinder-sessions-data-science-stats.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TFlab

//@version=6
indicator("Correlation HeatMap [TradingFinder] Sessions Data Science Stats", "TFlab CHM" ,overlay = false)

//input
Corr_period = input.int(100, 'Correlation Period',group = 'Logic Setting')
Market = input.string('Custom', 'Select Market', ['Forex', 'Stock', 'Crypto', 'Custom'],group = 'Logic Setting')

Show_Session = input.bool(true, 'Show Open Session',group = 'Session Setting')
MarketMode = input.string('Forex', 'Market Mode', options = ['Forex', 'Stock'],group = 'Session Setting')

Sym_Main         = input.symbol   ('XAUUSD', 'Main Symbol' , group = 'Main Custom Symbol'     ) 
Sym_1_C          = input.symbol   ('XAGUSD' , 'Symbol 1'   , group = 'Compared Custom Symbol' )
Sym_2_C          = input.symbol   ('XCUUSD' , 'Symbol 2'   , group = 'Compared Custom Symbol' )
Sym_3_C          = input.symbol   ('EURUSD' , 'Symbol 3'   , group = 'Compared Custom Symbol' )
Sym_4_C          = input.symbol   ('GBPUSD' , 'Symbol 4'   , group = 'Compared Custom Symbol' )
Sym_5_C          = input.symbol   ('US30'   , 'Symbol 5'   , group = 'Compared Custom Symbol' )
Sym_6_C          = input.symbol   ('US100'  , 'Symbol 6'   , group = 'Compared Custom Symbol' )
Sym_7_C          = input.symbol   ('US500'  , 'Symbol 7'   , group = 'Compared Custom Symbol' )
Sym_8_C          = input.symbol   ('US2000' , 'Symbol 8'   , group = 'Compared Custom Symbol' )
Sym_9_C          = input.symbol   ('BTCUSD' , 'Symbol 9'   , group = 'Compared Custom Symbol' )
Sym_10_C         = input.symbol   ('ETHUSD' ,  'Symbol 10' , group = 'Compared Custom Symbol' )
Sym_11_C         = input.symbol   ('DOGEUSD',  'Symbol 11' , group = 'Compared Custom Symbol' )
Sym_12_C         = input.symbol   ('LTCUSD' ,  'Symbol 12' , group = 'Compared Custom Symbol' )
Sym_13_C         = input.symbol   ('USDCAD' ,  'Symbol 13' , group = 'Compared Custom Symbol' )
Sym_14_C         = input.symbol   ('USDJPY' ,  'Symbol 14' , group = 'Compared Custom Symbol' )
Sym_15_C         = input.symbol   ('USDCHF' ,  'Symbol 15' , group = 'Compared Custom Symbol' )
Sym_16_C         = input.symbol   ('AUDUSD' ,  'Symbol 15' , group = 'Compared Custom Symbol' )
Sym_17_C         = input.symbol   ('NZDUSD' ,  'Symbol 15' , group = 'Compared Custom Symbol' )
Sym_18_C         = input.symbol   ('EURGBP' ,  'Symbol 18' , group = 'Compared Custom Symbol' )
Sym_19_C         = input.symbol   ('EURCHF' ,  'Symbol 19' , group = 'Compared Custom Symbol' )
Sym_20_C         = input.symbol   ('NZDJPY' ,  'Symbol 20' , group = 'Compared Custom Symbol' )

//variable
var string Main_Sym ='' ,var string Sym_1 = '' , var string Sym_2 = '' , var string Sym_3 = '' , var string Sym_4 = '' , var string Sym_5 = '' , var string Sym_6 = '' , var string Sym_7 = '' , var string Sym_8 = '' , var string Sym_9 = '' , var string Sym_10 = ''
var string Sym_11 = '', var string Sym_12 = '', var string Sym_13 = '', var string Sym_14 = '', var string Sym_15 = '', var string Sym_16 = '', var string Sym_17 = '', var string Sym_18 = '', var string Sym_19 = '', var string Sym_20 = ''

//Switching Market
switch Market
    'Forex' => Main_Sym := syminfo.ticker, Sym_1  := 'EURUSD' , Sym_2 := 'GBPUSD' , Sym_3 := 'USDJPY' , Sym_4 := 'USDCHF' , Sym_5 := 'USDCAD' , Sym_6 := 'AUDUSD' , Sym_7 := 'NZDUSD' , Sym_8 := 'EURJPY' , Sym_9 := 'EURGBP' , Sym_10 := 'GBPJPY'
     ,Sym_11 := 'AUDJPY', Sym_12 := 'EURCHF', Sym_13 := 'EURCAD', Sym_14 := 'GBPCAD', Sym_15 := 'CADJPY', Sym_16 := 'CHFJPY', Sym_17 := 'NZDJPY', Sym_18 := 'AUDNZD', Sym_19 := 'USDSEK' , Sym_20 := 'USDNOK'

    'Stock' => Main_Sym := syminfo.ticker, Sym_1  := 'NVDA' , Sym_2 := 'AAPL' , Sym_3 := 'GOOGL' , Sym_4 := 'GOOG' , Sym_5 := 'META' , Sym_6 := 'MSFT' , Sym_7 := 'AMZN' , Sym_8 := 'AVGO' , Sym_9 := 'TSLA' , Sym_10 := 'BRK.B'
     ,Sym_11 := 'UNH'  , Sym_12 := 'V'   , Sym_13 := 'JPM'  , Sym_14 := 'WMT' , Sym_15 := 'LLY' , Sym_16 := 'ORCL', Sym_17 := 'HD'  , Sym_18 := 'JNJ' , Sym_19 := 'MA'  , Sym_20 := 'COST'

    'Crypto' => Main_Sym := syminfo.ticker, Sym_1  := 'BTCUSD' , Sym_2 := 'ETHUSD' , Sym_3 := 'BNBUSD' , Sym_4 := 'XRPUSD' , Sym_5 := 'SOLUSD' , Sym_6 := 'ADAUSD' , Sym_7 := 'DOGEUSD' , Sym_8 := 'AVAXUSD' , Sym_9 := 'DOTUSD' , Sym_10 := 'TRXUSD'
     ,Sym_11 := 'LTCUSD' , Sym_12 := 'LINKUSD', Sym_13 := 'UNIUSD', Sym_14 := 'ATOMUSD', Sym_15 := 'ICPUSD', Sym_16 := 'ARBUSD', Sym_17 := 'APTUSD', Sym_18 := 'FILUSD', Sym_19 := 'OPUSD' , Sym_20 := 'USDT.D'

    'Custom' => Main_Sym := Sym_Main , Sym_1  := Sym_1_C , Sym_2 := Sym_2_C , Sym_3 := Sym_3_C , Sym_4 := Sym_4_C , Sym_5 := Sym_5_C , Sym_6 := Sym_6_C , Sym_7 := Sym_7_C , Sym_8 := Sym_8_C , Sym_9 := Sym_9_C , Sym_10 := Sym_10_C
     ,Sym_11 := Sym_11_C, Sym_12 := Sym_12_C, Sym_13 := Sym_13_C, Sym_14 := Sym_14_C, Sym_15 := Sym_15_C, Sym_16 := Sym_16_C, Sym_17 := Sym_17_C, Sym_18 := Sym_18_C, Sym_19 := Sym_19_C , Sym_20 := Sym_20_C

//Daylight Saving Time
DST_Detector(Start_Month, Start_Day, Start_CountDay, End_Month, End_Day, End_CountDay, TimeZone) =>
    var int StartCountDay = 0
    var int EndCountDay   = 0
    var bool S_PermitCount = true
    var bool E_PermitCount = true
    var bool SS_PermitCount = true
    var bool EE_PermitCount = true
    var int S = Start_CountDay
    var int E = End_CountDay   
    Y = year
    M = month
    D = dayofweek
    //dayofmonth counter
    if M[1] != M
        StartCountDay := 0
        EndCountDay   := 0
        SS_PermitCount := true
        EE_PermitCount := true       
    if D[1] != D
        S_PermitCount := true
        E_PermitCount := true

    if D == Start_Day and S_PermitCount
        StartCountDay  := StartCountDay + 1
        S_PermitCount := false

    if D == End_Day and E_PermitCount
        EndCountDay    := EndCountDay + 1
        E_PermitCount := false
    if Start_CountDay < 4 and SS_PermitCount == true
        S := Start_CountDay
    else if Start_CountDay == 4 and SS_PermitCount == true
        if StartCountDay < 4
            S := 4
        else if (StartCountDay[1] == 3 and StartCountDay == 4) and dayofmonth > 23
            S := 4
            SS_PermitCount := false
        else 
            S := 5
    
    if End_CountDay < 4 and EE_PermitCount == true
        E := End_CountDay
    else if End_CountDay == 4 and EE_PermitCount == true
        if EndCountDay < 4
            E := 4
        else if (EndCountDay[1] == 3 and EndCountDay == 4) and dayofmonth > 23
            E := 4
            EE_PermitCount := false
        else 
            E := 5

    if  M == Start_Month and StartCountDay >= S
     or  (M > Start_Month and M < End_Month)
     or M == End_Month and  EndCountDay < E 
        TimeZone == "Australia/Sydney" ? 'Inactive' : 'Active'
    else 
        TimeZone == "Australia/Sydney" ? 'Active' : 'Inactive'
    
Sydney_DST  = DST_Detector(4 , dayofweek.sunday, 1, 10 , dayofweek.sunday, 1, "Australia/Sydney")
London_DST  = DST_Detector(3 , dayofweek.sunday, 4, 10 , dayofweek.sunday, 4,    "Europe/London")
NewYork_DST = DST_Detector(3 , dayofweek.sunday, 2, 11 , dayofweek.sunday, 1, "America/New_York")

//Session Timing
Market_TimeZone_Calculator(MarketMode ,TimeZoneMode) =>
    var string Sydney   = na
    var string Tokyo    = na
    var string Shanghai = na
    var string Asia     = na
    var string Europe   = na
    var string London   = na
    var string NewYork  = na
    var string NYSE     = na
    if MarketMode == 'Forex'
        if TimeZoneMode == 'UTC'

            if Sydney_DST == 'Inactive'
                Sydney   := '2200-0600'
                Asia     := '2200-0700'

            else if Sydney_DST == 'Active'
                Sydney   := '2100-0500'
                Asia     := '2100-0700'


            if London_DST == 'Inactive'
                Europe   := '0700-1600'
                London   := '0800-1600'

            else if London_DST == 'Active'
                Europe   := '0600-1500'
                London   := '0700-1500'


            if NewYork_DST == 'Inactive'
                NewYork  := '1300-2100'
            else if NewYork_DST == 'Active'
                NewYork  := '1200-2000'

            Tokyo    := '2300-0700'
            Shanghai := '0100-0900'

    if MarketMode == 'Stock'
        if TimeZoneMode == 'UTC'

            if Sydney_DST == 'Inactive'
                Sydney   := '0000-0600'
                Asia     := '0000-0600'

            else if Sydney_DST == 'Active'
                Sydney   := '2300-0500' 
                Asia     := '2300-0600'


            if London_DST == 'Inactive'
                Europe   := '0700-1630'
                London   := '0800-1630'

            else if London_DST == 'Active'
                Europe   := '0600-1530'
                London   := '0700-1530'


            if NewYork_DST == 'Inactive'
                NewYork  := '1430-2100'
            else if NewYork_DST == 'Active'
                NewYork  := '1330-2000' 
            
            Tokyo    := '0000-0600'
            Shanghai := '0130-0700'
    [Sydney, Tokyo, Shanghai, Asia, Europe, London, NewYork, NYSE]
[Sydney, Tokyo, Shanghai, Asia, Europe, London, NewYork, NYSE] = Market_TimeZone_Calculator(MarketMode, 'UTC')


On_sesTokyo = math.sign(nz(time(timeframe.period, Tokyo, 'UTC+0')))
On_seslondon = math.sign(nz(time(timeframe.period, London, 'UTC+0')))
On_sesNewyork = math.sign(nz(time(timeframe.period, NewYork, 'UTC+0')))

//Drawing Sessions
OpenSessions(On_Session, Text_Session) => 
    var line  Vertical     = na 
    var label Session_Name = na 

    if (On_Session[1] == 0 and On_Session == 1)
        Vertical     := line.new(bar_index, 1, bar_index, 22.5, color = #73767e)
        Session_Name := label.new(bar_index,23 ,text = Text_Session  , textcolor = #73767e, color = #ffffff00, style = label.style_label_center )

if Show_Session
    OpenSessions(On_sesTokyo   , 'Open Tokyo')
    OpenSessions(On_seslondon  , 'Open London')
    OpenSessions(On_sesNewyork , 'Open NY')

//HeatMap Color
CorrelationHeatMapColor(float corr) =>
    s1 = corr >= -1.0 and corr < -0.8
    s2 = corr >= -0.8 and corr < -0.6
    s3 = corr >= -0.6 and corr < -0.4
    s4 = corr >= -0.4 and corr < -0.2
    s5 = corr >= -0.2 and corr <  0.0
    s6 = corr >=  0.0 and corr <  0.2
    s7 = corr >=  0.2 and corr <  0.4
    s8 = corr >=  0.4 and corr <  0.6
    s9 = corr >=  0.6 and corr <  0.8
    s10 = corr >= 0.8 and corr <  0.9
    s11 = corr >= 0.9 and corr <= 1.0

    c1  = color.from_gradient(corr, -1.0, -0.8, #990000, #cc0000)
    c2  = color.from_gradient(corr, -0.8, -0.6, #cc0000, #ff6600)
    c3  = color.from_gradient(corr, -0.6, -0.4, #ff6600, #ffcc00)
    c4  = color.from_gradient(corr, -0.4, -0.2, #ffcc00, #ccff66)
    c5  = color.from_gradient(corr, -0.2,  0.0, #ccff66, #66ff66)
    c6  = color.from_gradient(corr,  0.0,  0.2, #66ff66, #66ffcc)
    c7  = color.from_gradient(corr,  0.2,  0.4, #66ffcc, #33ccff)
    c8  = color.from_gradient(corr,  0.4,  0.6, #33ccff, #3399ff)
    c9  = color.from_gradient(corr,  0.6,  0.8, #3399ff, #0066ff)
    c10 = color.from_gradient(corr,  0.8,  0.9, #0066ff, #4902bb)
    c11 = color.from_gradient(corr,  0.9,  1.0, #4902bb, #410280)

    s1 ? c1 : s2 ? c2 : s3 ? c3 : s4 ? c4 : s5 ? c5 : s6 ? c6 : s7 ? c7 : s8 ? c8 : s9 ? c9 : s10 ? c10 : c11
    
//Correlation Function
Corr(Sx, Sy, y) =>
    c = ta.correlation(Sx, Sy, y)
    c

//get data & calculation
Data_Heat(int Corr_Period,string Sym_Main, string Sym_1, string Sym_2, string Sym_3, string Sym_4, string Sym_5, string Sym_6, string Sym_7, string Sym_8, string Sym_9, string Sym_10, string Sym_11, string Sym_12, string Sym_13, string Sym_14, string Sym_15, string Sym_16, string Sym_17, string Sym_18, string Sym_19, string Sym_20) => 
    Sym_Main_D  = request.security(Sym_Main , timeframe.period, close)
    Sym_1_D     = request.security(Sym_1 , timeframe.period, close)
    Sym_2_D     = request.security(Sym_2 , timeframe.period, close)
    Sym_3_D     = request.security(Sym_3 , timeframe.period, close)
    Sym_4_D     = request.security(Sym_4 , timeframe.period, close)
    Sym_5_D     = request.security(Sym_5 , timeframe.period, close)
    Sym_6_D     = request.security(Sym_6 , timeframe.period, close)
    Sym_7_D     = request.security(Sym_7 , timeframe.period, close)
    Sym_8_D     = request.security(Sym_8 , timeframe.period, close)
    Sym_9_D     = request.security(Sym_9 , timeframe.period, close)
    Sym_10_D    = request.security(Sym_10, timeframe.period, close)
    Sym_11_D    = request.security(Sym_11, timeframe.period, close)
    Sym_12_D    = request.security(Sym_12, timeframe.period, close)
    Sym_13_D    = request.security(Sym_13, timeframe.period, close)
    Sym_14_D    = request.security(Sym_14, timeframe.period, close)
    Sym_15_D    = request.security(Sym_15, timeframe.period, close)
    Sym_16_D    = request.security(Sym_16, timeframe.period, close)
    Sym_17_D    = request.security(Sym_17, timeframe.period, close)
    Sym_18_D    = request.security(Sym_18, timeframe.period, close)
    Sym_19_D    = request.security(Sym_19, timeframe.period, close)
    Sym_20_D    = request.security(Sym_20, timeframe.period, close)
    SYM_1_1  = Corr(Sym_Main_D , Sym_1_D , Corr_Period)
    SYM_1_2  = Corr(Sym_Main_D , Sym_2_D , Corr_Period)
    SYM_1_3  = Corr(Sym_Main_D , Sym_3_D , Corr_Period)
    SYM_1_4  = Corr(Sym_Main_D , Sym_4_D , Corr_Period)
    SYM_1_5  = Corr(Sym_Main_D , Sym_5_D , Corr_Period)
    SYM_1_6  = Corr(Sym_Main_D , Sym_6_D , Corr_Period)
    SYM_1_7  = Corr(Sym_Main_D , Sym_7_D , Corr_Period)
    SYM_1_8  = Corr(Sym_Main_D , Sym_8_D , Corr_Period)
    SYM_1_9  = Corr(Sym_Main_D , Sym_9_D , Corr_Period)
    SYM_1_10 = Corr(Sym_Main_D , Sym_10_D, Corr_Period)
    SYM_1_11 = Corr(Sym_Main_D , Sym_11_D, Corr_Period)
    SYM_1_12 = Corr(Sym_Main_D , Sym_12_D, Corr_Period)
    SYM_1_13 = Corr(Sym_Main_D , Sym_13_D, Corr_Period)
    SYM_1_14 = Corr(Sym_Main_D , Sym_14_D, Corr_Period)
    SYM_1_15 = Corr(Sym_Main_D , Sym_15_D, Corr_Period)
    SYM_1_16 = Corr(Sym_Main_D , Sym_16_D, Corr_Period)
    SYM_1_17 = Corr(Sym_Main_D , Sym_17_D, Corr_Period)
    SYM_1_18 = Corr(Sym_Main_D , Sym_18_D, Corr_Period)
    SYM_1_19 = Corr(Sym_Main_D , Sym_19_D, Corr_Period)
    SYM_1_20 = Corr(Sym_Main_D , Sym_20_D, Corr_Period)
    [SYM_1_1 ,SYM_1_2 ,SYM_1_3 ,SYM_1_4 ,SYM_1_5 ,SYM_1_6 ,SYM_1_7 ,SYM_1_8 ,SYM_1_9 ,SYM_1_10,SYM_1_11,SYM_1_12,SYM_1_13,SYM_1_14,SYM_1_15,SYM_1_16,SYM_1_17,SYM_1_18,SYM_1_19,SYM_1_20]

//Call Function
[SYM_1_1_H ,SYM_1_2_H ,SYM_1_3_H ,SYM_1_4_H ,SYM_1_5_H ,SYM_1_6_H ,SYM_1_7_H ,SYM_1_8_H ,SYM_1_9_H ,SYM_1_10_H,
 SYM_1_11_H,SYM_1_12_H,SYM_1_13_H,SYM_1_14_H,SYM_1_15_H,SYM_1_16_H,SYM_1_17_H,SYM_1_18_H,SYM_1_19_H,SYM_1_20_H] = 
 Data_Heat(Corr_period, Main_Sym, Sym_1 ,Sym_2 ,Sym_3 ,Sym_4 ,Sym_5 ,Sym_6 ,Sym_7 ,Sym_8 ,Sym_9 ,Sym_10,Sym_11,Sym_12,Sym_13,Sym_14,Sym_15,Sym_16,Sym_17,Sym_18,Sym_19,Sym_20)


//Drawing HeatMap
P_1   = plot(1 , color = #ffffff00, display = display.none) 
P_2   = plot(2 , color = #ffffff00, display = display.none)  , fill(P_1 , P_2 , color= CorrelationHeatMapColor(SYM_1_20_H ))
P_3   = plot(3 , color = #ffffff00, display = display.none)  , fill(P_2 , P_3 , color= CorrelationHeatMapColor(SYM_1_19_H ))
P_4   = plot(4 , color = #ffffff00, display = display.none)  , fill(P_3 , P_4 , color= CorrelationHeatMapColor(SYM_1_18_H ))
P_5   = plot(5 , color = #ffffff00, display = display.none)  , fill(P_4 , P_5 , color= CorrelationHeatMapColor(SYM_1_17_H ))
P_6   = plot(6 , color = #ffffff00, display = display.none)  , fill(P_5 , P_6 , color= CorrelationHeatMapColor(SYM_1_16_H ))
P_7   = plot(7 , color = #ffffff00, display = display.none)  , fill(P_6 , P_7 , color= CorrelationHeatMapColor(SYM_1_15_H ))
P_8   = plot(8 , color = #ffffff00, display = display.none)  , fill(P_7 , P_8 , color= CorrelationHeatMapColor(SYM_1_14_H ))
P_9   = plot(9 , color = #ffffff00, display = display.none)  , fill(P_8 , P_9 , color= CorrelationHeatMapColor(SYM_1_13_H ))
P_10  = plot(10, color = #ffffff00, display = display.none)  , fill(P_9 , P_10, color= CorrelationHeatMapColor(SYM_1_12_H ))
P_11  = plot(11, color = #ffffff00, display = display.none)  , fill(P_10, P_11, color= CorrelationHeatMapColor(SYM_1_11_H ))
P_12  = plot(12, color = #ffffff00, display = display.none)  , fill(P_11, P_12, color= CorrelationHeatMapColor(SYM_1_10_H ))
P_13  = plot(13, color = #ffffff00, display = display.none)  , fill(P_12, P_13, color= CorrelationHeatMapColor(SYM_1_9_H  ))
P_14  = plot(14, color = #ffffff00, display = display.none)  , fill(P_13, P_14, color= CorrelationHeatMapColor(SYM_1_8_H  ))
P_15  = plot(15, color = #ffffff00, display = display.none)  , fill(P_14, P_15, color= CorrelationHeatMapColor(SYM_1_7_H  ))
P_16  = plot(16, color = #ffffff00, display = display.none)  , fill(P_15, P_16, color= CorrelationHeatMapColor(SYM_1_6_H  ))
P_17  = plot(17, color = #ffffff00, display = display.none)  , fill(P_16, P_17, color= CorrelationHeatMapColor(SYM_1_5_H  ))
P_18  = plot(18, color = #ffffff00, display = display.none)  , fill(P_17, P_18, color= CorrelationHeatMapColor(SYM_1_4_H  ))
P_19  = plot(19, color = #ffffff00, display = display.none)  , fill(P_18, P_19, color= CorrelationHeatMapColor(SYM_1_3_H  ))
P_20  = plot(20, color = #ffffff00, display = display.none)  , fill(P_19, P_20, color= CorrelationHeatMapColor(SYM_1_2_H  ))
P_21  = plot(21, color = #ffffff00, display = display.none)  , fill(P_20, P_21, color= CorrelationHeatMapColor(SYM_1_1_H  ))


Label_1  = label.new(bar_index , 1.5 , '              ' + (Market != 'Custom' ? Sym_20 : str.split(Sym_20,':').get(1)) , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_1[1])
Label_2  = label.new(bar_index , 2.5 , '              ' + (Market != 'Custom' ? Sym_19 : str.split(Sym_19,':').get(1)) , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_2[1])
Label_3  = label.new(bar_index , 3.5 , '              ' + (Market != 'Custom' ? Sym_18 : str.split(Sym_18,':').get(1)) , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_3[1])
Label_4  = label.new(bar_index , 4.5 , '              ' + (Market != 'Custom' ? Sym_17 : str.split(Sym_17,':').get(1)) , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_4[1])
Label_5  = label.new(bar_index , 5.5 , '              ' + (Market != 'Custom' ? Sym_16 : str.split(Sym_16,':').get(1)) , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_5[1])
Label_6  = label.new(bar_index , 6.5 , '              ' + (Market != 'Custom' ? Sym_15 : str.split(Sym_15,':').get(1)) , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_6[1])
Label_7  = label.new(bar_index , 7.5 , '              ' + (Market != 'Custom' ? Sym_14 : str.split(Sym_14,':').get(1)) , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_7[1])
Label_8  = label.new(bar_index , 8.5 , '              ' + (Market != 'Custom' ? Sym_13 : str.split(Sym_13,':').get(1)) , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_8[1])
Label_9  = label.new(bar_index , 9.5 , '              ' + (Market != 'Custom' ? Sym_12 : str.split(Sym_12,':').get(1)) , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_9[1])
Label_10 = label.new(bar_index , 10.5, '              ' + (Market != 'Custom' ? Sym_11 : str.split(Sym_11,':').get(1)) , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_10[1])
Label_11 = label.new(bar_index , 11.5, '              ' + (Market != 'Custom' ? Sym_10 : str.split(Sym_10,':').get(1)) , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_11[1])
Label_12 = label.new(bar_index , 12.5, '              ' + (Market != 'Custom' ? Sym_9  : str.split(Sym_9,':').get(1))  , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_12[1])
Label_13 = label.new(bar_index , 13.5, '              ' + (Market != 'Custom' ? Sym_8  : str.split(Sym_8,':').get(1))  , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_13[1])
Label_14 = label.new(bar_index , 14.5, '              ' + (Market != 'Custom' ? Sym_7  : str.split(Sym_7,':').get(1))  , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_14[1])
Label_15 = label.new(bar_index , 15.5, '              ' + (Market != 'Custom' ? Sym_6  : str.split(Sym_6,':').get(1))  , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_15[1])
Label_16 = label.new(bar_index , 16.5, '              ' + (Market != 'Custom' ? Sym_5  : str.split(Sym_5,':').get(1))  , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_16[1])
Label_17 = label.new(bar_index , 17.5, '              ' + (Market != 'Custom' ? Sym_4  : str.split(Sym_4,':').get(1))  , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_17[1])
Label_18 = label.new(bar_index , 18.5, '              ' + (Market != 'Custom' ? Sym_3  : str.split(Sym_3,':').get(1))  , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_18[1])
Label_19 = label.new(bar_index , 19.5, '              ' + (Market != 'Custom' ? Sym_2  : str.split(Sym_2,':').get(1))  , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_19[1])
Label_20 = label.new(bar_index , 20.5, '              ' + (Market != 'Custom' ? Sym_1  : str.split(Sym_1,':').get(1))  , style = label.style_label_center ,color = #ffffff00, textcolor = #73767e) , label.delete(Label_20[1])


Line_L_1  = line.new(bar_index + 30, 1 , bar_index + 30, 2 , color = #ffffff00 ), line.delete(Line_L_1[1] ) , Line_R_1  = line.new(bar_index + 35, 1 , bar_index + 35, 2 , color = #ffffff00 ), line.delete(Line_R_1[1])
Line_L_2  = line.new(bar_index + 30, 2 , bar_index + 30, 3 , color = #ffffff00 ), line.delete(Line_L_2[1] ) , Line_R_2  = line.new(bar_index + 35, 2 , bar_index + 35, 3 , color = #ffffff00 ), line.delete(Line_R_2[1])
Line_L_3  = line.new(bar_index + 30, 3 , bar_index + 30, 4 , color = #ffffff00 ), line.delete(Line_L_3[1] ) , Line_R_3  = line.new(bar_index + 35, 3 , bar_index + 35, 4 , color = #ffffff00 ), line.delete(Line_R_3[1])
Line_L_4  = line.new(bar_index + 30, 4 , bar_index + 30, 5 , color = #ffffff00 ), line.delete(Line_L_4[1] ) , Line_R_4  = line.new(bar_index + 35, 4 , bar_index + 35, 5 , color = #ffffff00 ), line.delete(Line_R_4[1])
Line_L_5  = line.new(bar_index + 30, 5 , bar_index + 30, 6 , color = #ffffff00 ), line.delete(Line_L_5[1] ) , Line_R_5  = line.new(bar_index + 35, 5 , bar_index + 35, 6 , color = #ffffff00 ), line.delete(Line_R_5[1])
Line_L_6  = line.new(bar_index + 30, 6 , bar_index + 30, 7 , color = #ffffff00 ), line.delete(Line_L_6[1] ) , Line_R_6  = line.new(bar_index + 35, 6 , bar_index + 35, 7 , color = #ffffff00 ), line.delete(Line_R_6[1])
Line_L_7  = line.new(bar_index + 30, 7 , bar_index + 30, 8 , color = #ffffff00 ), line.delete(Line_L_7[1] ) , Line_R_7  = line.new(bar_index + 35, 7 , bar_index + 35, 8 , color = #ffffff00 ), line.delete(Line_R_7[1])
Line_L_8  = line.new(bar_index + 30, 8 , bar_index + 30, 9 , color = #ffffff00 ), line.delete(Line_L_8[1] ) , Line_R_8  = line.new(bar_index + 35, 8 , bar_index + 35, 9 , color = #ffffff00 ), line.delete(Line_R_8[1])
Line_L_9  = line.new(bar_index + 30, 9 , bar_index + 30, 10, color = #ffffff00 ), line.delete(Line_L_9[1] ) , Line_R_9  = line.new(bar_index + 35, 9 , bar_index + 35, 10, color = #ffffff00 ), line.delete(Line_R_9[1])
Line_L_10 = line.new(bar_index + 30, 10, bar_index + 30, 11, color = #ffffff00 ), line.delete(Line_L_10[1]) , Line_R_10 = line.new(bar_index + 35, 10, bar_index + 35, 11, color = #ffffff00 ), line.delete(Line_R_10[1])
Line_L_11 = line.new(bar_index + 30, 11, bar_index + 30, 12, color = #ffffff00 ), line.delete(Line_L_11[1]) , Line_R_11 = line.new(bar_index + 35, 11, bar_index + 35, 12, color = #ffffff00 ), line.delete(Line_R_11[1])
Line_L_12 = line.new(bar_index + 30, 12, bar_index + 30, 13, color = #ffffff00 ), line.delete(Line_L_12[1]) , Line_R_12 = line.new(bar_index + 35, 12, bar_index + 35, 13, color = #ffffff00 ), line.delete(Line_R_12[1])
Line_L_13 = line.new(bar_index + 30, 13, bar_index + 30, 14, color = #ffffff00 ), line.delete(Line_L_13[1]) , Line_R_13 = line.new(bar_index + 35, 13, bar_index + 35, 14, color = #ffffff00 ), line.delete(Line_R_13[1])
Line_L_14 = line.new(bar_index + 30, 14, bar_index + 30, 15, color = #ffffff00 ), line.delete(Line_L_14[1]) , Line_R_14 = line.new(bar_index + 35, 14, bar_index + 35, 15, color = #ffffff00 ), line.delete(Line_R_14[1])
Line_L_15 = line.new(bar_index + 30, 15, bar_index + 30, 16, color = #ffffff00 ), line.delete(Line_L_15[1]) , Line_R_15 = line.new(bar_index + 35, 15, bar_index + 35, 16, color = #ffffff00 ), line.delete(Line_R_15[1])
Line_L_16 = line.new(bar_index + 30, 16, bar_index + 30, 17, color = #ffffff00 ), line.delete(Line_L_16[1]) , Line_R_16 = line.new(bar_index + 35, 16, bar_index + 35, 17, color = #ffffff00 ), line.delete(Line_R_16[1])
Line_L_17 = line.new(bar_index + 30, 17, bar_index + 30, 18, color = #ffffff00 ), line.delete(Line_L_17[1]) , Line_R_17 = line.new(bar_index + 35, 17, bar_index + 35, 18, color = #ffffff00 ), line.delete(Line_R_17[1])
Line_L_18 = line.new(bar_index + 30, 18, bar_index + 30, 19, color = #ffffff00 ), line.delete(Line_L_18[1]) , Line_R_18 = line.new(bar_index + 35, 18, bar_index + 35, 19, color = #ffffff00 ), line.delete(Line_R_18[1])
Line_L_19 = line.new(bar_index + 30, 19, bar_index + 30, 20, color = #ffffff00 ), line.delete(Line_L_19[1]) , Line_R_19 = line.new(bar_index + 35, 19, bar_index + 35, 20, color = #ffffff00 ), line.delete(Line_R_19[1])
Line_L_20 = line.new(bar_index + 30, 20, bar_index + 30, 21, color = #ffffff00 ), line.delete(Line_L_20[1]) , Line_R_20 = line.new(bar_index + 35, 20, bar_index + 35, 21, color = #ffffff00 ), line.delete(Line_R_20[1])
Line_L_21 = line.new(bar_index + 30, 20, bar_index + 30, 21, color = #ffffff00 ), line.delete(Line_L_21[1]) , Line_R_21 = line.new(bar_index + 35, 20, bar_index + 35, 21, color = #ffffff00 ), line.delete(Line_R_21[1])


fill_1  = linefill.new(Line_L_1 ,  Line_R_1 ,   CorrelationHeatMapColor(-1.0))
fill_2  = linefill.new(Line_L_2 ,  Line_R_2 ,   CorrelationHeatMapColor(-0.9))
fill_3  = linefill.new(Line_L_3 ,  Line_R_3 ,   CorrelationHeatMapColor(-0.8))
fill_4  = linefill.new(Line_L_4 ,  Line_R_4 ,   CorrelationHeatMapColor(-0.7))
fill_5  = linefill.new(Line_L_5 ,  Line_R_5 ,   CorrelationHeatMapColor(-0.6))
fill_6  = linefill.new(Line_L_6 ,  Line_R_6 ,   CorrelationHeatMapColor(-0.5))
fill_7  = linefill.new(Line_L_7 ,  Line_R_7 ,   CorrelationHeatMapColor(-0.4))
fill_8  = linefill.new(Line_L_8 ,  Line_R_8 ,   CorrelationHeatMapColor(-0.3))
fill_9  = linefill.new(Line_L_9 ,  Line_R_9 ,   CorrelationHeatMapColor(-0.2))
fill_10 = linefill.new(Line_L_10,  Line_R_10,   CorrelationHeatMapColor(-0.1))
fill_11 = linefill.new(Line_L_11,  Line_R_11,   CorrelationHeatMapColor(0.0))
fill_12 = linefill.new(Line_L_12,  Line_R_12,   CorrelationHeatMapColor(0.1))
fill_13 = linefill.new(Line_L_13,  Line_R_13,   CorrelationHeatMapColor(0.2))
fill_14 = linefill.new(Line_L_14,  Line_R_14,   CorrelationHeatMapColor(0.3))
fill_15 = linefill.new(Line_L_15,  Line_R_15,   CorrelationHeatMapColor(0.4))
fill_16 = linefill.new(Line_L_16,  Line_R_16,   CorrelationHeatMapColor(0.5))
fill_17 = linefill.new(Line_L_17,  Line_R_17,   CorrelationHeatMapColor(0.6))
fill_18 = linefill.new(Line_L_18,  Line_R_18,   CorrelationHeatMapColor(0.7))
fill_19 = linefill.new(Line_L_19,  Line_R_19,   CorrelationHeatMapColor(0.8))
fill_20 = linefill.new(Line_L_20,  Line_R_20,   CorrelationHeatMapColor(0.9))
fill_21 = linefill.new(Line_L_21,  Line_R_21,   CorrelationHeatMapColor(1.0))

Scale_Name  = label.new(bar_index + 38, 23,text = "Correlation Heat Scale"  , textcolor = #73767e, color = #ffffff00, style = label.style_label_center ), label.delete(Scale_Name[1])
Main_Symbol = label.new(bar_index + 38 , 25,text = "Main Symbol: " + (Market != 'Custom' ? Main_Sym : str.split(Main_Sym,':').get(1))  , textcolor = #d30d5f, color = #ffffff00, style = label.style_label_center), label.delete(Main_Symbol[1])
Line_min = line.new(bar_index + 30, 1 , bar_index + 41, 1 , color = #73767e ), line.delete(Line_min[1]), Label_min = label.new(bar_index + 45, 1 ,text = "-1"  , textcolor = #73767e, color = #ffffff00, style = label.style_label_center ), label.delete(Label_min[1]) 
Line_25  = line.new(bar_index + 35, 6 , bar_index + 37, 6 , color = #73767e ), line.delete(Line_25[1] ), Label_25  = label.new(bar_index + 41, 6 ,text = "-0.5", textcolor = #73767e, color = #ffffff00, style = label.style_label_center ), label.delete(Label_25[1]) 
Line_50  = line.new(bar_index + 35, 11, bar_index + 39, 11, color = #73767e ), line.delete(Line_50[1] ), Label_50  = label.new(bar_index + 43, 11,text = "0"   , textcolor = #73767e, color = #ffffff00, style = label.style_label_center ), label.delete(Label_50[1])
Line_75  = line.new(bar_index + 35, 16, bar_index + 37, 16, color = #73767e ), line.delete(Line_75[1] ), Label_75  = label.new(bar_index + 41, 16,text = "+0.5", textcolor = #73767e, color = #ffffff00, style = label.style_label_center ), label.delete(Label_75[1])
Line_max = line.new(bar_index + 30, 21, bar_index + 41, 21, color = #73767e ), line.delete(Line_max[1]), Label_max = label.new(bar_index + 45, 21,text = "+1"  , textcolor = #73767e, color = #ffffff00, style = label.style_label_center ), label.delete(Label_max[1])

Overview

Correlation HeatMap Sessions Data Science Stats calculates Pearson correlation coefficients over a user-specified lookback period between a chosen primary symbol and up to twenty comparison instruments. The script allows users to switch between preset market baskets including Forex, stocks, and cryptocurrencies, or configure custom tickers and toggle open session tracking. Designed purely as an analytical data science dashboard, it does not generate direct buy or sell signals, nor does it provide automated trade execution rules.

Details

Published by

regalouisei on GitHub

Code credit

TFlab, as written in the script's header

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Screeners & dashboards, Sessions & time

Markets

Forex, Gold, Crypto, Stocks, Indices, Oil & commodities

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
Correlation Periodint100Corr_period
Select MarketstringCustomMarket
Show Open SessionbooltrueShow_Session
Market ModestringForexMarketMode
Main SymbolsymbolXAUUSDSym_Main
Symbol 1symbolXAGUSDSym_1_C
Symbol 2symbolXCUUSDSym_2_C
Symbol 3symbolEURUSDSym_3_C
Symbol 4symbolGBPUSDSym_4_C
Symbol 5symbolUS30Sym_5_C
Symbol 6symbolUS100Sym_6_C
Symbol 7symbolUS500Sym_7_C
Show all 25 settings
SettingTypeDefaultVariable
Symbol 8symbolUS2000Sym_8_C
Symbol 9symbolBTCUSDSym_9_C
Symbol 10symbolETHUSDSym_10_C
Symbol 11symbolDOGEUSDSym_11_C
Symbol 12symbolLTCUSDSym_12_C
Symbol 13symbolUSDCADSym_13_C
Symbol 14symbolUSDJPYSym_14_C
Symbol 15symbolUSDCHFSym_15_C
Symbol 15symbolAUDUSDSym_16_C
Symbol 15symbolNZDUSDSym_17_C
Symbol 18symbolEURGBPSym_18_C
Symbol 19symbolEURCHFSym_19_C
Symbol 20symbolNZDJPYSym_20_C
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

Donald SPX - Options Trading is an indicator designed to assist SPX index option traders by tracking session benchmarks and multi-timeframe moving average data. It calculates a 200-period weighted moving average (WMA) and requests multi-timeframe bar data from

Indicator v5 Moving averagesScreeners & dashboards Repaints
Updated 6 weeks ago · None stated GitHub repository of Donald SPX - Options Trading
46 stars

This indicator summarizes higher-timeframe candle range statistics by time of day and shows them in a table in a separate pane. It groups candles into slots for 5-minute, 15-minute, 1-hour, 4-hour, 8-hour, or 12-hour periods over a chosen lookback in days, and

Indicator v5 Screeners & dashboardsSessions & time Repaints
Updated 7 weeks ago · None stated GitHub repository of HTF Candle Stats by Time of Day
9 stars

This separate-pane indicator calculates multi-period volatility regimes by analyzing fast, medium, and slow Average True Range (ATR) metrics alongside volume integration, gap adjustments, and session weighting. It visualizes volatility states using a heat map

Indicator v6 Volatility & bandsScreeners & dashboards
Updated 12 days ago · Custom licence GitHub repository of QVS Pro - Raw Volatility Edition

BTMM HTF Bias System

by jcortes254
3 stars

BTMM HTF Bias System analyzes trend alignment and higher-timeframe directional bias using exponential moving averages across multiple timeframes, such as 1-hour, 4-hour, daily, and weekly charts. Based on Steve Mauro's Beat The Market Maker methodology, it cal

Indicator v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of BTMM HTF Bias System
3 stars

LC Signal Generator measures market breadth and alignment across three configurable symbol groups, including European stock indices, S&P 500 futures, and the VIX volatility index. It calculates daily percentage changes for each asset using daily close data. Wh

Indicator v5 Sessions & timeScreeners & dashboards Repaints
Updated 5 months ago · None stated GitHub repository of LC Signal Generator

RVol Panel

by samkdgit
1 stars

RVol Panel plots relative volume in a separate pane for intraday charts. It compares each bar’s volume with the same bar position across a configurable number of recent sessions and also tracks cumulative session volume against that baseline. Bars are colored

Indicator v5 VolumeSessions & time
Updated 11 months ago · MIT GitHub repository of RVol Panel

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