brokerCommand (int Command, int Parameter): var

brokerCommand (int Command, string Text)

brokerCommand (int Command, var* Parameters)

Sets various broker plugin parameters or retrieves asset specific data for special purposes in a script. The functions can be optionally provided by the broker plugin; they return 0 when they are not supported or no broker connection is established. The number and types of parameters depend on Command. The following commands are predefined (in functions.h):
Text / Parameter
GET_TIME 0 Last incoming quote time in the MT4 server time zone, OLE DATE format.
GET_DIGITS Symbol Number of relevant digits after decimal point in the price quotes.
GET_STOPLEVEL Symbol The 'safety net' stop level of the last order (non-NFA accounts only).
GET_STARTING Symbol Starting date, usually for futures (OLE DATE format).
GET_EXPIRATION Symbol Expiration date, usually for futures (OLE DATE format).
GET_TRADEALLOWED Symbol Trade is allowed for the asset.
GET_MINLOT Symbol Minimum permitted amount of a lot.
GET_LOTSTEP Symbol Step for changing lots.
GET_MAXLOT Symbol Maximum permitted amount of a lot.
GET_MARGININIT Symbol Initial margin requirements for 1 lot.


Symbol Margin to maintain open positions calculated for 1 lot.
GET_MARGINHEDGED Symbol Hedged margin calculated for 1 lot.
GET_MARGINREQUIRED Symbol Free margin required to open 1 lot for buying.
GET_COMPLIANCE 0 Account restrictions, a combination of the following flags: 1 - no partial closing; 2 - no hedging; 3 - FIFO compliance; 4 - no stop loss; 8 - no closing of trades; 15 - full NFA compliant account.
GET_NTRADES 0 Number of all open trades in this account.
GET_POSITION Symbol Net open contracts of the given symbol; negative values for short positions.
GET_ACCOUNT String Fills the string with the account name.
GET_BOOKASKS Symbol Ask volume in the order book, in contracts.
GET_BOOKBIDS Symbol Bid volume in the order book.
GET_BOOKPRICE Rank Price quote for a given price rank in the order book, starting with 1 for the lowest price quote. Call BOOKASKS / BOOKBIDS before for setting the asset and quote type.
GET_BOOKVOL Rank Volume for a given price rank in the order book, starting with 1 for the lowest price quote.
GET_OPTIONS CONTRACT* Get the option chain of the underlying set with SET_SYMBOL.
GET_FUTURES CONTRACT* Get the futures chain of the underlying set with SET_SYMBOL.
GET_UNDERLYING 0 Get the underlying price for the previous brokerAsset call when the asset was an option.
GET_DELAY 0 Return delay in ms between commands sent to the broker.
SET_DELAY Time in ms Set delay in ms between commands sent to the broker.
GET_WAIT 0 Return maximum wait time for confirmation after a command was sent to the broker, in ms.
SET_WAIT Time in ms Set maximum wait time in ms for confirmation after a command was sent to the broker.
SET_LOCK 0, 1 Set (1) or release (0) a lock for synchonizing commands among several connected Zorros (see remarks). Returns 0 if the lock was already set, otherwise 1.
SET_SLIPPAGE Pips Set the maximum allowed slippage (default = 5 pips) in adverse direction for subsequently opening or closing trades. Higher allowed slippage causes less requotes, but allows trades to be entered at a worse price. Note that the allowed slippage is not guaranteed; trades can be still entered at higher slippage dependent on the brokerm, market access method, and server setup.
SET_SYMBOL Symbol Set the symbol for subsequent commands.
SET_MAGIC Number Set a "magic number" for identifying trades opened by the current script.
SET_MULTIPLIER Number Set the multiplier for retrieving option and future chains.
SET_CLASS Name Sets the name of the trading class. Call this before setting the symbol for option and future chains; use an empty string ("") for retrieving all trading classes.
SET_LIMIT Price* pointer Sets an entry limit for the next order. The next trade will be filled at or better than the limit price, or not at all.
SET_ORDERTEXT Text Set an order comment (255 characters max). Often required for special MT4 orders, f.i. for trading binary options.
SET_PATCH Patch value Work around broker API issues by calculating the following API parameters on the Zorro side:
1 - Balance and Equity; 2 - TradeProfit of open trades; 4 - TradeProfit of all trades; 8 - Server time. Numbers can be combined by addition.
SET_COMMENT Text Display the given text (255 characters max) in the broker platform, usually at the top of the chart window.
DO_EXERCISE Lots Exercise the given number of contracts of the option type set with SET_SYMBOL.
PLOT_HLINE Parameters Place a horizontal line at a given price in the chart window of the broker platform. 5 parameters are used: P[0] = always 0; P[1] = price position; P[2] = line color; P[3] = line width; P[4] = line style. Return the identfier number of the line.
PLOT_TEXT Parameters Place a text element at a price position at the right border of the chart window. 5 parameters are used: P[0] = always 0; P[1] = price position; P[2] = text color; P[3] = text size in points. Return the identfier number of the text element.
PLOT_MOVE Parameters Move the graphical element with the identifier given by P[0] to the horizontal position given by P[1] and the vertical position given by P[2].
PLOT_STRING Text Set or modify the text content for the last created or moved text element.
PLOT_REMOVE Identifier Delete the graphical element with the given identifier.
PLOT_REMOVEALL 0 Remove all graphical elements from the chart.


Command Input, one of the commands from the list above.
Parameter Input, parameter or data to the command.
Parameters Input, array of up to 8 vars for commands with multiple parameters.
Symbol Broker symbol of an asset (see Symbol). Often, but not always identical to the asset name.
Text Input, for commands that require a text string.


0 when the command is not supported by the broker plugin, otherwise the data to be retrieved.



See also:

Brokers, broker plugin, MT4 bridge, FXCM plugin, IB plugin, Oanda plugin

► latest version online