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 / Property | Parameters | Returns | Description |
|---|
close() | — | double[] | Full close price array for current symbol/TF. |
close(offset) | int offset | double | Single value: 0=current, 1=previous bar. |
close(sym, tf) | string sym, timeframe tf | double[] | Full close price array from another symbol/timeframe. |
close(sym, tf, off) | string sym, tf, int off | double | Single 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() | — | double | Total number of candles in history. |
length(arr) | double[] arr | int | Number of elements in any array. |
Cross-Symbol & Cross-Timeframe
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 / Property | Returns | Description |
|---|
Symbol() | string | Current chart symbol name (e.g. "EURUSD"). |
Symbol.Bid(sym?) | double | Current bid price for sym (default: chart symbol). |
Symbol.Ask(sym?) | double | Current ask price. |
Symbol.Mid(sym?) | double | Current midpoint price. |
Symbol.Spread(sym?) | double | Current spread in price units. |
Symbol.Point(sym?) | double | Minimum price movement (1 pip unit). |
Symbol.Digits(sym?) | int | Decimal places in price. |
Symbol.PipDigits(sym?) | int | Decimal places for pips. |
Symbol.TickSize(sym?) | double | Minimum price change. |
Symbol.TickValue(sym?) | double | Value of one tick in deposit currency. |
Symbol.LotMin(sym?) | double | Minimum allowed lot size. |
Symbol.LotMax(sym?) | double | Maximum allowed lot size. |
Symbol.LotStep(sym?) | double | Lot increment step. |
Symbol.NormalizePrice(p, s?) | double | Round price to correct decimal places. |
Symbol.NormalizeVolume(v, s?) | double | Round lot size to correct step. |
Symbol.ToLots(risk, sl, s?) | double | Convert risk % and SL distance to lot size. |
Symbol.ToPips(diff, s?) | double | Convert price difference to pips. |
Symbol.CanTrade(vol, s?) | bool | Check if volume is tradeable right now. |
Account.*
| Function / Property | Returns | Description |
|---|
Account.Balance() | double | Current account balance. |
Account.Equity() | double | Balance + floating P&L. |
Account.Profit() | double | Total floating profit/loss. |
Account.Margin() | double | Used margin. |
Account.FreeMargin() | double | Available free margin. |
Account.Level() | double | Margin level percentage. |
Account.Number() | int | Account login number. |
Account.Name() | string | Account owner name. |
Account.Currency() | string | Deposit currency (e.g. "USD"). |
Account.Leverage() | int | Account leverage ratio. |
Account.Hedging() | bool | True if hedging is allowed. |
Account.Server() | string | Trading server name. |
Account.IsConnected() | bool | Network connectivity status. |
Env.*
| Function / Property | Returns | Description |
|---|
Env.IsBacktest() | bool | Running in historical backtest mode. |
Env.IsLive() | bool | Running against a live broker feed. |
Env.IsTesting() | bool | Running in paper-trade / test mode. |
Env.IsOptimize() | bool | Running during parameter optimisation. |
Env.Connected() | bool | Network connectivity status. |
Time.*
| Function / Property | Returns | Description |
|---|
Time.Server() | datetime | Current broker server time. |
Time.Hour() | int | Current hour (0–23). |
Time.DayOfWeek() | int | 0=Sunday … 6=Saturday. |
Time.IsNewBar() | bool | True on the first tick of a new bar. |
Time.InSession(name) | bool | True if server time is within the named session. |
Time.InRange(from,to) | bool | True if server time falls within the HH:MM range. |
Tick() {
if (!Time.InSession("London") && !Time.InSession("NewYork")) { return; }
if (Time.InRange("16:30","17:00")) { return; }
// strategy logic here...
}