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 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_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.
GET_MAXTICKS 0 Return the maximum number of ticks to be filled by BrokerHistory2. If this command is not supported, it's 300 ticks.
SET_DIAGNOSTICS 0, 1 1 to enable, 0 to disable diagnostics output. When enabled, communication between plugin and API will be dumped into the Log folder for diagnostic purposes.
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 Set 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.
SET_COMBO_LEG 2, 3, 4 Declares the given number of following option trades as a combo order. Some brokers offer reduced margin and commission on combos. To use, set the combo leg number and immediately call the enter commands for the contracts. The order will be processed after the last enter command is received. If the order fails, the last enter will return 0. The script must then cancel the prior trades. All combo trades must have matching expiration dates  and underlying symbols; otherwise the order will not be accepted.
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.
2000..2999 var User supplied command with a single numerical parameter.
3000..3999 var* User supplied command with an array of 8 var parameters..
4000..5999 char* User supplied command with a text string.


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