SymbolInfoDouble in Pine Script: syminfo.mintick, pointvalue
Short answer
SYMBOL_POINT and SYMBOL_TRADE_TICK_SIZE are syminfo.mintick, SYMBOL_TRADE_TICK_VALUE is syminfo.pointvalue * syminfo.mintick, and SYMBOL_VOLUME_MIN is syminfo.mincontract. Volume step, volume max, Bid and Ask have no counterpart.
SymbolInfoDouble(symbol, property) returns a numeric property of a symbol: its point size, tick size and tick value, the minimum, maximum and step of tradeable volume, the current Bid and Ask, swap rates and more. Pine Script exposes a smaller fixed set as syminfo.* variables for the chart symbol. The core mapping: SYMBOL_POINT and SYMBOL_TRADE_TICK_SIZE are syminfo.mintick; SYMBOL_TRADE_TICK_VALUE is syminfo.pointvalue * syminfo.mintick (money per tick per unit); SYMBOL_VOLUME_MIN is syminfo.mincontract. Volume step, volume max, Bid and Ask have no counterpart.
What SymbolInfoDouble computes
The values come from the broker's symbol specification. SYMBOL_POINT is the smallest price digit (0.00001 on a five-digit EURUSD, 0.01 on most gold symbols). SYMBOL_TRADE_TICK_SIZE is the smallest price change actually allowed, which is usually equal to the point but larger on some futures and indices. SYMBOL_TRADE_TICK_VALUE is the profit or loss in deposit currency of one tick move for one lot; for a USD account on EURUSD it is about 1.0 with a 100,000 contract size. SYMBOL_VOLUME_MIN, SYMBOL_VOLUME_MAX and SYMBOL_VOLUME_STEP constrain lot sizes (typically 0.01, 100 and 0.01). SYMBOL_BID and SYMBOL_ASK are the latest quotes. The integer sibling SymbolInfoInteger(symbol, SYMBOL_DIGITS) gives the number of decimals, and _Point / _Digits are shortcuts for the chart symbol.
In Pine, syminfo.mintick is the price scale's tick (the smallest displayed and tradeable increment); syminfo.pointvalue is the money value of a move of 1.0 in price for one unit of qty, in syminfo.currency; syminfo.mincontract is the smallest tradeable quantity. Money from these is in the symbol's currency unless the strategy declares currency=, in which case Pine converts results itself.
The Pine Script equivalent
Fixed-risk position sizing, the place where these properties matter most: the size that loses a set percentage of equity if the stop is hit.
//@version=6
strategy("Breakout with fixed-risk sizing", overlay = true, initial_capital = 10000)
riskPct = input.float(1.0, "Risk per trade, % of equity")
stopTks = input.int(400, "Stop distance, ticks")
len = input.int(20, "Breakout lookback")
// syminfo.mintick = SYMBOL_TRADE_TICK_SIZE (and usually SYMBOL_POINT)
// syminfo.pointvalue = money per 1.0 price move for 1 unit of qty
// so the money one unit loses over the stop is distance * pointvalue.
stopDist = stopTks * syminfo.mintick
riskMoney = strategy.equity * riskPct / 100
lossPerUnit = stopDist * syminfo.pointvalue
// No volume step in Pine: round down to the step you trade in (here whole units).
qty = math.max(syminfo.mincontract, math.floor(riskMoney / lossPerUnit))
if close > ta.highest(high, len)[1] and strategy.position_size == 0
strategy.entry("long", strategy.long, qty = qty)
strategy.exit("long sl", from_entry = "long", stop = close - stopDist)#include <Trade\Trade.mqh>
input double InpRiskPct = 1.0; // Risk per trade, % of equity
input int InpStopPts = 400; // Stop distance, points
input int InpLen = 20; // Breakout lookback
CTrade trade;
datetime lastBar = 0;
// Lots that lose InpRiskPct of equity if the stop is hit, rounded down to the volume step.
double RiskLots(const double stopPoints)
{
double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
double tickSize = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_SIZE);
double tickValue = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE); // money per tick per 1 lot
double volMin = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
double volMax = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
double volStep = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
if(tickSize <= 0.0 || tickValue <= 0.0 || volStep <= 0.0)
return(0.0);
double riskMoney = AccountInfoDouble(ACCOUNT_EQUITY) * InpRiskPct / 100.0;
double lossPerLot = stopPoints * point / tickSize * tickValue;
double lots = MathFloor(riskMoney / lossPerLot / volStep) * volStep;
return(MathMax(volMin, MathMin(volMax, lots)));
}
int OnInit()
{
return(INIT_SUCCEEDED);
}
void OnTick()
{
datetime t = iTime(_Symbol, _Period, 0);
if(t == lastBar) return;
lastBar = t;
int hi = iHighest(_Symbol, _Period, MODE_HIGH, InpLen, 2);
double lastClose = iClose(_Symbol, _Period, 1);
if(lastClose > iHigh(_Symbol, _Period, hi) && !PositionSelect(_Symbol))
{
double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
double sl = NormalizeDouble(ask - InpStopPts * _Point, _Digits);
trade.Buy(RiskLots(InpStopPts), _Symbol, ask, sl, 0.0);
}
}| MQL5 property | Pine |
|---|---|
SYMBOL_POINT, _Point | syminfo.mintick (check: equal on most FX and CFD feeds, not on every symbol) |
SYMBOL_TRADE_TICK_SIZE | syminfo.mintick |
SYMBOL_TRADE_TICK_VALUE | syminfo.pointvalue * syminfo.mintick, per unit not per lot |
SYMBOL_TRADE_CONTRACT_SIZE | No variable; on TradingView FX qty is already in units |
SYMBOL_VOLUME_MIN | syminfo.mincontract |
SYMBOL_VOLUME_STEP, SYMBOL_VOLUME_MAX | None; round qty yourself |
SYMBOL_BID, SYMBOL_ASK, SYMBOL_LAST | close (no bid/ask in bar data) |
SymbolInfoInteger(SYMBOL_DIGITS), _Digits | No variable; math.round(-math.log10(syminfo.mintick)) or format = format.mintick for display |
SymbolInfoString(SYMBOL_CURRENCY_PROFIT) | syminfo.currency |
Where the two differ
Lots versus units. Tick value in MQL5 is per lot; Pine's point value is per unit of qty. For forex on TradingView syminfo.pointvalue is 1 and quantity is in base currency units, so a 0.10-lot EA position is qty = 10000. For futures pointvalue is the contract multiplier (50 for ES) and qty is contracts, which matches MetaTrader futures when the broker's lot is one contract.
Point versus tick. MQL5 code mixes _Point for distances and tick size for money. Pine has one value. On a symbol where the broker's tick is five points (some indices), a stop of "400 points" means different prices on the two platforms; convert distances to prices first.
Deposit currency. SYMBOL_TRADE_TICK_VALUE is already converted into the account currency, and changes with the exchange rate. Pine's pointvalue is in the symbol's currency; set currency = currency.USD in strategy() for Pine to convert P&L, but the size formula above still uses the symbol currency, so multiply by a rate from request.currency_rate() when they differ.
Live quotes. An EA reads Bid and Ask; Pine sees only bar prices. Spread-dependent logic has to become a fixed cost.
What the Stratlate converter emits
The MQL5 to Pine engine dispatches SymbolInfoDouble on its property argument (PineCatalog, SymbolInfo* family): SYMBOL_POINT and SYMBOL_TRADE_TICK_SIZE become syminfo.mintick, SYMBOL_TRADE_TICK_VALUE becomes (syminfo.pointvalue * syminfo.mintick), SYMBOL_VOLUME_MIN and SYMBOL_VOLUME_STEP both become syminfo.mincontract, SYMBOL_VOLUME_MAX becomes the constant 1000000.0, and SYMBOL_BID, SYMBOL_ASK and SYMBOL_LAST become close; an unlisted property falls back to close. _Point is syminfo.mintick and _Digits / SYMBOL_DIGITS become int(math.round(-math.log10(syminfo.mintick))). ACCOUNT_EQUITY becomes strategy.equity and ACCOUNT_BALANCE strategy.initial_capital + strategy.netprofit. The RiskLots function above therefore converts line for line, but its result is still a lot count and is passed as qty unchanged, so on forex the strategy trades far fewer units than the EA. Review the sizing in the output; it should be compiled and backtested against the original.
Pitfalls
- Using
syminfo.pointvalueas tick value. It is the value of a 1.0 price move; multiply bysyminfo.mintickto get the value of one tick. Symptom: positions 10,000 times too small on FX. - Rounding
qtyto 0.01 because the EA's volume step was 0.01. On TradingView FX that is 0.01 units; round to whole units or to 1000-unit micro lots. - Assuming
_Pointequalssyminfo.mintickeverywhere. Check one symbol of each class you trade; JPY pairs, metals and indices differ between feeds. - Computing risk from
strategy.initial_capital. That ignores profits and losses;strategy.equityis the counterpart ofACCOUNT_EQUITY. - Using
closefor Ask in a spread filter. The filter is then always zero; drop it or replace it with a cost setting.
FAQ
What is the Pine equivalent of _Digits?
There is no variable. Compute it as int(math.round(-math.log10(syminfo.mintick))), or for display use str.tostring(x, format.mintick), which formats to the symbol's tick precision directly.
Is there a volume step or maximum lot in Pine?
No. A strategy accepts any positive qty; syminfo.mincontract gives only the minimum. Apply the broker's step and limits in code with math.floor(qty / step) * step and math.min if the backtest should respect them.
How do I size a position as a percentage of equity in Pine without the formula?
Set default_qty_type = strategy.percent_of_equity and default_qty_value = 10 in strategy(). That sizes by notional value, not by risk to the stop; for risk-based sizing use the formula on this page.
Convert the whole program
Paste an MQL4 or MQL5 indicator or Expert Advisor and get Pine Script v6 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