Docs / Market Data

Market Data

Direct access to price history, symbol specifications, account state, execution environment flags, and time primitives — all through clean namespace APIs.


OHLCVT Price Data

Called without arguments → full price array. Called with an integer offset → single scalar (0 = current bar, 1 = previous bar).

Function / PropertyParametersReturnsDescription
close()double[]Full close price array for current symbol/TF.
close(offset)int offsetdoubleSingle value: 0=current, 1=previous bar.
close(sym, tf)string sym, timeframe tfdouble[]Full close price array from another symbol/timeframe.
close(sym, tf, off)string sym, tf, int offdoubleSingle value from another symbol/timeframe at offset.
open()double[]Full open price array.
high()double[]Full high price array.
low()double[]Full low price array.
volume()double[]Full tick volume array.
time()datetime[]Bar open time array.
hl2()double[](High + Low) / 2 array.
hlc3()double[](High + Low + Close) / 3 array.
ohlc4()double[](Open + High + Low + Close) / 4 array.
tr()double[]True Range array.
candle_count()doubleTotal number of candles in history.
length(arr)double[] arrintNumber of elements in any array.

Cross-Symbol & Cross-Timeframe

Cross-TF accessTDSL
double eurusd_h4[] = close("EURUSD", Timeframe.H4);
double h4_close_now  = close("EURUSD", Timeframe.H4, 0);
double h4_close_prev = close("EURUSD", Timeframe.H4, 1);

// Multi-TF trend confirmation
Tick() {
  bool uptrend = close("EURUSD", Timeframe.H4, 0) > close("EURUSD", Timeframe.D1, 0);
  if (uptrend) { Trade.Buy(Symbol(), 0.1); }
}

Symbol.*

Function / PropertyReturnsDescription
Symbol()stringCurrent chart symbol name (e.g. "EURUSD").
Symbol.Bid(sym?)doubleCurrent bid price for sym (default: chart symbol).
Symbol.Ask(sym?)doubleCurrent ask price.
Symbol.Mid(sym?)doubleCurrent midpoint price.
Symbol.Spread(sym?)doubleCurrent spread in price units.
Symbol.Point(sym?)doubleMinimum price movement (1 pip unit).
Symbol.Digits(sym?)intDecimal places in price.
Symbol.PipDigits(sym?)intDecimal places for pips.
Symbol.TickSize(sym?)doubleMinimum price change.
Symbol.TickValue(sym?)doubleValue of one tick in deposit currency.
Symbol.LotMin(sym?)doubleMinimum allowed lot size.
Symbol.LotMax(sym?)doubleMaximum allowed lot size.
Symbol.LotStep(sym?)doubleLot increment step.
Symbol.NormalizePrice(p, s?)doubleRound price to correct decimal places.
Symbol.NormalizeVolume(v, s?)doubleRound lot size to correct step.
Symbol.ToLots(risk, sl, s?)doubleConvert risk % and SL distance to lot size.
Symbol.ToPips(diff, s?)doubleConvert price difference to pips.
Symbol.CanTrade(vol, s?)boolCheck if volume is tradeable right now.

Account.*

Function / PropertyReturnsDescription
Account.Balance()doubleCurrent account balance.
Account.Equity()doubleBalance + floating P&L.
Account.Profit()doubleTotal floating profit/loss.
Account.Margin()doubleUsed margin.
Account.FreeMargin()doubleAvailable free margin.
Account.Level()doubleMargin level percentage.
Account.Number()intAccount login number.
Account.Name()stringAccount owner name.
Account.Currency()stringDeposit currency (e.g. "USD").
Account.Leverage()intAccount leverage ratio.
Account.Hedging()boolTrue if hedging is allowed.
Account.Server()stringTrading server name.
Account.IsConnected()boolNetwork connectivity status.

Env.*

Function / PropertyReturnsDescription
Env.IsBacktest()boolRunning in historical backtest mode.
Env.IsLive()boolRunning against a live broker feed.
Env.IsTesting()boolRunning in paper-trade / test mode.
Env.IsOptimize()boolRunning during parameter optimisation.
Env.Connected()boolNetwork connectivity status.

Time.*

Function / PropertyReturnsDescription
Time.Server()datetimeCurrent broker server time.
Time.Hour()intCurrent hour (0–23).
Time.DayOfWeek()int0=Sunday … 6=Saturday.
Time.IsNewBar()boolTrue on the first tick of a new bar.
Time.InSession(name)boolTrue if server time is within the named session.
Time.InRange(from,to)boolTrue if server time falls within the HH:MM range.
Session filterTDSL
Tick() {
  if (!Time.InSession("London") && !Time.InSession("NewYork")) { return; }
  if (Time.InRange("16:30","17:00")) { return; }
  // strategy logic here...
}