syminfo.mintick in MQL5: SYMBOL_POINT vs tick size and value

Short answer

syminfo.mintick is SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE). _Point is the last displayed digit, which equals the tick size on most forex symbols but differs on many CFDs and futures.

The syminfo namespace describes the chart's instrument. In MQL5 the same facts come from SymbolInfoDouble, SymbolInfoInteger and SymbolInfoString on _Symbol. syminfo.mintick is the minimum price step, which is SYMBOL_TRADE_TICK_SIZE; _Point (SYMBOL_POINT) is the last displayed digit and is the same number for most forex symbols but not for many CFDs and futures.

What syminfo computes

  • syminfo.mintick: the smallest price increment of the symbol, used for rounding (math.round_to_mintick) and offsets such as close + 10 * syminfo.mintick.
  • syminfo.pointvalue: the value in the symbol's currency of a price move of 1.0 for one contract.
  • syminfo.tickerid: "EXCHANGE:SYMBOL", the form request.security takes; syminfo.ticker is the symbol alone.
  • syminfo.currency: the currency prices are quoted in; syminfo.basecurrency the base of a pair.
  • Also: syminfo.timezone, syminfo.session, syminfo.type, syminfo.description.

All are constants for the whole run of the script.

The MQL5 equivalent

The example rounds hlc3 to the tick size and shows the symbol's point, tick size, tick value, a derived point value and its currencies.

//@version=6
indicator("syminfo demo", overlay=true)
plot(math.round_to_mintick(hlc3), "hlc3 rounded to tick")
if barstate.islast
    label.new(bar_index, high, syminfo.tickerid + " tick=" + str.tostring(syminfo.mintick) + " pointvalue=" + str.tostring(syminfo.pointvalue) + " " + syminfo.basecurrency + "/" + syminfo.currency)
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDodgerBlue
#property indicator_label1  "hlc3 rounded to tick"

double RoundedBuf[];

// Pine: math.round_to_mintick(x)  -- round to the tick size, not to _Digits
double RoundToTick(const double x, const double tick)
{
   return tick > 0 ? MathRound(x / tick) * tick : x;
}

int OnInit()
{
   SetIndexBuffer(0, RoundedBuf, INDICATOR_DATA);

   double point     = SymbolInfoDouble(_Symbol, SYMBOL_POINT);             // smallest price step shown
   double tickSize  = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);   // Pine: syminfo.mintick
   double tickValue = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);  // profit of one tick, one lot
   double pointValue = tickSize > 0 ? tickValue / tickSize : 0.0;          // Pine: syminfo.pointvalue (per 1.0 move, one lot)
   string quoteCcy  = SymbolInfoString(_Symbol, SYMBOL_CURRENCY_PROFIT);   // Pine: syminfo.currency
   string baseCcy   = SymbolInfoString(_Symbol, SYMBOL_CURRENCY_BASE);     // Pine: syminfo.basecurrency

   // Pine: syminfo.tickerid is "EXCHANGE:SYMBOL"; MQL5 has only the broker symbol
   Comment(_Symbol, "  point=", DoubleToString(point, _Digits),
           "  tick=", DoubleToString(tickSize, _Digits),
           "  tickValue=", DoubleToString(tickValue, 2),
           "  pointValue=", DoubleToString(pointValue, 2),
           "  ", baseCcy, "/", quoteCcy);
   return INIT_SUCCEEDED;
}

int OnCalculate(const int rates_total, const int prev_calculated,
                const datetime &time[], const double &open[],
                const double &high[], const double &low[],
                const double &close[], const long &tick_volume[],
                const long &volume[], const int &spread[])
{
   double tick = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
   int start = prev_calculated > 0 ? prev_calculated - 1 : 0;
   for(int i = start; i < rates_total; i++)
      RoundedBuf[i] = RoundToTick((high[i] + low[i] + close[i]) / 3.0, tick);
   return rates_total;
}

void OnDeinit(const int reason) { Comment(""); }

Tick value is per lot, and a lot's size comes from SYMBOL_TRADE_CONTRACT_SIZE. On TradingView a forex "contract" is one unit of the base currency, so Pine's pointvalue for EURUSD is 1 while MetaTrader's value of a 1.0 move for one lot is the contract size. Anything that sizes positions needs to be redone with lots in mind; see percent-of-equity position sizing in MT5.

Where the two differ

PineMQL5Note
syminfo.mintickSymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE)equals _Point on most forex; differs on index CFDs, futures, some metals
syminfo.pointvalueTICK_VALUE / TICK_SIZEper lot, not per contract unit
syminfo.tickerid, syminfo.ticker_Symbolbroker name, often with a suffix (EURUSD.m); no exchange prefix
syminfo.currencySymbolInfoString(_Symbol, SYMBOL_CURRENCY_PROFIT)not the account currency
syminfo.basecurrencySYMBOL_CURRENCY_BASE
format.mintick digits_Digits
syminfo.timezonenoneMT5 exposes server time only

What the Stratlate converter emits

The current engine maps syminfo.mintick to _Point, syminfo.ticker and syminfo.tickerid to Symbol(), syminfo.pointvalue to the symbol's SYMBOL_TRADE_TICK_VALUE (through a MarketInfo shim in its runtime), and syminfo.currency and syminfo.basecurrency to the account currency (AccountInfoString(ACCOUNT_CURRENCY)). math.round_to_mintick(x) becomes NormalizeDouble(x, _Digits). None of these is noted in the report, and the example converted CLEAN, but as the table shows they are exact only where tick size equals point and the account currency equals the quote currency. On symbols where that does not hold, replace them with the SymbolInfo* calls above.

Pitfalls

  • Using _Point as the tick: on an index CFD with point 0.01 and tick size 0.25, prices rounded to _Point are not tradable. Symptom: "invalid price" when an EA places pending orders.
  • Pips vs points: on 5-digit forex 1 pip is 10 points. A Pine script that adds 10 * syminfo.mintick adds one pip, not ten.
  • Hard-coding a ticker with an exchange prefix: "FX:EURUSD" is not an MT5 symbol name. Use _Symbol or the broker's exact name, which may carry a suffix.
  • Taking the account currency for the quote currency: on a EUR account trading USDJPY the two are EUR and JPY.
  • Reading symbol properties before the symbol is selected: for a symbol other than the chart's, call SymbolSelect(name, true) first or the values are 0.

FAQ

Is syminfo.mintick the same as _Point?

Often but not always. _Point is the value of the last price digit; Pine's mintick is the minimum price change, which MQL5 calls SYMBOL_TRADE_TICK_SIZE. They agree on most forex pairs and differ on many indices, futures and some metals.

How do I get syminfo.pointvalue in MQL5?

Divide SYMBOL_TRADE_TICK_VALUE by SYMBOL_TRADE_TICK_SIZE to get the value of a 1.0 price move for one lot, in the account currency. Pine's value is per contract unit in the symbol's currency, so divide by the contract size if you need Pine's exact number.

What is syminfo.tickerid in MetaTrader?

_Symbol (or Symbol()), the broker's symbol name for the chart. MetaTrader has no exchange prefix, and the name can carry broker suffixes, so do not compare it with TradingView strings.

Convert the whole script

Paste a Pine Script indicator or strategy and get MQL5 with this and every other call mapped, checked against the original on the same bars, and every construct that could not be carried over reported.

Open the converter

Related