Indicator · Pine Script v6 · Own pane

Monthly Candle Closed Yesterday

by chaise-cogent

Monthly Candle Closed Yesterday is a price action and Smart Money Concepts helper indicator that plots rolling virtual monthly candles in a separate pane, treating yesterday as the end of the monthly period.

View on GitHub

Repaints

GitHub stars5on the repository
Pine versionv6current
Lines of code193
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

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

monthly-candle-started-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.2.1-table-position
// The script slides start/end dates of 1-Month candles forward,
// as if Yesterday the previous Monthly-candle was closed.

//@version=6
indicator('Monthly 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])

is_one_month_timeframe = timeframe.ismonthly 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


is_leap_year(yearNumber) =>
    if (yearNumber % 4) != 0
        false
    else if (yearNumber % 100) != 0
        true
    else if (yearNumber % 400) == 0
        true
    else
        false


get_month_len(time_stamp) =>
    year_number = year(time_stamp)
    month_number = month(time_stamp)
    int days = na
    if month_number == 1 or month_number == 3 or month_number == 5 or
      month_number == 7 or month_number == 8 or month_number == 10 or
      month_number == 12
        days := 31
    else if month_number == 4 or month_number == 6 or month_number == 9 or
      month_number == 11
        days := 30
    else // February: check for leap year
        days := is_leap_year(year_number) ? 29 : 28
    days


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)

today_day_of_month = dayofmonth(timenow)

bar_time_closing_second = time_close - 1
days_in_future_month = dayofmonth(time_close)
days_in_month = dayofmonth(bar_time_closing_second)
days_in_current_month = get_month_len(timenow)

last_month_custom_open = request.security(syminfo.tickerid, '1D',
  open[days_in_current_month]) // was 7
last_month_custom_high = request.security(syminfo.tickerid, '1D',
  ta.highest(high[1], days_in_current_month)) // was 7
last_month_custom_low = request.security(syminfo.tickerid, '1D',
  ta.lowest(low[1], days_in_current_month)) // was 7
last_month_custom_close = request.security(syminfo.tickerid, '1D', close[1])

var int previous_month_last_day = days_in_current_month -
  today_day_of_month + 1

before_last_month_custom_open = request.security(syminfo.tickerid, '1D',
  open[previous_month_last_day + days_in_month - 1]) // was 6
before_last_month_custom_high = request.security(syminfo.tickerid, '1D',
  ta.highest(high[previous_month_last_day], days_in_month)) // was 7
before_last_month_custom_low = request.security(syminfo.tickerid, '1D',
  ta.lowest(low[previous_month_last_day], days_in_month)) // was 7
before_last_month_custom_close = request.security(syminfo.tickerid, '1D',
  close[previous_month_last_day])

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

if is_one_month_timeframe
    if barstate.islast
        custom_open := last_month_custom_open
        custom_high := last_month_custom_high
        custom_low := last_month_custom_low
        custom_close := last_month_custom_close
    else
        custom_open := before_last_month_custom_open
        custom_high := before_last_month_custom_high
        custom_low := before_last_month_custom_low
        custom_close := before_last_month_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) month', 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(31 - 1), // As a workaround
      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 the plotting
// of virtual candle's levels on real candles
month_open_conditional = show_on_real and is_one_month_timeframe ? custom_open : na
month_high_conditional = show_on_real and is_one_month_timeframe ? custom_high : na
month_low_conditional = show_on_real and is_one_month_timeframe ? custom_low : na
month_close_conditional = show_on_real and is_one_month_timeframe ? custom_close : na

plot(month_open_conditional, style=plot.style_circles, color = color.new(bull_color, 0),
  linewidth = 2, force_overlay = true, title = 'virt open')
plot(month_high_conditional, style=plot.style_circles, color = color.gray,
  linewidth = 2, force_overlay = true, title = 'virt high')
plot(month_low_conditional, style=plot.style_circles, color = color.gray,
  linewidth = 2, force_overlay = true, title = 'virt low')
plot(month_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_month_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

Monthly Candle Closed Yesterday uses daily price data to dynamically calculate open, high, low, and close levels for custom monthly spans based on month lengths and leap years. Users can adjust candle colors, add day shifts, toggle display options, and configure the on-screen table alignment.

Details

Published by

chaise-cogent on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Support & resistance, SMC / ICT / price action, Candlestick patterns

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

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
46 stars

This overlay indicator draws a set of higher-timeframe candles on the price chart. The user sets the timeframe or lets it select automatically, plus candle count, size, offset, margin, and whether the candles are standard or Heikin Ashi. A table can show the a

Indicator v6 Support & resistanceCandlestick patterns Repaints
Updated 7 weeks ago · None stated GitHub repository of HTF Sweep Model with CISD Table

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]

Assistant

by eddiebelaval
7 stars

Assistant is an overlay indicator that marks candles with small or missing upper and lower wicks, using a threshold relative to body size. It plots three-candle and five-candle swing fractals as triangles two bars back, and fires alerts when a bullish or beari

Indicator v6 Candlestick patternsSupport & resistance
Updated 3 months ago · None stated GitHub repository of Assistant

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