Indicator · Pine Script v5 · On the chart

Last n Swing High Low Table V2

by mikeyhu70· code credited to congacindy

Detects swing highs and swing lows from left and right bar counts and lists the most recent ones in a table on the price chart.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code262
Settings15inputs
LicenceNone statedfile: MPL-2.0
Last update6 months ago15 Apr 2026

Add It to Your TradingView Chart

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

Source Code

262 lines of Pine Script v5 from Swing/Last n Swing High Low Table V2.ps, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Last n Swing High Low Table V2.ps
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © congacindy

//@version=5
indicator("Last n Swing High Low Table 2024-V2 ", overlay = true)

// Inputs
leftBars = input.int(4, "Left Bars", minval=1)
rightBars = input.int(4, "Right Bars", minval=1)
nswing = input.int(8, "Number of Swing? Display", minval=1)
nStore= input.int(10, "Number of Swing?", minval=1)
trim_date = input.bool(true, "Trim Future Dates?")
nDatePast = input.int(45, "Number of Days in the past to display?", minval=1)
nDateFuture= input.int(90, "Number of Days in the future to display?", minval=1)
nNearFuture= input.int(21, "Number of Days in the future to change color?", minval=1)

// Get swing high and low
pivotHigh = ta.pivothigh(high, leftBars, rightBars)
pivotLow = ta.pivotlow(low, leftBars, rightBars)



txt_col_bear = input.color(color.rgb(76, 244, 169), 'Text/Frame Color', group='Dashboard')
txt_col_bull = input.color(color.rgb(228, 95, 235), 'Text/Frame Color', group='Dashboard')

txt_col = input.color(color.rgb(182, 186, 200), 'Text/Frame Color', group='Dashboard')
dash_loc_high = input.string('Top Right', 'Dashboard Location for SwingHigh', options=['Top Right', 'Bottom Right', 'Top Left', 'Mid Left', 'Mid Right'], group='Dashboard')
dash_loc_low = input.string('Bottom Right', 'Dashboard Location for SwingLow', options=['Top Right', 'Bottom Right', 'Top Left', 'Mid Left', 'Mid Right'], group='Dashboard')
dash_loc_extra = input.string('Mid Left', 'Dashboard Location for Soltice ...', options=['Top Right', 'Bottom Right', 'Top Left', 'Mid Left', 'Mid Right'], group='Dashboard')
text_size = input.string('Tiny', 'Dashboard Size', options=['Tiny', 'Small', 'Normal', 'Large'], group='Dashboard')


// Store last 10 swing high and low values
//var float[] lastHighs = array.new_float(nswing)
//var float[] lastLows = array.new_float(nswing)
//var int[] lastHighDates = array.new_int(nswing)
//var int[] lastLowDates = array.new_int(nswing)

// Declare SwingLowData as matrices
var swingLowData = matrix.new<float>(nStore, 10)

//if pivotLow
if not na(pivotLow)
    // Shift the existing rows down
    for i = nStore - 1 to 1
        for j = 0 to 9
            matrix.set(swingLowData, i, j, matrix.get(swingLowData, i - 1, j))
    
    // Add the new data to the first row
    matrix.set(swingLowData, 0, 0, low[rightBars])
    matrix.set(swingLowData, 0, 1, time[rightBars])
    matrix.set(swingLowData, 0, 2, time[rightBars] + 22.5 * 24 * 60 * 60 * 1000)
    matrix.set(swingLowData, 0, 3, time[rightBars] + 45 * 24 * 60 * 60 * 1000)
    matrix.set(swingLowData, 0, 4, time[rightBars] + 90 * 24 * 60 * 60 * 1000)
    matrix.set(swingLowData, 0, 5, time[rightBars] + 135 * 24 * 60 * 60 * 1000)
    matrix.set(swingLowData, 0, 6, time[rightBars] + 180 * 24 * 60 * 60 * 1000)
    matrix.set(swingLowData, 0, 7, time[rightBars] + 225 * 24 * 60 * 60 * 1000)
    matrix.set(swingLowData, 0, 8, time[rightBars] + 270 * 24 * 60 * 60 * 1000)
    matrix.set(swingLowData, 0, 9, time[rightBars] + 315 * 24 * 60 * 60 * 1000)

// Declare swingHighData as a matrix
var swingHighData = matrix.new<float>(nStore, 10)

// Get the current timestamp
var int currentTimestamp = time

// Initialize an empty array to store the dates
var string[] dateArrayHigh = array.new_string(0)

//if pivotHigh   
if not na (pivotHigh)
    // Shift the existing rows down
    for i = nStore - 1 to 1
        for j = 0 to 9
            matrix.set(swingHighData, i, j, matrix.get(swingHighData, i - 1, j))
    
    // Add the new data to the first row
    matrix.set(swingHighData, 0, 0, high[rightBars])
    matrix.set(swingHighData, 0, 1, time[rightBars])
    matrix.set(swingHighData, 0, 2, time[rightBars] + 22.5 * 24 * 60 * 60 * 1000)
    matrix.set(swingHighData, 0, 3, time[rightBars] + 45 * 24 * 60 * 60 * 1000)
    matrix.set(swingHighData, 0, 4, time[rightBars] + 90 * 24 * 60 * 60 * 1000)
    matrix.set(swingHighData, 0, 5, time[rightBars] + 135 * 24 * 60 * 60 * 1000)
    matrix.set(swingHighData, 0, 6, time[rightBars] + 180 * 24 * 60 * 60 * 1000)
    matrix.set(swingHighData, 0, 7, time[rightBars] + 225 * 24 * 60 * 60 * 1000)
    matrix.set(swingHighData, 0, 8, time[rightBars] + 270 * 24 * 60 * 60 * 1000)
    matrix.set(swingHighData, 0, 9, time[rightBars] + 315 * 24 * 60 * 60 * 1000)      


// Create table
//var table swingTable = table.new(position.top_right, 6, nswing+1, border_color=txt_col,border_width=1,frame_color=txt_col,frame_width=1)

//var table_position_low = dash_loc_low == 'Top Left' ? position.top_left : dash_loc_low == 'Bottom Left' ? position.bottom_left : dash_loc_low == 'Top Right' ? position.top_right : position.bottom_right
//var table_position_high = dash_loc_high == 'Top Left' ? position.top_left : dash_loc_high == 'Bottom Left' ? position.bottom_left : dash_loc_high == 'Top Right' ? position.top_right : position.bottom_right
//var table_position_extra = dash_loc_extra == 'Top Left' ? position.top_left : dash_loc_extra == 'Bottom Left' ? position.bottom_left : dash_loc_extra == 'Top Right' ? position.top_right : position.bottom_right
var table_position_low = dash_loc_low == 'Top Left' ? position.top_left : dash_loc_low == 'Bottom Left' ? position.bottom_left : dash_loc_low == 'Top Right' ? position.top_right : dash_loc_low == 'Mid Left' ? position.middle_left : dash_loc_low == 'Mid Right' ? position.middle_right : position.bottom_right
var table_position_high = dash_loc_high == 'Top Left' ? position.top_left : dash_loc_high == 'Bottom Left' ? position.bottom_left : dash_loc_high == 'Top Right' ? position.top_right : dash_loc_high == 'Mid Left' ? position.middle_left : dash_loc_high == 'Mid Right' ? position.middle_right : position.bottom_right
var table_position_extra = dash_loc_extra == 'Top Left' ? position.top_left : dash_loc_extra == 'Bottom Left' ? position.bottom_left : dash_loc_extra == 'Top Right' ? position.top_right : dash_loc_extra == 'Mid Left' ? position.middle_left : dash_loc_extra == 'Mid Right' ? position.middle_right : position.bottom_right


var table_text_size = text_size == 'Tiny' ? size.tiny : text_size == 'Small' ? size.small : text_size == 'Normal' ? size.normal : size.large


// Create a table to display the swing high data
var table swingHighTable = table.new(position = table_position_high, rows = 10, columns = nswing+1, border_color=txt_col,border_width=1,frame_color=txt_col,frame_width=1)

table.cell(swingHighTable, 0, 0, "Date", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingHighTable, 0, 1, "High", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingHighTable, 0, 2, "Date+22.5", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingHighTable, 0, 3, "High+45", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingHighTable, 0, 4, "High+90", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingHighTable, 0, 5, "High+135", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingHighTable, 0, 6, "High+180", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingHighTable, 0, 7, "High+225", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingHighTable, 0, 8, "High+270", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingHighTable, 0, 9, "High+315", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)

// Update the table with the first two rows of swingHighData
//if barstate.islast
//    if matrix.rows(swingHighData) >= nswing
//        for i = 1 to nswing
//            table.cell(swingHighTable, i, 0, str.format("{0,date,yyyy-MM-dd}",matrix.get(swingHighData, i-1, 1)), text_color=txt_col_bear, text_size=table_text_size)
//            table.cell(swingHighTable, i, 1, str.tostring(matrix.get(swingHighData, i-1, 0)), text_color=txt_col_bear, text_size=table_text_size)
//            table.cell(swingHighTable, i, 2, str.format("{0,date,yyyy-MM-dd}",matrix.get(swingHighData, i-1, 2)), text_color=txt_col_bear, text_size=table_text_size)
//            table.cell(swingHighTable, i, 3, str.format("{0,date,yyyy-MM-dd}",matrix.get(swingHighData, i-1, 3)), text_color=txt_col_bear, text_size=table_text_size)
//            table.cell(swingHighTable, i, 4, str.format("{0,date,yyyy-MM-dd}",matrix.get(swingHighData, i-1, 4)), text_color=txt_col_bear, text_size=table_text_size)
//            table.cell(swingHighTable, i, 5, str.format("{0,date,yyyy-MM-dd}",matrix.get(swingHighData, i-1, 5)), text_color=txt_col_bear, text_size=table_text_size)
//            table.cell(swingHighTable, i, 6, str.format("{0,date,yyyy-MM-dd}",matrix.get(swingHighData, i-1, 6)), text_color=txt_col_bear, text_size=table_text_size)
//            table.cell(swingHighTable, i, 7, str.format("{0,date,yyyy-MM-dd}",matrix.get(swingHighData, i-1, 7)), text_color=txt_col_bear, text_size=table_text_size)
//            table.cell(swingHighTable, i, 8, str.format("{0,date,yyyy-MM-dd}",matrix.get(swingHighData, i-1, 8)), text_color=txt_col_bear, text_size=table_text_size)
//            table.cell(swingHighTable, i, 9, str.format("{0,date,yyyy-MM-dd}",matrix.get(swingHighData, i-1, 9)), text_color=txt_col_bear, text_size=table_text_size)

if barstate.islast
    if matrix.rows(swingHighData) >= nswing
        for i = 1 to nswing
            var int timestamp = int(matrix.get(swingHighData, i-1, 1))
            var int oneMonthAgo = int(timenow - nDatePast * 24 * 60 * 60 * 1000)
            var int sixtyDaysInFuture = int(timenow + nDateFuture * 24 * 60 * 60 * 1000)
            var int fourteenDaysInFuture = int(timenow + nNearFuture * 24 * 60 * 60 * 1000)
    
            table.cell(swingHighTable, i, 0, timestamp > oneMonthAgo ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bull, text_size=table_text_size)
            table.cell(swingHighTable, i, 1, str.tostring(matrix.get(swingHighData, i-1, 0)), text_color=txt_col_bull, text_size=table_text_size)

            timestamp := int(matrix.get(swingHighData, i-1, 2))
            table.cell(swingHighTable, i, 2, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bull, text_size=table_text_size, bgcolor=(timestamp >= timenow and timestamp < fourteenDaysInFuture) and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=80) : na)

            timestamp := int(matrix.get(swingHighData, i-1, 3))
            table.cell(swingHighTable, i, 3, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bull, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=80): na)
    
            timestamp := int(matrix.get(swingHighData, i-1, 4))
            table.cell(swingHighTable, i, 4, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bull, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=80): na)
    
            timestamp := int(matrix.get(swingHighData, i-1, 5))
            table.cell(swingHighTable, i, 5, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bull, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=80) : na)
    
            timestamp := int(matrix.get(swingHighData, i-1, 6))
            table.cell(swingHighTable, i, 6, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bull, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=80) : na)
    
            timestamp := int(matrix.get(swingHighData, i-1, 7))
            table.cell(swingHighTable, i, 7, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bull, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=80) : na)
    
            timestamp := int(matrix.get(swingHighData, i-1, 8))
            table.cell(swingHighTable, i, 8, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bull, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=80): na)

            timestamp := int(matrix.get(swingHighData, i-1, 9))
            table.cell(swingHighTable, i, 9, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bull, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=80) : na)




// Create a table to display the swing high data
var table swingLowTable = table.new(position = table_position_low, rows = 10, columns = nswing+1, border_color=txt_col,border_width=1,frame_color=txt_col,frame_width=1)

table.cell(swingLowTable, 0, 0, "Date", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingLowTable, 0, 1, "Low", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingLowTable, 0, 2, "Low+22.5", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingLowTable, 0, 3, "Low+45", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingLowTable, 0, 4, "Low+90", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingLowTable, 0, 5, "Low+135", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingLowTable, 0, 6, "Low+180", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingLowTable, 0, 7, "Low+225", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingLowTable, 0, 8, "Low+270", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)
table.cell(swingLowTable, 0, 9, "Low+315", text_color=txt_col, text_size=table_text_size,bgcolor=color.gray)

if barstate.islast
    if matrix.rows(swingLowData) >= nswing
        for i = 1 to nswing
            var int timestamp = int(matrix.get(swingLowData, i-1, 1))
            var int oneMonthAgo = int(timenow - nDatePast * 24 * 60 * 60 * 1000)
            var int sixtyDaysInFuture = int(timenow + nDateFuture * 24 * 60 * 60 * 1000)
            var int fourteenDaysInFuture = int(timenow + nNearFuture * 24 * 60 * 60 * 1000)
    
            table.cell(swingLowTable, i, 0, timestamp > oneMonthAgo ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bear, text_size=table_text_size)
            table.cell(swingLowTable, i, 1, str.tostring(matrix.get(swingLowData, i-1, 0)), text_color=txt_col_bear, text_size=table_text_size)

            timestamp := int(matrix.get(swingLowData, i-1, 2))
            table.cell(swingLowTable, i, 2, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bear, text_size=table_text_size, bgcolor=(timestamp >= timenow and timestamp < fourteenDaysInFuture) and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=70) : na)

            timestamp := int(matrix.get(swingLowData, i-1, 3))
            table.cell(swingLowTable, i, 3, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bear, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=70): na)
    
            timestamp := int(matrix.get(swingLowData, i-1, 4))
            table.cell(swingLowTable, i, 4, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bear, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=70): na)
    
            timestamp := int(matrix.get(swingLowData, i-1, 5))
            table.cell(swingLowTable, i, 5, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bear, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=70) : na)
    
            timestamp := int(matrix.get(swingLowData, i-1, 6))
            table.cell(swingLowTable, i, 6, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bear, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=70) : na)
    
            timestamp := int(matrix.get(swingLowData, i-1, 7))
            table.cell(swingLowTable, i, 7, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bear, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=70) : na)
    
            timestamp := int(matrix.get(swingLowData, i-1, 8))
            table.cell(swingLowTable, i, 8, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bear, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=70): na)

            timestamp := int(matrix.get(swingLowData, i-1, 9))
            table.cell(swingLowTable, i, 9, (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? str.format("{0,date,yyyy-MM-dd}", timestamp) : "", text_color=txt_col_bear, text_size=table_text_size, bgcolor=timestamp >= timenow and timestamp < fourteenDaysInFuture and (timestamp > oneMonthAgo and (not trim_date or timestamp <= sixtyDaysInFuture)) ? color.new(color.yellow, transp=70) : na)


// Function to get the timestamp for approximate equinox and solstice dates
getTimestamp(year, month, day) =>
    timestamp(year, month, day, 0, 0)

// Current year
currentYear = year(timenow)

// Approximate dates for equinoxes and solstices
springEquinoxMonth = 3
springEquinoxDay = 20
summerSolsticeMonth = 6
summerSolsticeDay = 21
autumnEquinoxMonth = 9
autumnEquinoxDay = 23
winterSolsticeMonth = 12
winterSolsticeDay = 21

// Calculate timestamps for the current year
spring_equinox_timestamp = getTimestamp(currentYear, springEquinoxMonth, springEquinoxDay)
summer_solstice_timestamp = getTimestamp(currentYear, summerSolsticeMonth, summerSolsticeDay)
autumn_equinox_timestamp = getTimestamp(currentYear, autumnEquinoxMonth, autumnEquinoxDay)
winter_solstice_timestamp = getTimestamp(currentYear, winterSolsticeMonth, winterSolsticeDay)

// Create a table to display the turning dates
var table gann_turning_dates = table.new(position=table_position_extra , columns=2, rows=5, border_color=txt_col,border_width=1,frame_color=txt_col,frame_width=1)

// Update the table with the turning dates
if barstate.islast 
    table.cell(gann_turning_dates, 0, 0, "Turning Date", text_color=txt_col, text_size=table_text_size)
    table.cell(gann_turning_dates, 1, 0, "Date", text_color=txt_col, text_size=table_text_size)
    
    table.cell(gann_turning_dates, 0, 1, "Spring Equinox", text_color=txt_col, text_size=table_text_size)
    table.cell(gann_turning_dates, 1, 1, str.format("{0,date,yyyy-MM-dd}", spring_equinox_timestamp), text_color=txt_col, text_size=table_text_size)
    
    table.cell(gann_turning_dates, 0, 2, "Summer Solstice", text_color=txt_col, text_size=table_text_size)
    table.cell(gann_turning_dates, 1, 2, str.format("{0,date,yyyy-MM-dd}", summer_solstice_timestamp), text_color=txt_col, text_size=table_text_size)
    
    table.cell(gann_turning_dates, 0, 3, "Autumn Equinox", text_color=txt_col, text_size=table_text_size)
    table.cell(gann_turning_dates, 1, 3, str.format("{0,date,yyyy-MM-dd}", autumn_equinox_timestamp), text_color=txt_col, text_size=table_text_size)
    
    table.cell(gann_turning_dates, 0, 4, "Winter Solstice", text_color=txt_col, text_size=table_text_size)
    table.cell(gann_turning_dates, 1, 4, str.format("{0,date,yyyy-MM-dd}", winter_solstice_timestamp), text_color=txt_col, text_size=table_text_size)

Overview

Settings choose the bar counts, how many swings to store and show, an option to trim future dates, and day ranges for the past and future display. Separate text and frame colours are set for highs and lows. It is an information display with no trade signals.

Details

Published by

mikeyhu70 on GitHub

Code credit

congacindy, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

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

Settings

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

SettingTypeDefaultVariable
Left Barsint4leftBars
Right Barsint4rightBars
Number of Swing? Displayint8nswing
Number of Swing?int10nStore
Trim Future Dates?booltruetrim_date
Number of Days in the past to display?int45nDatePast
Number of Days in the future to display?int90nDateFuture
Number of Days in the future to change color?int21nNearFuture
Text/Frame Colorcolorcolor.rgb(76, 244, 169)txt_col_bear
Text/Frame Colorcolorcolor.rgb(228, 95, 235)txt_col_bull
Text/Frame Colorcolorcolor.rgb(182, 186, 200)txt_col
Dashboard Location for SwingHighstringTop Rightdash_loc_high
Show all 15 settings
SettingTypeDefaultVariable
Dashboard Location for SwingLowstringBottom Rightdash_loc_low
Dashboard Location for Soltice ...stringMid Leftdash_loc_extra
Dashboard SizestringTinytext_size
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

575 stars

This overlay indicator scans a pasted list of symbols for ICT liquidity sweep patterns using prior swing sweeps. The screening method looks back one, two, or three swings and can list long and short signals in a results table with adjustable rows, position, an

Indicator v5 SMC / ICT / price actionScreeners & dashboards
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Liquidity Sweep Pattern Scanner
330 stars

This indicator monitors multiple cryptocurrency symbols for trading signals. It calculates and plots entry prices, take profit, and stop loss levels for each symbol including BTCUSDT, ETHUSDT, BNBUSDT and others. Price crossovers trigger buy, sell or close ale

Indicator v5 Support & resistanceScreeners & dashboards
Updated 2 months ago · None stated GitHub repository of Multi Alert Long/Short [Alorse]

BZ-tracker

by Allen1212
303 stars

The BZ-tracker indicator marks ARK Invest buy and sell transactions on stock charts with labels. It plots green labels for purchases and red labels for sales, each annotated with a multiplier such as X1 or X2 to show the number of ARK ETFs trading the stock on

Indicator v4 Support & resistanceScreeners & dashboards
Updated 2 years ago · None stated GitHub repository of BZ-tracker
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

Golden Bullet Strategy

by TradersPost
228 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy

More Support & resistance scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers