NinjaTrader chart clock indicator

NinjaTrader chart clock: show bar time with NinjaScript

A chart clock should make the timestamp being processed visible without pretending that a label converts sessions or predicts when a market will move. This page shows the indicator boundary, time-zone checks, and a small NinjaScript artifact.

Content checked on

Overlay chart clock Indicator

A single-file NinjaScript Indicator that formats Time[0] and updates one stable chart label.

using System;
using System.ComponentModel.DataAnnotations;
using System.Windows.Media;
using NinjaTrader.NinjaScript;
using NinjaTrader.NinjaScript.DrawingTools;

namespace NinjaTrader.NinjaScript.Indicators
{
    public class ChartClockIndicator : Indicator
    {
        [NinjaScriptProperty]
        [Display(Name = "Show seconds", GroupName = "Parameters", Order = 0)]
        public bool ShowSeconds { get; set; }

        [NinjaScriptProperty]
        [Range(0, 100)]
        [Display(Name = "Label offset ticks", GroupName = "Parameters", Order = 1)]
        public int LabelOffsetTicks { get; set; }

        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Name = "ChartClockIndicator";
                Calculate = Calculate.OnEachTick;
                IsOverlay = true;
                DrawOnPricePanel = true;
                ShowSeconds = false;
                LabelOffsetTicks = 4;
            }
        }

        protected override void OnBarUpdate()
        {
            string format = ShowSeconds ? "HH:mm:ss" : "HH:mm";
            string label = Time[0].ToString(format);
            double y = Close[0] + LabelOffsetTicks * TickSize;
            Draw.Text(this, "ChartClock", label, 0, y, Brushes.DodgerBlue);
        }
    }
}

Direct answer

A NinjaTrader chart clock indicator reads the bar timestamp exposed by the chart and draws a formatted label. The displayed time depends on the chart data, Trading Hours template, and platform time settings, while daylight-saving changes can alter the relationship between local, exchange, and session times. Pineify can generate a single-file Indicator with an overlay label and display parameters, but it does not change the platform clock, provide a time feed, or decide whether a bar belongs to RTH or ETH for you.

What to know first

  • Time[0] represents the current bar timestamp in the script context; it is not an independent wall clock.
  • A Trading Hours template determines session boundaries, so RTH and ETH comparisons need an explicit template and rule.
  • Daylight-saving changes can shift a local-session comparison even when the displayed exchange schedule is unchanged.
  • OnEachTick can update a realtime label more often, while historical processing still follows the available bar and tick data.
  • The generated artifact draws one stable tag and remains subject to native NinjaTrader compile and chart checks.

Supported scope

What this NinjaScript workflow can cover

  • Single-file NinjaScript chart clock Indicator
  • Bar timestamp formatting with optional seconds
  • Stable overlay drawing tag
  • Bounded chart label offset parameter
  • Trading Hours, RTH, ETH, and DST review checklist
  • External static/API diagnostic workflow

What a NinjaTrader chart clock actually displays

A chart clock label is usually a formatted view of the latest bar time. In NinjaScript, Time[0] gives the current bar timestamp in the active Bars context, and Draw.Text can place a label at a chart coordinate. Reusing a stable tag updates one object rather than creating a new object on every update.

This is different from reading a computer wall clock. A chart with delayed, historical, or sparse data can show the latest available bar time, not the current instant. State the intended behavior before choosing Calculate.OnBarClose, Calculate.OnEachTick, or Calculate.OnPriceChange.

  • Choose bar time or a wall-clock display explicitly.
  • Decide whether the label belongs on the price panel or an indicator panel.
  • Use a stable drawing tag to avoid unbounded chart objects.

Time zones, DST, RTH, and ETH are configuration questions

NinjaTrader applies a Trading Hours template to the Bars series. Regular trading hours and extended trading hours are therefore properties of the selected instrument, template, and session schedule, not labels that a generic clock can infer from a screenshot. A clock can show a timestamp, but a session filter must define its own boundary.

Daylight-saving time is a calendar rule that can change the offset between a local clock and an exchange or session clock. Compare session iterator values or documented time conversions after checking the platform and instrument settings. Do not hard-code a single offset and call it a permanent conversion.

  • Record the instrument, chart time zone, and Trading Hours template.
  • Check both sides of a DST transition when validating a session filter.
  • Keep RTH and ETH tests separate when the strategy depends on one of them.

Use overlay parameters that stay easy to audit

A useful clock exposes only parameters that affect the display, such as whether seconds are shown and how many ticks above the current close the label is drawn. The artifact below keeps those settings public and leaves time-zone selection to the platform chart and session configuration.

If a user needs a clock for a specific exchange session, add a written rule for the session start and end and test it against the selected Trading Hours template. A label alone does not open a session, block an order, or make a strategy timezone-safe.

  • Keep formatting choices separate from session eligibility rules.
  • Use a bounded integer offset rather than an unbounded chart coordinate.
  • Describe the timestamp source in the indicator name and documentation.

Compile and verify the clock on representative sessions

Pineify can generate one complete NinjaScript Indicator and run an external static/API check against the supported profile. That check can catch source and selected API errors, but it does not render a chart or confirm a local time-zone setting.

Compile the file in NinjaTrader Editor, apply it to a chart with the intended Trading Hours template, and compare labels around session opens, session closes, weekends, holidays, and DST transitions. If the indicator is used by a Strategy, validate the Strategy time filter independently.

  • Compare displayed labels with the chart data box.
  • Check historical and realtime update behavior separately.
  • Record the platform time zone and template with the test result.

Sources and verification

Last verified:

Pineify provides information and code-generation assistance, not investment advice. Generated code, static checks, backtests, simulations, and historical examples cannot predict prices or guarantee returns. Review all code and test it in NinjaTrader Editor, Strategy Analyzer, and a simulation account before considering live use.

Frequently asked questions

Build a chart clock around your session rules

Describe the timestamp source, format, panel, offset, and session assumptions. Pineify will generate one editable NinjaScript Indicator for review.