MultiCharts PowerLanguage Session Functions: OpenD, HighS, LowS, Time_S and Overnight Behaviour Explained

Man gives money to a woman. day of salary in the modern office with screens with graphs on them

If you have ever written a MultiCharts strategy that seemed correct on paper but produced wrong signals in live trading, the culprit is often one of PowerLanguage’s session and daily functions. Specifically, functions like OpenD, HighD, LowD, OpenS, HighS, LowS, and Time_S each have precise, sometimes counterintuitive behaviour when your chart spans overnight or premarket sessions. Understanding exactly how these functions resolve their values is fundamental to writing reliable strategies in MultiCharts PowerLanguage.

This guide covers the full set of session-related functions in PowerLanguage as of MultiCharts 15, explains the overnight and premarket behaviour that trips up even experienced developers, and shows you how to choose the right function for your session template.


The Two Function Families: D-Series vs S-Series

PowerLanguage gives you two distinct families of functions for retrieving open, high, low, and close reference prices. They look similar but behave very differently depending on your chart’s session template.

The D-Series: OpenD, HighD, LowD, CloseD

OpenD, CloseD, and their siblings operate on Date, not the Symbol Session. The open price returned is the first trade of a new bar on a new calendar day. If your chart uses a 24/7 session, the open price is the first trade after midnight, not the first trade of Regular Trading Hours (RTH) or Extended Trading Hours (ETH).

This is the most common source of confusion. If you are charting US equity futures on a 24-hour session and call OpenD(0), you will not receive the RTH open at 09:30 but rather the premarket open from when data first arrives, as early as 04:00 in some configurations.

The parameter passed to D-series functions is a day offset, not a bar offset. OpenD(0) returns today’s open; OpenD(1) returns the previous day’s open. If your chart is not 24/7 but runs from 09:30 to 16:00, the open price will correctly be the first trade of the bar representing a new calendar date. So for strict RTH-only charts, D-series functions behave as expected. For anything with overnight or extended data, they do not.

HighD and LowD reset at midnight regardless of session template. This means if you want to track the high and low of the current session on 1-minute charts where the session crosses over a calendar day (common with futures that open at 17:00 and close at 16:00 the next day), HighD and LowD will reset at midnight and split your session data across two calendar dates.

The S-Series: OpenS, HighS, LowS, CloseS

The S-series functions were introduced in MultiCharts 9.1 specifically to address the limitations of the D-series for non-RTH workflows. OpenS, HighS, LowS, and CloseS return the open, high, low, and close prices relative to the Symbol Session defined in your chart’s session template, not the calendar day.

This makes them the correct choice when you are working with overnight sessions, futures that span midnight, or any instrument where your logical trading day does not align with a calendar date boundary. If your ES futures chart runs a session from 17:00 to 16:00 the following day, HighS(0) returns the highest price within that defined session window, not just from midnight onwards.

For RTH session templates, OpenD, CloseD, HighD, and LowD will work correctly. For 24-hour or custom session templates that span midnight, you need either the S-series functions or a manual session-tracking approach using SessionStartTime and SessionEndTime.

In MultiCharts .NET, note that HighS and LowS are available as prebuilt functions in PowerLanguage (EasyLanguage mode) but are not directly available in MultiCharts .NET, where you must implement equivalent logic manually.


Time Functions: Time, Time_S, and SecondsFromDateTime

PowerLanguage provides several time-related functions that are frequently misunderstood, particularly Time_S and SecondsFromDateTime.

Time vs Time_S

Time returns the time of the current bar with minute precision. For example, a bar closing at 15:45 PM returns a value of 1545.

Time_S returns the same bar time but with seconds precision. A bar closing at 15:45:00 PM returns a value of 154500. Use Time for minute-resolution analysis and Time_S when your strategy works on tick or second-level data where the minute-only value is insufficient.

Both Time and Time_S refer to bar time, not computer time. If you need the current wall-clock time rather than the bar’s timestamp, use CurrentTime (minute precision) or CurrentTime_S (second precision) instead. This distinction matters when writing logic that should trigger at a specific real-world time rather than on a specific bar.

The range of values returned by both functions is limited by your MaxBarsBack setting. If your strategy is looking back further than MaxBarsBack allows, time-based conditions on historical bars will not resolve correctly.

SecondsFromDateTime

SecondsFromDateTime converts a DateTime value into a total seconds count from a reference point. It is most useful when calculating durations between two DateTime values or when comparing timestamps across data series. If you are working with multi-data charts where Data1 and Data2 operate on different resolutions or sessions, converting both timestamps to seconds allows direct arithmetic comparison without worrying about the HHMM or HHMMSS format quirks.


OpenD Behaviour in Overnight and Premarket Sessions

The overnight and premarket behaviour of OpenD(0) deserves its own section because it affects a significant number of strategy patterns.

The root issue: OpenD(0) identifies the open as the first bar of a new calendar date. If your data feed delivers premarket or overnight data, the first bar of that calendar date arrives well before the RTH open bell. On US equities with an IQFeed connection, for example, OpenD(0) returns the premarket open at 04:00 rather than the RTH open at 09:30, and CloseD(1) returns the post-market close at 17:00 rather than the official close at 16:00.

This breaks any strategy that compares today’s open to yesterday’s close to measure gaps, or uses the daily open as a reference level for intraday entries.

There are three practical solutions:

  1. Use a strict RTH session template. If you configure your chart to use a session template that exactly matches RTH hours with no pre or post-market data, OpenD(0) will return the correct RTH open. This is the simplest fix but means you lose pre and post-market context on the chart.
  2. Switch to the S-series. Use OpenS(0) with a session template that explicitly defines your trading window. The S-series respects your session definition rather than the calendar day, so it returns the open of whichever session you have configured.
  3. Use a second data series on a daily resolution. The recommended approach for more complex cases is to load daily resolution data on a subchart (Data2) and reference those values from the script applied on the intraday chart. This gives you clean daily OHLC values anchored to the exchange’s official session definition, regardless of what intraday data is loaded on the primary chart.

Session Timing Functions: SessionStartTime, SessionEndTime, and BarsSinceStartSession

When neither the D-series nor S-series fully captures your required logic, PowerLanguage provides lower-level session timing functions for manual session tracking.

SessionStartTime(SessionNumber, DataStream) returns the start time of the specified session for the given data series. SessionEndTime returns the corresponding end time. These are particularly useful when you need to detect session boundaries explicitly in your code rather than relying on built-in price functions.

When StartTime is not less than EndTime, PowerLanguage treats the session as an overnight session spanning midnight. In this case, you must handle the time check with an or condition rather than a simple range comparison, checking whether the current time is either greater than StartTime or less than EndTime.

BarsSinceStartSession returns the number of bars elapsed since the current session began. This is a clean way to identify the opening bar of a session without hardcoding a time value, which is especially useful for instruments that observe daylight saving changes or have sessions that shift across data providers.


Common Strategy Issues Caused by Misusing Session Functions

Getting session functions wrong produces specific, reproducible failure modes.

Strategy fires on wrong open level: Almost always caused by using OpenD(0) on a 24-hour chart with premarket data. Switch to OpenS(0) or use a daily Data2 series.

HighD or LowD resets mid-session: This happens on instruments with sessions that cross midnight. The D-functions reset at midnight by design. Use HighS and LowS instead, configured against a session template that defines your full session window.

Time-based conditions trigger at wrong moment: Check whether you are using Time or CurrentTime. Time is bar time; CurrentTime is real-world time. For conditions that should evaluate based on when the bar closes, use Time. For conditions that should evaluate against the wall clock regardless of bar formation, use CurrentTime or CurrentTime_S.

Backtesting looks different from live: A common cause is that MaxBarsBack is too low for your look-back requirements. When bars are unavailable, time and session functions silently return incorrect values on historical bars. Raise MaxBarsBack or set it to 999999 during development, then optimise once the logic is validated.


Running MultiCharts Strategies Around the Clock with TradingFXVPS

Even a perfectly written PowerLanguage strategy underperforms if the environment running it is unreliable. Session functions that depend on precise timing, like CurrentTime_S triggers or BarsSinceStartSession conditions evaluated at session open, require consistent data delivery and stable execution. A strategy running on a home machine is exposed to internet drops, power interruptions, and system latency at exactly the moments when the market is most active.

TradingFXVPS is purpose-built for running MultiCharts, MetaTrader, and NinjaTrader strategies around the clock without interruption. Servers are colocated in eight financial-grade data centres across London, New York, Chicago, Singapore, Tokyo, Hong Kong, Frankfurt, and Amsterdam, positioned directly alongside major broker and data feed infrastructure. You can explore the MultiCharts-optimised VPS plans to find the configuration that suits your strategy load.

Hardware specifications are matched to algorithmic trading workloads: 4.3+ GHz CPUs, NVMe SSD storage, and 10 Gbps network connectivity. Session boundaries matter to your strategy logic, and they also matter to your infrastructure. A connection that drops at 17:00 when your overnight session opens is not a minor inconvenience. See the available VPS plans to compare locations and tiers.

For traders migrating from a local setup, the MultiCharts setup guide walks through the full process of moving your workspace to a VPS environment. And if you ever run into platform-level issues, TradingFXVPS support is available around the clock from staff who understand trading platform behaviour, not just generic server administration.


Frequently Asked Questions

What does OpenD(0) return in MultiCharts PowerLanguage?

OpenD(0) operates on Date, not the Symbol Session. It returns the open price of the first bar of the current calendar date. On a 24-hour or premarket-inclusive chart, this is the very first tick after midnight, not the RTH open. If you need the open of your defined trading session rather than the calendar day, use OpenS(0) with an appropriate session template instead.

What is the difference between OpenD and OpenS in MultiCharts?

OpenD returns prices based on calendar date boundaries and resets at midnight regardless of session template. OpenS returns prices based on your chart’s defined Symbol Session. For instruments with sessions that span midnight or include premarket data, OpenS will give you the correct session open while OpenD will return the first price after midnight, which may be premarket data.

How does Time_S differ from Time in PowerLanguage?

Time returns the bar’s timestamp with minute precision in HHMM format, while Time_S returns the same timestamp with second precision in HHMMSS format. Use Time for strategies on minute or higher timeframes, and Time_S for tick or second-resolution charts where the extra precision is needed to correctly identify bars or trigger conditions.

Why does HighD reset mid-session on my futures chart?

HighD resets at midnight on the calendar date boundary, not at your session boundary. If your session crosses midnight, HighD will split the session high across two calendar days, giving you an incorrect value for the full session range. Use HighS instead, which tracks the high relative to your defined session template and handles overnight sessions correctly.

What is the correct way to detect an overnight session in PowerLanguage?

When StartTime is not less than EndTime, PowerLanguage recognises this as an overnight session. Your time filter logic must check whether the current time is either greater than StartTime or less than EndTime, using an or condition rather than a simple range comparison. A standard intraday range check will fail to correctly identify bars that fall in the hours before midnight as part of the same overnight session.

How do I get the correct RTH open on an equities chart that includes premarket data?

The most reliable approach is to load daily resolution data on Data2 and reference it from your intraday script on Data1. MultiCharts scripts use only the data available on the chart they are applied to, so adding a daily data series gives your script access to clean exchange-level daily OHLC values anchored to official session definitions. Alternatively, configure a strict RTH session template so that OpenD(0) on Data1 resolves correctly by excluding premarket bars from the chart entirely.


Close the CTA
5

WAIT! DON’T LEAVE

YOUR TRADES BEHIND...

Try our Lightning-Fast VPS for 7 days

and Experience Pro-level Trading Speed and Reliability for just $3.99