Indicator · Pine Script v6 · Own pane

Weekly candle closed yesterday

by chaise-cogent

This indicator calculates and plots a virtual weekly candle structured as if the previous seven-day period finished yesterday relative to the current date.

View on GitHub

Repaints

GitHub stars5on the repository
Pine versionv6current
Lines of code159
Settings6inputs
LicenceMIT
Last update7 months ago19 Mar 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

159 lines of Pine Script v6 from src/week-candle-finished-yesterday.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

week-candle-finished-yesterday.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © chaise_cogent
//
// Script version = 4.1.3-table-position-selection
// The script slides start/end dates of 1-week candles forward,
// as if Yesterday the previous Week-candle closed.
// For example, if today is Wednesday —- then virtual weeks
// open on Saturdays and close on Tuesdays.

//@version=6
indicator('Weekly candle closed yesterday', overlay=false)

enum TablePosition
    left = 'left'
    center = 'center'
    right = 'right'

// TODO: check candles at time from 12:00am until time of your timezone -- for positive timezones
show_on_real = input.bool(false, 'Show virtual levels on real 1W candles?')
bull_color = input.color(color.new(color.green, 20), title = 'Bullish Candle')
bear_color = input.color(color.new(color.gray, 20), title = 'Bearish Candle')
draw_current_week = input.bool(true, title = 'Draw today\'s virtual week start?')
day_shift = input.int(0, 'Additional day shift', minval=0, maxval=6)
table_position = input.enum(defval = TablePosition.left, title = 'Table position', 
  options = [TablePosition.left, TablePosition.center, TablePosition.right])

day_of_week = dayofweek(timenow)
is_one_week_timeframe = timeframe.isweekly and timeframe.multiplier == 1

get_table_position (selection) =>
    switch selection
        TablePosition.left => position.bottom_left
        TablePosition.center => position.bottom_center
        TablePosition.right => position.bottom_right
        => na

get_date_human_readable(simple int days_back = 0) =>
    // Returns date in ISO-format specified days ago: '2025-12-31'
    _today_midnight = timestamp(
      year(timenow), month(timenow), dayofmonth(timenow), 0, 0, 0)
    _yesterday_midnight = _today_midnight - days_back * 24 * 3600 * 1000
    str.format_time(_yesterday_midnight, 'yyyy-MM-dd', syminfo.timezone)

last_week_custom_open = request.security(syminfo.tickerid, '1D', open[7])
last_week_custom_high = request.security(syminfo.tickerid, '1D', ta.highest(high[1], 7))
last_week_custom_low = request.security(syminfo.tickerid, '1D', ta.lowest(low[1], 7))
last_week_custom_close = request.security(syminfo.tickerid, '1D', close[1])

var int previous_weeks_daily_index = day_of_week == dayofweek.sunday ?
  1 : // Sun(1) => 1
  9 - day_of_week // Mon(2) => 7, Tue(3) => 6, Wed(4) => 5, ..., Sat(7) => 2

before_last_week_custom_open = request.security(syminfo.tickerid, '1D',
  open[previous_weeks_daily_index + 6])
before_last_week_custom_high = request.security(syminfo.tickerid, '1D',
  ta.highest(high[previous_weeks_daily_index], 7))
before_last_week_custom_low = request.security(syminfo.tickerid, '1D',
  ta.lowest(low[previous_weeks_daily_index], 7))
before_last_week_custom_close = request.security(syminfo.tickerid, '1D',
  close[previous_weeks_daily_index])

series float custom_open = na
series float custom_close = na
series float custom_high = na
series float custom_low = na

if is_one_week_timeframe
    if barstate.islast
        custom_open := last_week_custom_open
        custom_high := last_week_custom_high
        custom_low := last_week_custom_low
        custom_close := last_week_custom_close
    else
        custom_open := before_last_week_custom_open
        custom_high := before_last_week_custom_high
        custom_low := before_last_week_custom_low
        custom_close := before_last_week_custom_close
else
    custom_open := open
    custom_high := high
    custom_low := low
    custom_close := close

candle_color = custom_open <= custom_close ? bull_color : bear_color

// Main plotting of the candles
plotcandle(custom_open, custom_high, custom_low, custom_close,
  color = candle_color, wickcolor = candle_color, bordercolor = candle_color,
  title = 'OHLC', force_overlay = false)

// Table with the last candle's dates
if barstate.islast
    table_settings = table.new(get_table_position(table_position),
      columns = 2, rows = 3,
      border_color = color.white, bgcolor = color.new(color.black, 20),
      border_width = 1, force_overlay = false)

    table.clear(table_settings, start_column = 0, start_row = 0,
      end_column = 1, end_row = 2)
    table.cell(table_settings, 0, 0, 'Last (virtual) week', text_size = size.tiny,
      text_color = color.white, text_formatting = text.format_bold)
    table.merge_cells(table_settings, start_column = 0, start_row = 0,
      end_column = 1, end_row = 0)
    table.cell(table_settings, 0, 1, 'Started', text_formatting = text.format_bold,
      text_size = size.small, text_color = color.white)
    table.cell(table_settings, 1, 1, 'Last day', text_formatting = text.format_bold,
      text_size = size.small, text_color = color.white)
    table.cell(table_settings, 0, 2, get_date_human_readable(7),
      text_size = size.small, text_color = color.white)
    table.cell(table_settings, 1, 2, get_date_human_readable(1),
      text_size = size.small, text_color = color.white)

// Next lines are only supplementing 
// Plotting virtual candle's levels on real candles
week_open_conditional = show_on_real and is_one_week_timeframe ? custom_open : na
week_high_conditional = show_on_real and is_one_week_timeframe ? custom_high : na
week_low_conditional = show_on_real and is_one_week_timeframe ? custom_low : na
week_close_conditional = show_on_real and is_one_week_timeframe ? custom_close : na

plot(week_open_conditional, style=plot.style_circles, color = color.new(bull_color, 0),
  linewidth = 2, force_overlay = true, title = 'virt open')
plot(week_high_conditional, style=plot.style_circles, color = color.gray,
  linewidth = 2, force_overlay = true, title = 'virt high')
plot(week_low_conditional, style=plot.style_circles, color = color.gray,
  linewidth = 2, force_overlay = true, title = 'virt low')
plot(week_close_conditional, style=plot.style_circles, color = color.new(bear_color, 0),
  linewidth = 2, force_overlay = true, title = 'virt close')

// Plotting today's candle with the current price
draw_pseudo_candle(p_open, p_high, p_low, p_close, p_offset, color) =>
    candle_left_x = bar_index + p_offset
    candle_right_x = bar_index + p_offset + 1
    body_bottom = math.min(p_open, p_close)
    body_top = math.max(p_open, p_close)
    is_green = p_open < p_close
    bottom_wick_x = is_green ? candle_left_x : candle_right_x
    top_wick_x = is_green ? candle_right_x : candle_left_x

    box.new(candle_left_x, body_top, candle_right_x, body_bottom,
      border_color=color, bgcolor=color)
    line.new(bottom_wick_x, p_low, bottom_wick_x, body_bottom,
      color=color, width=1, xloc = xloc.bar_index)
    line.new(top_wick_x, p_high, top_wick_x, body_top,
      color=color, width=1, xloc = xloc.bar_index)


today_open = request.security(syminfo.tickerid, '1D', open)
today_high = request.security(syminfo.tickerid, '1D', high)
today_low = request.security(syminfo.tickerid, '1D', low)
today_close = close
today_color = today_open < today_close ?
  color.new(color.lime, 40) : color.new(color.red, 30)

if barstate.islast and is_one_week_timeframe
    draw_pseudo_candle(today_open, today_high, today_low, today_close,
      1, today_color)

plot(draw_current_week and barstate.islast ? close : na, title = 'Current price',
  color=color.gray, linewidth=1, trackprice=true, style = plot.style_stepline)

Overview

Weekly candle closed yesterday queries daily price data to derive rolling weekly open, high, low, and close levels. Designed for ICT and smart money concepts that analyze rolling weekly periods, the script draws in a separate pane and displays an informational table. Settings allow adjustments for additional day shifts, table positioning, and candle colors.

Details

Published by

chaise-cogent on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Candlestick patterns, SMC / ICT / price action

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

Settings

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

SettingTypeDefaultVariable
Show virtual levels on real 1W candles?boolfalseshow_on_real
Bullish Candlecolorcolor.new(color.green, 20)bull_color
Bearish Candlecolorcolor.new(color.gray, 20)bear_color
Draw today's virtual week start?booltruedraw_current_week
Additional day shiftint0day_shift
Table positionenumTablePosition.lefttable_position
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

The indicator plots ICT displacement candles on the price chart and can switch to retracement scanning. Displacement requires a move larger than a set share of the 14-bar average high-low range, lasting at least a chosen number of bars, with optional close, pr

Indicator v6 SMC / ICT / price actionCandlestick patterns
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Displacement Candles Indicator

This Pine Script indicator identifies liquidity sweeps and confirms signals using a close-back candle pattern directly on the price chart. It tracks recent swing highs and lows over a customizable lookback period. A bullish signal forms when a prior bar sweeps

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · MPL-2.0 GitHub repository of Liquidity Sweep + Close-Back Confirmation

Confluence Suite

by TamaraKGreen
46 stars

The Confluence Suite indicator draws multiple trading signals and tools directly on the price chart. It generates entry and exit signals based on selected modes and filters, with an AI signal classifier rating quality from 1-4. Additional features include smar

Indicator v5 TrendSMC / ICT / price action
Updated 7 weeks ago · None stated GitHub repository of Confluence Suite

Fractal Reclaim Strength

by selimgrsoy0-commits
12 stars

The indicator tracks four-bar fractal sweep and reclaim setups on chart timeframes of 15 minutes and above. It calculates Reclaim Strength based on where C2 closes relative to C1's range and plots level lines for the swept C1 extreme and C2 extreme. An on-scre

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 7 weeks ago · None stated GitHub repository of Fractal Reclaim Strength

ICT HTF Candles (fadi)

by dbruce1990
12 stars

ICT HTF Candles displays higher timeframe candle structures directly on the price chart using customized boxes and lines. It tracks up to six user-defined higher timeframes, plotting historical body, wick, and imbalance zones alongside optional price level tra

Indicator v6 SMC / ICT / price actionCandlestick patterns
Updated 1 year ago · None stated GitHub repository of ICT HTF Candles (fadi)

This overlay indicator detects tweezer tops and bottoms and kangaroo-tail pin bars, then draws supply and demand zones from those patterns. It scores each zone, decays freshness, merges overlapping zones, and can invalidate a zone after a close-through or afte

Indicator v6 Candlestick patternsSupport & resistance
Updated yesterday · MIT GitHub repository of Tweezer & Kangaroo Zones [WavesUnchained]

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