GetOrderVolume
Syntax
GetOrderVolume(): numberReturn Value
Description
Example
// Select an order by ticket number
if (this.api.SelectOrder(12345, EOrderSelectMode.SELECT_ORDER_BY_TICKET)) {
// Get the order's volume
const volume = this.api.GetOrderVolume();
// Get the order's symbol
const symbol = this.api.GetOrderSymbol();
console.log(`Order #12345 has a volume of ${volume} lots on ${symbol}`);
// Calculate the position size in base currency units
const standardLotSize = 100000; // Standard lot size for forex
const baseUnits = volume * standardLotSize;
console.log(`Position size: ${baseUnits} units of base currency`);
// Calculate required margin based on volume
if (
this.api.GetOrderType() === TTradePositionType.BUY ||
this.api.GetOrderType() === TTradePositionType.SELL
) {
// Example margin calculation (simplified)
const leverage = this.api.GetLeverageRatio();
const price = this.api.GetOrderOpenPrice();
const margin = (baseUnits * price) / leverage;
console.log(`Approximate margin required: ${margin.toFixed(2)}`);
}
}Notes
Last updated