PA Swings [TTA]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Â© TTA

//@version=5
indicator("PA Swings [TTA]", 
  overlay = true, max_lines_count = 500, max_labels_count = 500)



_data    = input.string(defval = "SH/SL", title = "Swings to Show", options = ["SH", "SL", "SH/SL"])
_hideDev   = input.bool(defval = true, title = "Hide Far Away Lines?")
_devDelete = input.float(defval = 15, title = "Hide Far Away Lines After Price Deviates (%)", minval = 0) / 100
_hide_r    = input.bool(defval = false, title = "Delete Inactive Lines?")
_hide_days = input.int(defval = 3, title = "Delete Inactive Lines After => Bars")
_avgGainInput = input.int(defval = 10, title = "Number of Bars Included For Avg. Gain/Loss Following Retest")
_lineOnly = input.bool(defval = false, title = "Show Lines Only")
_logR = input.bool(defval = true, title = "Use Log Returns")
_showLab = input.bool(defval = false, title = "Show Labels on Chart")
_sVolBool = input.bool(defval = false, title = "Show High Volume Swings Only")
_textSize = input.string(defval = "Normal", title = "Text Size", 
     options = ["Tiny", "Small", "Normal", "Large", "Huge", "Auto"])
_hidePanel = input.bool(defval = false, title = "Hide Color Identity Panel")

_finalSize = switch _textSize
    
    "Normal" => size.normal
    "Tiny"   => size.tiny
    "Small" => size.small
    "Large" => size.large
    "Huge" => size.huge
    "Auto" => size.auto
 
//                                                                  ------{{Swing High}}------

var string [] _rankTrack = array.new_string()

_sHighN = close[3] > open[3] and close[2] > open[2] and close[2] > close[3] and high[2] > high[3] and close[1] < open[1]  and high < high[2] and high[1] < high[2] and close < open 

var float [] _sHighVol = array.new_float()
var bool _sHighNx = na
if _sVolBool == true 
    array.push(_sHighVol, volume)
    _sHighNx := array.size(_sHighVol) > 5 ? _sHighN and array.percentrank(_sHighVol, array.size(_sHighVol) - 3) > 80 : na
    
    if array.size(_sHighVol) > 300
        array.shift(_sHighVol)

_sHighLasts = switch _sVolBool
    
    true => _sHighNx
    false => _sHighN



_sLowN = close[3] < open[3] and close[2] < open[2] and close[2] < close[3] and high[2] < high[3] and close[1] > open[1]  and high > high[2] and high[1] > high[2] and close > open 

var bool _sLowNx = na
if _sVolBool == true 
    _sLowNx := array.size(_sHighVol) > 5 ? _sLowN and array.percentrank(_sHighVol, array.size(_sHighVol) - 3) > 80 : na
_sLowLasts = switch _sVolBool
    
    true  => _sLowNx
    false => _sLowN



var int _session = 0
var bool _sesC = false
if barstate.isfirst
    _session := math.round(time)
else 
    if session.isfirstbar_regular and _sesC == false
        _session := math.round(time) - _session
        _sesC := true

var label [] _arrayLabel = array.new_label()    , var label [] _r      = array.new_label()
var float [] _avgRetest  = array.new_float()    , var float [] _avgMax = array.new_float()
var line [] _sLow = array.new_line()            , var label [] _arrayLabelLow =  array.new_label()
var int [] _barCountLow = array.new_int()       , var float [] _avgMin = array.new_float()
var float [] _arrayHoldLow =  array.new_float() , var float [] _arrayHoldLow2 = array.new_float()
var line  [] _arrayLineLow = array.new_line()   , var line [] _arrayLineLow2 = array.new_line()
var float [] _min = array.new_float()           , var int [] _line2CountLow = array.new_int()
var int [] _avgRetestBarLow = array.new_int()   , var float [] _avgRetestLow = array.new_float()
var label [] _rLow = array.new_label()          , var float [] _sLowVolTrack = array.new_float()
var string [] _rankTrackH = array.new_string()  , var float [] _sHighVolTrack = array.new_float()
var line [] _sHigh = array.new_line()           , var int [] _barCount = array.new_int()



if last_bar_index - bar_index <= 7000
    
    if _data != "SL"

        var string _pRank = ""

        if _sHighLasts
            if _sVolBool == true
                array.push(_sHighVolTrack, volume)
                _pRank := array.size(_sHighVol) > 5 ? "\nVol. Rank: " + str.tostring(array.percentrank(_sHighVol, array.size(_sHighVol) - 3), format.percent) : ""
                array.push(_rankTrackH, _pRank)
                array.push(_sHighVolTrack, volume)

        
        
        var float [] _arrayHold =  array.new_float()
        var float [] _arrayHold2 = array.new_float()
        var line  [] _arrayLine = array.new_line()
        var line [] _arrayLine2 = array.new_line()


        if _sHighLasts
            array.push(_sHigh, line.new(time[2], high[2], time,  high[2], color = #c8e6c9, xloc = xloc.bar_time))
            array.push(_arrayLabel, label.new(time, line.get_y1(array.get(_sHigh, array.size(_sHigh) - 1)),
             "(" + str.tostring(0, "#") + ")" + "\n" + 
             str.tostring((close / line.get_y1(array.get(_sHigh, array.size(_sHigh) - 1)) - 1) * 100, format.percent) + _pRank, color = na, 
             textcolor = _showLab == true ? 
              #c8e6c9 : color.new(color.black, 100), xloc = xloc.bar_time, size = size.small))
            array.push(_barCount, bar_index)

        var float [] _max = array.new_float()
        var int [] _line2Count = array.new_int()
        var int [] _avgRetestBar = array.new_int()


        if array.size(_sHigh) > 0 
            for i = 0 to array.size(_sHigh) - 1
                if high[1] > line.get_y1(array.get(_sHigh, i)) and array.includes(_arrayHold, line.get_y1(array.get(_sHigh, i))) == false
                    array.push(_arrayHold, line.get_y1(array.get(_sHigh, i)))
                    
                    
                    if _sVolBool == true
                        if array.size(_rankTrackH) == array.size(_sHigh)
                            label.set_text(array.get(_arrayLabel, i), "Impulse Up\n" + "Vol. Rank: " + array.get(_rankTrackH, i))
                    
                    else
                        
                        label.set_text(array.get(_arrayLabel, i), "Impulse Up")

                    
                    if _hide_r == true
                        line.set_color(array.get(_sHigh, i), na)
    
        
        if array.size(_sHigh) > 0 
        

        
            for i = 0 to array.size(_sHigh) - 1
                if array.includes(_arrayHold, line.get_y1(array.get(_sHigh, i))) == false
                    line.set_x2(array.get(_sHigh, i), time)
                    line.set_color(array.get(_sHigh, i), color.from_gradient(time, line.get_x1(array.get(_sHigh, i)), line.get_x1(array.get(_sHigh, i)) + 
                     _session * 100, color.lime, #c8e6c9))
                    
                    if _sVolBool == false
                        
                        label.set_text(array.get(_arrayLabel, i), "(" + str.tostring(bar_index - array.get(_barCount, i), "#") + ")" + "\n"
                     + str.tostring((close / line.get_y1(array.get(_sHigh, i)) - 1) * 100, format.percent))
                    
                    else
                        if array.size(_rankTrackH) > 0
                            label.set_text(array.get(_arrayLabel, i), "(" + str.tostring(bar_index - array.get(_barCount, i), "#") + ")" + "\n"
                              + str.tostring((close / line.get_y1(array.get(_sHigh, i)) - 1) * 100, format.percent) + array.get(_rankTrackH, i))
                    
                        
                    
                    if _showLab == true
                        label.set_textcolor(array.get(_arrayLabel, i),  color.from_gradient(time, line.get_x1(array.get(_sHigh, i)), line.get_x1(array.get(_sHigh, i)) + 
                     _session * 100, color.lime,  #c8e6c9))
                    label.set_x(array.get(_arrayLabel, i), time - line.get_x1(array.get(_sHigh, i)) >= _session * 15 ?
                     math.round(
                     math.avg(
                     line.get_x1(
                     array.get(_sHigh, i)), line.get_x2(array.get(_sHigh, i)))) : time)
                    
    
                
                
                
                else
        
                    
        
                
                    if array.includes(_arrayHold2, line.get_y1(array.get(_sHigh, i))) == false
                        array.push(_arrayLine2, line.new(time[1], line.get_y1(array.get(_sHigh, i)), time, line.get_y1(array.get(_sHigh, i)), color = na,
                         style = line.style_dashed, xloc = xloc.bar_time))
                        array.push(_arrayHold2, line.get_y1(array.get(_sHigh, i)))
                        array.push(_line2Count, 0)
                        array.push(_max, high)
                        
                if _hideDev == true    
                    if math.abs(close / line.get_y1(array.get(_sHigh, i)) - 1) >= _devDelete
                        line.set_x2(array.get(_sHigh, i), line.get_x1(array.get(_sHigh, i)))
                        label.set_x(array.get(_arrayLabel, i),  line.get_x1(array.get(_sHigh, i)))                   
                        label.set_textcolor(array.get(_arrayLabel, i),  na)                  
                        
                    
            if array.size(_max) > 0 
                for i = 0 to array.size(_max) - 1
                    array.set(_max, i, math.max(array.get(_max, i), high))
                    
            if array.size(_arrayLine2) > 0 
        
    
        
                for i = 0 to array.size(_arrayLine2) - 1
                
                    if array.get(_line2Count, i) == 0
                        
                        if low > line.get_y1(array.get(_arrayLine2, i))
                        
                            line.set_x2(array.get(_arrayLine2, i), time)
                            line.set_color(array.get(_arrayLine2, i), color.from_gradient(time, line.get_x1(array.get(_arrayLine2, i)), 
                             line.get_x1(array.get(_arrayLine2, i)) + (_session * 100), color.yellow, #fff9c4))
                            array.set(_line2Count, i, 1)
        
                    if array.get(_line2Count, i) == 1
                        
                        line.set_x2(array.get(_arrayLine2, i), time)
                        line.set_color(array.get(_arrayLine2, i), color.from_gradient(time, line.get_x1(array.get(_arrayLine2, i)), 
                         line.get_x1(array.get(_arrayLine2, i)) + (_session * 100), color.yellow, #fff9c4))
                        
                        if low <= line.get_y1(array.get(_arrayLine2, i)) and high >= line.get_y1(array.get(_arrayLine2, i))
                            
                            array.set(_line2Count, i, 2)
                            array.push(_r, label.new(bar_index, line.get_y1(array.get(_arrayLine2, i)), "(Retest)" ,  xloc = xloc.bar_index, 
                             size = size.small, color = color.new(color.black, 100), style = label.style_label_up, 
                             textcolor =  _showLab == true ? color.from_gradient(time, line.get_x1(array.get(_arrayLine2, i)), 
                             line.get_x1(array.get(_arrayLine2, i)) + _session * 100, color.yellow, #fff9c4) : color.new(color.black, 100)))
                            
                            array.push(_avgMax, _logR == true ? math.log(array.get(_max, i) / line.get_y1(array.get(_arrayLine2, i))) : 
                             array.get(_max, i) / line.get_y1(array.get(_arrayLine2, i)) - 1)
                            array.push(_avgRetestBar, bar_index)
                            
                        if array.get(_line2Count, i) == 2
                            
                            if time - line.get_x2(array.get(_arrayLine2, i)) >= _session * _hide_days
                            
                                line.delete(array.remove(_arrayLine2, i))
                                array.remove(_line2Count, i)
                                
                                
                                
                                break
                                
                                // if i < array.size(_arrayLine2)
                                    
                                    
                                //     continue
               
                    if _hideDev == true 
                        
                        if math.abs(close / line.get_y1(array.get(_arrayLine2, i)) - 1) >= _devDelete
                        
                        
                            line.set_x2(array.get(_arrayLine2, i), line.get_x1(array.get(_arrayLine2, i)))
                            label.set_x(array.get(_arrayLabel, i),  line.get_x1(array.get(_sHigh, i)))                   
                            label.set_textcolor(array.get(_arrayLabel, i),  na)                  
                            
                    
               
                if _hide_r ==true 
                    if array.size(_r) > 0 
                        for n = 0 to array.size(_r) - 1
                            if bar_index - label.get_x(array.get(_r, n)) >= _hide_days
                                label.set_textcolor(array.get(_r, n), na)
    
                if _hideDev ==true 
                    if array.size(_r) > 0 
                        for n = 0 to array.size(_r) - 1
                            if  math.abs(close / label.get_y(array.get(_r, n)) - 1) >= _devDelete
                                label.set_textcolor(array.get(_r, n), na)
                        
                        
                            else 
                        
                        
                                if _showLab == true
                                    label.set_textcolor(array.get(_r, n), color.yellow)
    
                if array.size(_r) > 0 
                    for i = 0 to array.size(_r) - 1
                        if bar_index - array.get(_avgRetestBar, i) == _avgGainInput
                            array.push(_avgRetest, _logR == true ? math.log(close / label.get_y(array.get(_r, i)))
                             : close / label.get_y(array.get(_r, i)) - 1)
            
            
            
            
            
            
            
            
            
            
            
        
//                                                                  ------{{Swing Low}}------
     
     
    if _data != "SH" 
        

        var string _pRank = ""
        

        if _sLowLasts
            if _sVolBool == true
                array.push(_sLowVolTrack, volume)
                _pRank := array.size(_sHighVol) > 5 ? "\nVol. Rank: " + str.tostring(array.percentrank(_sHighVol, array.size(_sHighVol) - 3), format.percent) : ""
                array.push(_rankTrack, _pRank)

            array.push(_sLow, line.new(time[2], low[2], time,  low[2], color = #b2ebf2, xloc = xloc.bar_time))
            array.push(_arrayLabelLow, label.new(time, line.get_y1(array.get(_sLow, array.size(_sLow) - 1)),
             "(" + str.tostring(0, "#") + ")" + "\n" + 
             str.tostring((close / line.get_y1(array.get(_sLow, array.size(_sLow) - 1)) - 1) * 100, format.percent) + _pRank, color = na, 
             textcolor = _showLab == true ? 
              #c8e6c9 : color.new(color.black,100), xloc = xloc.bar_time, size = size.small))
            array.push(_barCountLow, bar_index)


        
        if array.size(_sLow) > 0 
            for i = 0 to array.size(_sLow) - 1
                if low[1] < line.get_y1(array.get(_sLow, i)) and array.includes(_arrayHoldLow, line.get_y1(array.get(_sLow, i))) == false
                    array.push(_arrayHoldLow, line.get_y1(array.get(_sLow, i)))
                    
                    if _sVolBool == true
                        
                        label.set_text(array.get(_arrayLabelLow, i), "Impulse Dn\n" + "Vol. Rank: " + array.get(_rankTrack, i))
                    
                    else
                        
                        label.set_text(array.get(_arrayLabelLow, i), "Impulse Dn")

                    
                    if _hide_r == true
                        line.set_color(array.get(_sLow, i), na)
    
        if array.size(_sLow) > 0 
    
            for i = 0 to array.size(_sLow) - 1
                if array.includes(_arrayHoldLow, line.get_y1(array.get(_sLow, i))) == false
                    line.set_x2(array.get(_sLow, i), time)
                    line.set_color(array.get(_sLow, i), color.from_gradient(time, line.get_x1(array.get(_sLow, i)), line.get_x1(array.get(_sLow, i)) + 
                     _session * 100, color.aqua, #80deea))
                    
                    if _sVolBool == false
                    
                        label.set_text(array.get(_arrayLabelLow, i), "(" + str.tostring(bar_index - array.get(_barCountLow, i), "#") + ")" + "\n" + 
                     str.tostring((close / line.get_y1(array.get(_sLow, i)) - 1) * 100, format.percent))
                    
                   
                    else
                        
                   
                        if array.size(_rankTrack) > 0
                            label.set_text(array.get(_arrayLabelLow, i), "(" + str.tostring(bar_index - array.get(_barCountLow, i), "#") + ")" + "\n" + 
                                 str.tostring((close / line.get_y1(array.get(_sLow, i)) - 1) * 100, format.percent) + array.get(_rankTrack, i))
                    
                        
                    
                    if _showLab == true
                        label.set_textcolor(array.get(_arrayLabelLow, i),  color.from_gradient(time, line.get_x1(array.get(_sLow, i)), line.get_x1(array.get(_sLow, i)) + 
                     _session * 100, color.aqua,  #80deea))
                    label.set_x(array.get(_arrayLabelLow, i), time - line.get_x1(array.get(_sLow, i)) >= _session * 15 ?
                     math.round(
                     math.avg(
                     line.get_x1(
                     array.get(_sLow, i)), line.get_x2(array.get(_sLow, i)))) : time)
                    
    
                
                else
        
                    
        
                
                    if array.includes(_arrayHoldLow2, line.get_y1(array.get(_sLow, i))) == false
                        
                        array.push(_arrayLineLow2, line.new(time[1], line.get_y1(array.get(_sLow, i)), time, line.get_y1(array.get(_sLow, i)), 
                         color = na, style = line.style_dashed, xloc = xloc.bar_time))
                        array.push(_arrayHoldLow2, line.get_y1(array.get(_sLow, i)))
                        array.push(_line2CountLow, 0)
                        array.push(_min, low)
                        
                if _hideDev == true    
                    
                    if math.abs(close / line.get_y1(array.get(_sLow, i)) - 1) >= _devDelete
                    
                        line.set_x2(array.get(_sLow, i), line.get_x1(array.get(_sLow, i)))
                        label.set_x(array.get(_arrayLabelLow, i),  line.get_x1(array.get(_sLow, i)))                   
                        if _showLab == true
                            label.set_textcolor(array.get(_arrayLabelLow, i),  na)                  
                        
                    
                        
                    
            if array.size(_min) > 0 
                for i = 0 to array.size(_min) - 1
                    array.set(_min, i, math.min(array.get(_min, i), low))
                    
            if array.size(_arrayLineLow2) > 0 
        
    
        
                for i = 0 to array.size(_arrayLineLow2) - 1
                
    
                    if array.get(_line2CountLow, i) == 0
                        if high < line.get_y1(array.get(_arrayLineLow2, i))
                            line.set_x2(array.get(_arrayLineLow2, i), time)
                            line.set_color(array.get(_arrayLineLow2, i), color.from_gradient(time, line.get_x1(array.get(_arrayLineLow2, i)), 
                             line.get_x1(array.get(_arrayLineLow2, i)) + (_session * 100), color.purple, #ce93d8))
                            array.set(_line2CountLow, i, 1)
        
                    if array.get(_line2CountLow, i) == 1
                        
                        line.set_x2(array.get(_arrayLineLow2, i), time)
                        line.set_color(array.get(_arrayLineLow2, i), color.from_gradient(time, line.get_x1(array.get(_arrayLineLow2, i)), 
                         line.get_x1(array.get(_arrayLineLow2, i)) + (_session * 100), color.purple, #ce93d8))
                        
                        if high >= line.get_y1(array.get(_arrayLineLow2, i)) and low <= line.get_y1(array.get(_arrayLineLow2, i))
                            array.set(_line2CountLow, i, 2)
                            array.push(_rLow, label.new(bar_index, line.get_y1(array.get(_arrayLineLow2, i)), "(Retest)" ,  xloc = xloc.bar_index, 
                             size = size.small, color = color.new(color.black, 100), style = label.style_label_down, 
                             textcolor = _showLab == true ?  color.from_gradient(time, line.get_x1(array.get(_arrayLineLow2, i)), 
                        
                             line.get_x1(array.get(_arrayLineLow2, i)) + _session * 100, color.purple, #ce93d8) : color.new(color.black, 100)))
                            array.push(_avgMin,  _logR == true ? math.log(array.get(_min, i) / line.get_y1(array.get(_arrayLineLow2, i))) : 
                             array.get(_min, i) / line.get_y1(array.get(_arrayLineLow2, i)) - 1)
                            array.push(_avgRetestBarLow, bar_index)
                            
                        if array.get(_line2CountLow, i) == 2
                            
                            if time - line.get_x2(array.get(_arrayLineLow2, i)) >= _session * _hide_days
                            
                            
                                line.delete(array.remove(_arrayLineLow2, i))
                                array.remove(_line2CountLow, i)
                                
                                
                                
                                break
                                // if i < array.size(_arrayLineLow2)
                                    
                                    
                                //     continue
               
                    if _hideDev == true 
                        if math.abs(close / line.get_y1(array.get(_arrayLineLow2, i)) - 1) >= _devDelete
                            line.set_x2(array.get(_arrayLineLow2, i), line.get_x1(array.get(_arrayLineLow2, i)))
                            label.set_x(array.get(_arrayLabelLow, i),  line.get_x1(array.get(_sLow, i))) 
                            if _showLab == true
                                label.set_textcolor(array.get(_arrayLabelLow, i),  na)                  
    
               
                if _hide_r ==true 
                    if array.size(_rLow) > 0 
                        for n = 0 to array.size(_rLow) - 1
                            if bar_index - label.get_x(array.get(_rLow, n)) >= _hide_days
                                label.set_textcolor(array.get(_rLow, n), na)
    
                if _hideDev ==true 
                    if array.size(_rLow) > 0 
                        for n = 0 to array.size(_rLow) - 1
                            if  math.abs(close / label.get_y(array.get(_rLow, n)) - 1) >= _devDelete
                                label.set_textcolor(array.get(_rLow, n), na)
                            else 
                                if _showLab == true
                                    label.set_textcolor(array.get(_rLow, n), color.purple)
    
                if array.size(_rLow) > 0 
                    for i = 0 to array.size(_rLow) - 1
                        if bar_index - array.get(_avgRetestBarLow, i) == _avgGainInput
                            array.push(_avgRetestLow, _logR == true ? math.log(close / label.get_y(array.get(_rLow, i))) :
                             close / label.get_y(array.get(_rLow, i)) - 1)
            
        



if barstate.islast

        
    

    var table statisticsTable = table.new(position.bottom_right, 5, 5, frame_color = color.white, border_color = color.white, frame_width = 1, border_width = 1)
    if array.size(_avgMax) > 0
        
        table.cell(statisticsTable, 0, 0, "Avg. Percent Gain Following Impulse Up,\nUntil Level is Retested\n" + str.tostring(array.avg(_avgMax) * 100, format.percent),
         text_color = color.white,  bgcolor = color.new(#26c6da, 90), text_size = _finalSize)
        
        table.cell(statisticsTable, 0, 1, "Avg. " + str.tostring(_avgGainInput, "#") + "-Bar Percent Gain/Loss Following Retest (Swing High)\n" + 
         str.tostring(array.avg(_avgRetest) * 100, format.percent),
         text_color = color.white, bgcolor = color.new(#4dd0e1, 90), text_size = _finalSize)
    
    if array.size(_avgMin) > 0
        
        table.cell(statisticsTable, 0, 2, "Avg. Percent Loss Following Impulse Down,\nUntil Level is Retested\n" + str.tostring(array.avg(_avgMin) * 100, format.percent),
         text_color = color.white,  bgcolor = color.new(#80deea, 90), text_size = _finalSize)
       
        table.cell(statisticsTable, 0, 3, "Avg. " + str.tostring(_avgGainInput, "#") + "-Bar Percent Gain/Loss Following Retest (Swing Low)\n" +
         str.tostring(array.avg(_avgRetestLow) * 100, format.percent),
         text_color = color.white, bgcolor = color.new(#0097a7, 90), text_size = _finalSize)
         
    if _lineOnly == true
        for i = 0 to array.size(_arrayLabel) - 1
            label.set_textcolor(array.get(_arrayLabel, i), na)
        for i = 0 to array.size(_arrayLabelLow) - 1
            label.set_textcolor(array.get(_arrayLabelLow, i), na)
        for i = 0 to array.size(_r) - 1
            label.set_textcolor(array.get(_r, i), na)
        for i = 0 to array.size(_rLow) - 1
            label.set_textcolor(array.get(_rLow, i), na)
         
         
    var table _colorCoord = table.new(position.top_right, 20, 20)
         
    if _showLab == false and _lineOnly == false 
        
        if _hidePanel == false
            
            table.cell(_colorCoord, 0, 0, text = "Color Identity (SH)", text_color = color.white)
            table.cell(_colorCoord, 0, 1, text = '"⎯⎯⎯⎯" = Swing High (Recent)',bgcolor = na, text_color = color.lime, text_halign = text.align_left)
            table.cell(_colorCoord, 0, 2, text = '"⎯⎯⎯⎯" = Swing High (Older)',bgcolor = na, text_color = #c8e6c9, text_halign = text.align_left)
            table.cell(_colorCoord, 0, 3, text = '"------" = Violated Swing High / Retest Level (Recent)',bgcolor = na, text_color = color.yellow, text_halign = text.align_left)
            table.cell(_colorCoord, 0, 4, text = '"------" = Violated Swing High / Retest Level (Older)',bgcolor = na, text_color =  #fff9c4, text_halign = text.align_left)    
        
            table.cell(_colorCoord, 0, 5, text = "\nColor Identity (SL)", text_color = color.white)
            table.cell(_colorCoord, 0, 6, text = '"⎯⎯⎯⎯" = Swing Low (Recent)',bgcolor = na, text_color = color.aqua, text_halign = text.align_left)
            table.cell(_colorCoord, 0, 7, text = '"⎯⎯⎯⎯" = Swing Low (Older)',bgcolor = na, text_color = #80deea, text_halign = text.align_left)
            table.cell(_colorCoord, 0, 8, text = '"------" = Violated Swing Low / Retest Level (Recent)',bgcolor = na, text_color = color.purple, text_halign = text.align_left)
            table.cell(_colorCoord, 0, 9, text = '"------" = Violated Swing Low / Retest Level (Older)',bgcolor = na, text_color = #ce93d8, text_halign = text.align_left)
        