OPEN-SOURCE SCRIPT

Multi Cycle Session Boxes

214
  • Multi Cycle Session Boxes is an overlay tool that frames freely defined time windows with a box that grows with the price inside it.
    It is built for anyone who keeps drawing the same rectangle over the same hours — a trading session, the run-up to a weekly close, a month, a season — and would rather have that window marked on every repetition without touching the chart again.
    The principle is a plain comparison: each session holds a start point and an end point, and while the current bar falls between them the box tracks the highest high and the lowest low reached since the window opened.
    There is no indicator arithmetic behind this; the entire calculation is calendar arithmetic carried out in a timezone of your choosing, which is what allows the same window to repeat on a daily, weekly, monthly or yearly cycle.
    Seven such sessions run independently of one another, each with its own cycle, its own window and its own colors.


Timezone

  • Timezone:
    the timezone all seven sessions are evaluated in; Exchange follows the timezone of the symbol itself.


SESSION 1 (present seven times, SESSION 1–SESSION 7, each instance identically structured)

  • Show boxes:
    switches the session on or off.

  • Repeat:
    the cycle the window repeats on — Daily, Weekly, Monthly or Yearly.
    It also decides which of the time fields below are evaluated.


Session 1 Time (Start:End)

  • Month:
    first and last month of the window, evaluated in Yearly only.

  • Day:
    first and last day of the window, evaluated in Weekly, Monthly and Yearly. In Weekly the day is counted from 1 for Monday to 7 for Sunday, otherwise it is the day of the month.

  • Hour:
    first and last hour of the window.

  • Minute:
    first and last minute of the window.


Session 1 Graphic

  • Fill:
    color of the box area.

  • Border:
    switches the border on or off, and sets its color and its width.


snapshot


  • A box opens on the first bar that falls inside the window and is redrawn with every bar that follows: its upper edge sits at the highest high reached since the window opened, its lower edge at the lowest low, and its right edge moves along with the last bar still inside.
    Once the window closes the box stays where it is, so what builds up on the chart is a record of what each repetition of that window actually contained.
    Every session keeps its last seventy boxes and removes the oldest as new ones open, which keeps all seven of them together within what the platform allows a single script to draw.


  • The end of a window is exclusive: a window ending at 15:30 contains the bar before it, not the 15:30 bar itself.
    A window whose end lies before its start is not discarded but crosses the boundary of its cycle instead, which is how an overnight session from 22:00 to 06:00 remains a single box.
    If start and end are set to the same point, the window is open at all times and each box then spans one full cycle before the next one begins.
    In Weekly the two day fields count only up to seven, and higher values are read as Sunday.
    In Monthly and Yearly a day the calendar month does not have is never reached: an out-of-range start skips that repetition altogether, an out-of-range end carries the box through to the end of the month.


  • One point worth knowing before the first attempt: a window can only be resolved as precisely as the chart's timeframe permits.
    A window from 12:00 to 15:30 needs bars that fall inside those hours — on a daily chart no bar begins at 12:00, so nothing is drawn there.


snapshot


  • This indicator is intended solely for market analysis and does not constitute investment advice or a guarantee of success.
    Use it at your own discretion and risk; past results are not indicative of future performance.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.