> ## Documentation Index
> Fetch the complete documentation index at: https://gocharting.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Market data and time across languages

> How Lipi maps to MQL4, MQL5, NinjaScript, Pine Script and thinkScript for market data and time: price and volume of the bar, average prices of the bar, open interest, orderflow of the bar, instrument details, chart timeframe and more, with the differences that matter when converting.

Prices, volume, orderflow, the instrument, the timeframe, sessions and time. Each row maps one concept from Lipi to the other languages; the word in a cell is the relation, explained in the [language map overview](https://gocharting.com/docs/scripting/reference/language-map.md#relations).

| Concept | Lipi | MQL4 | MQL5 | NinjaScript | Pine Script | thinkScript |
| - | - | - | - | - | - | - |
| [Price and volume of the bar](#data-ohlcv) | `open`, `high`, `low`, `close`, `volume` | Caveat | Caveat | Caveat | Exact | Caveat |
| [Average prices of the bar](#data-derived-price) | `hl2`, `hlc3`, `ohlc4`, `hlcc4` | Caveat | Caveat | Caveat | Exact | Caveat |
| [Open interest](#data-open-interest) | `oi` | Absent | Differs | Caveat | Caveat | Caveat |
| [Orderflow of the bar](#data-orderflow) | `orderflow.buyvolume`, `orderflow.sellvolume`, `orderflow.delta`, `orderflow.trades`, `orderflow.cvd` | Absent | Composite | Caveat | Composite | Caveat |
| [Instrument details](#data-instrument) | `syminfo.ticker`, `syminfo.exchange`, `syminfo.currency`, `syminfo.mintick`, `syminfo.asset_type` | Composite | Composite | Composite | Differs | Caveat |
| [Chart timeframe](#data-timeframe) | `interval.interval`, `interval.isintraday`, `interval.isdaily`, `interval.multiplier`, `interval.in_seconds` | Caveat | Caveat | Composite | Caveat | Caveat |
| [Data from another symbol or timeframe](#data-other-symbol) | None | Not in Lipi | Not in Lipi | Not in Lipi | Not in Lipi | Not in Lipi |
| [Chart type](#data-chart-type) | `chart.is_standard`, `chart.is_heikinashi`, `chart.is_renko` | Caveat | Caveat | Caveat | Exact | Absent |
| [Time of the bar](#time-bar-time) | `time`, `time_close` | Caveat | Differs | Differs | Caveat | Caveat |
| [Current time](#time-now) | `timenow` | Differs | Differs | Caveat | Exact | Absent |
| [Parts of a date](#time-parts) | `year`, `month`, `dayofmonth`, `dayofweek`, `hour`, `minute`, `second` | Differs | Differs | Caveat | Caveat | Differs |
| [Build a time value](#time-make-timestamp) | `timestamp` | Caveat | Caveat | Caveat | Caveat | Absent |
| [Format a time as text](#time-format) | `str.format_time` | Caveat | Caveat | Caveat | Differs | Absent |
| [Trading session](#time-session) | `session.isfirst`, `session.date`, `time_sessionday` | Composite | Composite | Composite | Caveat | Composite |

Each section below gives the Lipi construct first, then the construct in each language, with a note wherever behaviour differs. The language name links to the documentation the row was checked against.

## Price and volume of the bar

The open, high, low, close and volume of the current bar.

In Lipi: `open`, `high`, `low`, `close`, `volume`.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/predefined) | `Open[], High[], Low[], Close[], Volume[]` | Equivalent, with a caveat | Series arrays with shift 0 as current bar; Volume is tick volume, a count of price changes, not traded contracts. |
| [MQL5](https://www.mql5.com/en/docs/event_handlers/oncalculate) | open\[], high\[], low\[], close\[], tick\_volume\[], volume\[] (OnCalculate); iOpen, iHigh, iLow, iClose, iVolume | Equivalent, with a caveat | Prices arrive as arrays whose direction you set; volume is split into tick\_volume\[] and real volume\[], so choose which one Lipi's volume maps to. History indexing: Array direction follows ArraySetAsSeries; iClose(shift) always counts 0 as the current bar. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/priceseries.htm) | `Open[0], High[0], Low[0], Close[0], Volume[0]` | Equivalent, with a caveat | Series objects read with \[barsAgo]; bare Close is the series. With Calculate.OnBarClose, \[0] is the bar that just closed. Bar timing: In OnBarClose mode the script never sees a forming bar; Lipi runs on every live update by default. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/) | `open, high, low, close, volume` | Exact | |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Fundamentals/close) | `open, high, low, close, volume` | Equivalent, with a caveat | close(), high() and the rest also take a symbol, aggregation period and price type; Lipi's variables read the chart's own symbol and timeframe only. |

## Average prices of the bar

Common averages of a bar's prices, such as the mid-point of high and low.

In Lipi: `hl2`, `hlc3`, `ohlc4`, `hlcc4`. hlcc4 is (high + low + 2 x close) / 4.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/constants/indicatorconstants/prices#ENUM_APPLIED_PRICE) | `PRICE_MEDIAN, PRICE_TYPICAL, PRICE_WEIGHTED` | Equivalent, with a caveat | Constants that select hl2, hlc3 and (H+L+C+C)/4 for indicator functions, not variables; no ohlc4 constant, so compute values yourself. |
| [MQL5](https://www.mql5.com/en/docs/constants/indicatorconstants/prices) | PRICE\_MEDIAN; PRICE\_TYPICAL; PRICE\_WEIGHTED (ENUM\_APPLIED\_PRICE) | Equivalent, with a caveat | Median is hl2, typical is hlc3, weighted is hlcc4; there is no OHLC/4 constant, so compute it from the arrays. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/priceseries.htm) | `Median[0], Typical[0], Weighted[0]` | Equivalent, with a caveat | Median = hl2, Typical = hlc3, Weighted = (H+L+C+C)/4 = hlcc4. There is no built-in ohlc4 series. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/) | `hl2, hlc3, ohlc4, hlcc4` | Exact | |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Fundamentals/ohlc4) | `hl2, hlc3, ohlc4` | Equivalent, with a caveat | hlcc4 is not documented; compute (high + low + 2 \* close) / 4 yourself. |

## Open interest

The number of open contracts, for instruments that report it.

In Lipi: `oi`. `oi` is 0, not na, on a bar that carries no open interest.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/constants/environment_state/marketinfoconstants) | | Not in MQL4 | No open-interest value; symbol properties and series expose only tick volume. |
| [MQL5](https://www.mql5.com/en/docs/marketinformation/symbolinfodouble) | `SYMBOL_SESSION_INTEREST` | Looks alike, behaves differently | A symbol property for the trading session, not a value stored per bar; MqlTick has no open-interest field. History indexing: No per-bar history of it: only the current value is read. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/marketdataeventargs.htm) | `MarketDataType.OpenInterest in OnMarketData()` | Equivalent, with a caveat | Arrives as a live market-data event (supported by some providers), not a per-bar series; Lipi oi is a bar series that reads 0 when missing. History indexing: No bar history of open interest is exposed; store your own values per bar. |
| [Pine Script](https://www.tradingview.com/script/Rpmobpw5-Request/) | open-interest ticker "\<id>\_OI", requested as another symbol (for example with request.security) | Equivalent, with a caveat | Pine has no built-in open-interest variable; OI comes from a ticker with \_OI appended. Lipi's oi is 0, not na, when absent. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Fundamentals/open-interest) | `open_interest()` | Equivalent, with a caveat | A function with optional symbol, period and price-type arguments; the value reported where no open interest exists is not stated. |

## Orderflow of the bar

Buy and sell volume, delta and trade counts of the bar.

In Lipi: `orderflow.buyvolume`, `orderflow.sellvolume`, `orderflow.delta`, `orderflow.trades`, `orderflow.cvd`. Ten integer series exist only where the chart has footprint data, else na. orderflow\.cvd restarts at session.isfirst.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/series) | | Not in MQL4 | Only tick volume per bar (Volume, iVolume); no buy/sell split, delta or trade count. |
| [MQL5](https://www.mql5.com/en/docs/constants/structures/mqltick) | CopyTicks; MqlTick flags TICK\_FLAG\_BUY and TICK\_FLAG\_SELL; volume\_real | Built from several Lipi constructs | No per-bar buy/sell volume or delta: copy ticks, split them by TICK\_FLAG\_BUY and TICK\_FLAG\_SELL, and sum per bar yourself. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/order_flow_volumetric_bars2.htm) | `VolumetricBarsType.Volumes[CurrentBar] (BarDelta, TotalBuyingVolume, TotalSellingVolume, Trades, CumulativeDelta)` | Equivalent, with a caveat | Needs a Volumetric bars series. Index with the absolute CurrentBar, not barsAgo. CumulativeDelta resets at the session break. History indexing: Volumes\[i] takes an absolute bar index, the reverse of Close\[barsAgo]. |
| [Pine Script](https://www.tradingview.com/pine-script-docs/concepts/other-timeframes-and-data/#requestfootprint) | `request.footprint(), footprint.buy_volume(), footprint.sell_volume(), footprint.delta(), footprint.total_volume()` | Built from several Lipi constructs | Call request.footprint(ticks\_per\_row), then footprint.buy\_volume(), sell\_volume(), delta(), total\_volume(). No trade-count series or cvd function exists; accumulate delta with ta.cum. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Fundamentals/tick-count) | `tick_count` | Equivalent, with a caveat | Only the trade count of an intraday bar exists; buy/sell volume, delta and cumulative delta have no documented function. |

## Instrument details

The symbol, exchange, currency, tick size and type of the instrument on the chart.

In Lipi: `syminfo.ticker`, `syminfo.exchange`, `syminfo.currency`, `syminfo.mintick`, `syminfo.asset_type`. syminfo has 14 names; no tickerid, pointvalue or type. ticker is exchange:segment:symbol; mintick = tick size / maximum tick precision.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/constants/environment_state/marketinfoconstants) | Symbol(), MarketInfo(symbol, MODE\_TICKSIZE / MODE\_DIGITS / MODE\_POINT), SymbolInfoString, AccountCurrency() | Built from several Lipi constructs | Name from Symbol, tick size and digits from MarketInfo, base and profit currency from SymbolInfoString; no exchange or asset-type property is listed. |
| [MQL5](https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants) | SymbolInfoString(SYMBOL\_EXCHANGE, SYMBOL\_CURRENCY\_PROFIT); SymbolInfoDouble(SYMBOL\_TRADE\_TICK\_SIZE); SYMBOL\_TRADE\_CALC\_MODE | Built from several Lipi constructs | Each field is a property read by identifier: exchange and currencies as strings, tick size as double, instrument kind via the calc-mode enum. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/masterinstrument.htm) | `Instrument.MasterInstrument.Name, Instrument.Exchange, MasterInstrument.Currency, MasterInstrument.TickSize, MasterInstrument.InstrumentType` | Built from several Lipi constructs | Fields sit on Instrument and MasterInstrument and are readable only from State.DataLoaded; InstrumentType is NinjaTrader's own enum. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/) | `syminfo.ticker, syminfo.prefix, syminfo.currency, syminfo.mintick, syminfo.type` | Looks alike, behaves differently | Pine mintick is the price tick, Lipi's is minmove/pricescale. Pine ticker omits the exchange. Exchange maps to syminfo.prefix, asset\_type to syminfo.type. Numbers and types: Pine syminfo.mintick equals the smallest price step; in Lipi the step is syminfo.minmove and mintick is minmove divided by pricescale. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Others/GetSymbol) | `GetSymbol(), TickSize(), TickValue(), GetSymbolPart()` | Equivalent, with a caveat | Symbol, tick size and dollar tick value only; futures symbols come back with an exchange namespace such as /ES:XCME; no currency, exchange or type accessors. |

## Chart timeframe

The timeframe of the chart and tests for its kind, such as intraday or daily.

In Lipi: `interval.interval`, `interval.isintraday`, `interval.isdaily`, `interval.multiplier`, `interval.in_seconds`. There is no `timeframe` namespace; use interval.\*. in\_seconds counts a month as 2628003 seconds and is na for tick and range intervals.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/constants/chartconstants/enum_timeframes) | `Period(), PeriodSeconds(), PERIOD_* constants` | Equivalent, with a caveat | Period() returns minutes as an int (PERIOD\_H1 is 60); there are no isintraday or isdaily flags, so compare against the constants. |
| [MQL5](https://www.mql5.com/en/docs/check/period) | Period(); \_Period; ENUM\_TIMEFRAMES | Equivalent, with a caveat | Returns an ENUM\_TIMEFRAMES constant such as PERIOD\_M5, not text; tests like intraday or daily are your own comparisons. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/barsperiod.htm) | `BarsPeriod.BarsPeriodType, BarsPeriod.Value` | Built from several Lipi constructs | Period type (Tick, Minute, Day, Renko and others) plus Value; no isintraday or isdaily flags, so derive them. Read only from State.DataLoaded. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/) | `timeframe.period, timeframe.isintraday, timeframe.isdaily, timeframe.multiplier, timeframe.in_seconds()` | Equivalent, with a caveat | The namespace is timeframe, not interval. timeframe.period is a Pine-format string (bare minutes, S, D, W, M suffixes), unlike Lipi's unit-suffixed strings. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Others/GetAggregationPeriod) | `GetAggregationPeriod()` | Equivalent, with a caveat | One number whose unit depends on chart type; compare it with AggregationPeriod constants instead of isintraday-style flags. Numbers and types: Unit is milliseconds, ticks or price range by chart type, and 1 Day compares equal to 24 hours. |

## Data from another symbol or timeframe

Reading a series of a different instrument or a different timeframe from the one on the chart.

Lipi has no construct for this. Lipi reads only the chart's own symbol and timeframe.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/series) | iClose(symbol, timeframe, shift), iOpen, iHigh, iLow, iVolume, iTime, iCustom, CopyRates | No Lipi equivalent | Series functions take a symbol and timeframe plus a shift counted in that series' own bars; Lipi reads only the chart's symbol and timeframe. Other timeframes: Shift counts bars of the requested timeframe; shift 0 is that series' current, still-forming bar. |
| [MQL5](https://www.mql5.com/en/docs/series/iclose) | iClose(symbol, timeframe, shift); CopyRates; CopyBuffer | No Lipi equivalent | Any symbol and timeframe can be read directly; Lipi sees only the chart's own series. Other timeframes: shift counts bars of the requested timeframe, not chart bars; align them yourself with iTime or iBarShift. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/adddataseries.htm) | `AddDataSeries() with Closes[i][0]` | No Lipi equivalent | Add extra Bars in State.Configure with hard-coded arguments, read Closes\[i]\[0], and filter OnBarUpdate by BarsInProgress. Lipi reads only the chart series. |
| [Pine Script](https://www.tradingview.com/pine-script-docs/concepts/other-timeframes-and-data/#requestsecurity) | `request.security(), request.security_lower_tf()` | No Lipi equivalent | Lipi reads only the chart's own symbol and timeframe; nothing replaces request.security. Other timeframes: request.security takes gaps and lookahead (both off by default) and shows developing higher-timeframe values on realtime bars. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/tutorials/Advanced/Chapter-11---Referencing-Secondary-Aggregation) | `close("IBM", period = AggregationPeriod.WEEK)` | No Lipi equivalent | Every price function takes symbol and period arguments; Lipi reads only the chart's own symbol and timeframe, so such scripts cannot be converted. Other timeframes: A secondary period cannot be shorter than the chart's, and one variable cannot mix two different secondary periods. |

## Chart type

Whether the chart shows standard candles or another bar type.

In Lipi: `chart.is_standard`, `chart.is_heikinashi`, `chart.is_renko`. chart.\* has nine names: bg\_color, fg\_color, is\_standard, is\_heikinashi, is\_kagi, is\_linebreak, is\_pnf, is\_range, is\_renko.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/constants/chartconstants/enum_chart_property#CHART_MODE) | `ChartGetInteger(0, CHART_MODE)` | Equivalent, with a caveat | Reports candlesticks, bars or line display mode only; Heikin Ashi and Renko are not values of this property. |
| [MQL5](https://www.mql5.com/en/docs/constants/chartconstants/enum_chart_property) | `ChartGetInteger with CHART_MODE` | Equivalent, with a caveat | CHART\_MODE reports bars, candles or line only; the docs list no Heikin Ashi or Renko mode. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/barsperiod.htm) | `BarsPeriod.BarsPeriodType == BarsPeriodType.HeikenAshi / Renko` | Equivalent, with a caveat | No is\_standard flag; compare BarsPeriodType (for example HeikenAshi 9, Renko 11) yourself. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/) | `chart.is_standard, chart.is_heikinashi, chart.is_renko` | Exact | |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/SetChartType) | | Not in thinkScript | SetChartType only sets the chart type; no function tests which type the chart currently shows. |

## Time of the bar

The opening and closing time of the current bar.

In Lipi: `time`, `time_close`. `time` and `time_close` are int milliseconds; time\_close is the open time plus one interval.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/predefined) | `Time[shift], iTime(symbol, timeframe, shift)` | Equivalent, with a caveat | Gives bar open time in seconds since 1970 (Lipi uses milliseconds); close time is open plus PeriodSeconds(). Numbers and types: Seconds, not milliseconds. |
| [MQL5](https://www.mql5.com/en/docs/series/itime) | time\[] (OnCalculate); iTime(symbol, timeframe, shift) | Looks alike, behaves differently | Gives only the bar's open time, as datetime in seconds since 1970; no close-time function is documented, and Lipi time is milliseconds. Numbers and types: Seconds in MQL5, milliseconds in Lipi: scale by 1000. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/how_bars_are_built.htm) | `Time[0]` | Looks alike, behaves differently | Time\[0] is the bar's closing time stamp, so it matches Lipi time\_close, not time (open). It returns a DateTime, not epoch milliseconds. Bar timing: A minute bar stamped 9:31:00 holds data from 9:30:00 to 9:30:59; Lipi time would read 9:30. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/) | `time, time_close` | Equivalent, with a caveat | Lipi time\_close is always open plus one interval; Pine yields na on the open realtime bar of tick and price-based charts. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Date---Time/GetTime) | `GetTime()` | Equivalent, with a caveat | Returns epoch milliseconds but the reference does not say whether that is the bar's open or close; there is no separate close-time value. |

## Current time

The present time while the script runs.

In Lipi: `timenow`. `timenow` is the wall clock on every run, not the bar's time. `time.now` does not exist.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/dateandtime/timelocal) | `TimeCurrent(), TimeLocal(), TimeGMT()` | Looks alike, behaves differently | TimeCurrent is the server time of the last quote, TimeLocal the computer clock; all in seconds, and equal to each other in the tester. Bar timing: Server time of last tick, not wall-clock now; frozen between ticks. |
| [MQL5](https://www.mql5.com/en/docs/dateandtime/timecurrent) | TimeCurrent(); TimeLocal() | Looks alike, behaves differently | TimeCurrent is the last quote's server time, not the machine clock; TimeLocal is the computer's clock and equals TimeCurrent in the tester. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/c_method_functions_reference.htm) | `DateTime.Now` | Equivalent, with a caveat | Returns a local-time DateTime, not epoch milliseconds; it is evaluated on each call, not per bar. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/#var_timenow) | `timenow` | Exact | |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Date---Time) | | Not in thinkScript | The Date and Time list has no function for the present wall-clock time. |

## Parts of a date

The year, month, day, weekday, hour, minute and second of a time.

In Lipi: `year`, `month`, `dayofmonth`, `dayofweek`, `hour`, `minute`, `second`. dayofweek runs 1 (Sunday) to 7 (Saturday). hour(time, zone) needs an IANA zone name; an offset such as "UTC-5" gives 0.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/dateandtime) | TimeYear(t), TimeMonth(t), TimeDay(t), TimeDayOfWeek(t), TimeHour(t), TimeMinute(t), TimeSeconds(t) | Looks alike, behaves differently | Bare Hour() and DayOfWeek() read the last server time, not the bar; use TimeHour(Time\[i]). Weekday is zero-based, Sunday 0 (Lipi 1 to 7). Numbers and types: Weekday 0 to 6 from Sunday, versus Lipi 1 to 7. Bar timing: No-argument forms follow server time, not the bar being calculated. |
| [MQL5](https://www.mql5.com/en/docs/constants/structures/mqldatetime) | TimeToStruct; MqlDateTime fields year, mon, day, hour, min, sec, day\_of\_week, day\_of\_year | Looks alike, behaves differently | Weekday 0 is Sunday and day\_of\_year starts at 0, unlike Lipi's Sunday 1; all parts come from one filled struct. |
| [NinjaScript](https://learn.microsoft.com/en-us/dotnet/api/system.datetime) | Time\[0].Year, .Month, .Day, .DayOfWeek, .Hour, .Minute, .Second | Equivalent, with a caveat | Properties of the bar's DateTime. DayOfWeek is a .NET enum, not Lipi's 1 to 7 number. |
| [Pine Script](https://www.tradingview.com/pine-script-docs/concepts/time/#calendar-based-variables) | year, month, dayofmonth, dayofweek, hour, minute, second | Equivalent, with a caveat | Pine's variables use the exchange time zone, and the matching functions take an optional timezone argument. Check which zone Lipi's variables read. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Date---Time/GetDayOfWeek) | `GetYear(), GetMonth(), GetDay(), GetDayOfMonth(yyyymmdd), GetDayOfWeek(yyyymmdd)` | Looks alike, behaves differently | Weekday is Monday=1 to Sunday=7 (Lipi Sunday=1); GetDay is day of year; year and month use CST; no hour, minute or second. |

## Build a time value

Making a time value from a date and time of day.

In Lipi: `timestamp`. A date string without a zone is read as UTC; a string that matches no layout gives na. The numeric form uses the exchange zone.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/dateandtime/structtotime) | `StructToTime(MqlDateTime), StringToTime(string)` | Equivalent, with a caveat | Fill an MqlDateTime struct or parse a date string; results are seconds since 1970 and no timezone argument exists. Numbers and types: Seconds, not milliseconds. |
| [MQL5](https://www.mql5.com/en/docs/dateandtime/structtotime) | StructToTime; StringToTime; D'yyyy.mm.dd hh:mi:ss' literal | Equivalent, with a caveat | Fill an MqlDateTime and call StructToTime, or use a D'...' literal; the result counts seconds since 1970, not milliseconds. |
| [NinjaScript](https://learn.microsoft.com/en-us/dotnet/api/system.datetime) | new DateTime(year, month, day, hour, minute, second) | Equivalent, with a caveat | The constructor returns a DateTime, not an epoch-millisecond int; Lipi timestamp reads the parts in exchange time. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/#fun_timestamp) | `timestamp()` | Equivalent, with a caveat | Pine timestamp(dateString) is const and valid as an input.time default; Lipi's is na at compile, so Add to chart rejects it. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Date---Time) | | Not in thinkScript | No builder from date parts: dates are plain YYYYMMDD integers and times of day HHMM integers. |

## Format a time as text

Turning a time value into readable text.

In Lipi: `str.format_time`. str.format\_time reads seconds, not milliseconds: pass int(time / 1000). The layout is the reference date 2006-01-02 15:04:05.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/convert/timetostring) | `TimeToString(value, mode)` | Equivalent, with a caveat | Only flag modes giving yyyy.mm.dd, hh:mi and hh:mi:ss; there is no custom pattern or timezone argument. |
| [MQL5](https://www.mql5.com/en/docs/convert/timetostring) | `TimeToString` | Equivalent, with a caveat | Output has a fixed yyyy.mm.dd hh:mi:ss layout chosen by flags; there is no free-form pattern, and the input is in seconds. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/iseries_time.htm) | `DateTime.ToString()` | Equivalent, with a caveat | ToString() with an optional .NET format string; Lipi str.format\_time uses a reference-date layout and reads seconds. |
| [Pine Script](https://www.tradingview.com/pine-script-reference/v6/#fun_str.format_time) | `str.format_time()` | Looks alike, behaves differently | Pine takes the time in milliseconds and a pattern of tokens such as yyyy-MM-dd HH:mm; Lipi takes seconds and a Go-style reference-date layout. Numbers and types: Pine time argument is milliseconds; Lipi's is seconds, so divide by 1000 when converting. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Others/AsText) | | Not in thinkScript | AsText formats numbers only; the Date and Time list has no function that turns a time into text. |

## Trading session

Whether a bar falls inside a session, and the start of the trading day.

In Lipi: `session.isfirst`, `session.date`, `time_sessionday`. session.\* has only `date` and `isfirst`; there is no session.islast.

| Language | Construct | Relation | Note |
| - | - | - | - |
| [MQL4](https://docs.mql4.com/marketinformation/symbolinfosessiontrade) | `SymbolInfoSessionTrade(symbol, day_of_week, session_index, from, to)` | Built from several Lipi constructs | Returns a session's start and end as seconds from midnight for a weekday and index; testing a bar against sessions is manual. |
| [MQL5](https://www.mql5.com/en/docs/marketinformation/symbolinfosessiontrade) | `SymbolInfoSessionTrade` | Built from several Lipi constructs | Returns session start and end for a symbol, weekday and session index; first-bar-of-session tests must be built from those times. |
| [NinjaScript](https://ninjatrader.com/support/helpGuides/nt8/sessioniterator.htm) | `Bars.IsFirstBarOfSession, SessionIterator` | Built from several Lipi constructs | session.isfirst \~ Bars.IsFirstBarOfSession; session date and day start come from a SessionIterator built in State.DataLoaded. |
| [Pine Script](https://www.tradingview.com/pine-script-docs/concepts/time/) | `session.isfirstbar, time(timeframe, session), time_tradingday` | Equivalent, with a caveat | session.isfirst is session.isfirstbar, time\_sessionday is time\_tradingday, and time(tf, session) returns na outside the session. Pine has no session.date. |
| [thinkScript](https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Date---Time/SecondsFromTime) | `SecondsFromTime(HHMM), SecondsTillTime(HHMM), RegularTradingStart(yyyymmdd), GetYYYYMMDD()` | Built from several Lipi constructs | Session tests are seconds from or to an EST clock time, always zero on daily charts; GetYYYYMMDD gives the session date; no first-of-session flag. Bar timing: Clock times are fixed to EST rather than the exchange zone, and the functions return zero when the chart period is a day or more. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.