Original (English)
brokerCommand (int Command, intptr_t 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 in [Trade] mode.
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. User-specific commands to the broker API can be added. The
following commands are predefined:
Command
|
Parameter |
Internal |
Returns |
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_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. |
GET_MARGINMAINTAIN |
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;
4 - FIFO compliance;
8 - no closing of trades; 15 - full NFA compliant account. |
GET_SERVERSTATE |
0 |
|
State of the broker server: 1
- server connected; 2 - server disconnected;
3 - server was temporarily disconnected since the
last GET_SERVERSTATE command. |
GET_NTRADES |
0 |
|
Number of all open trades in this account. |
GET_POSITION |
Symbol |
✔ |
Net open amount (as
in BrokerBuy2) of the given symbol; negative values for short
positions.
For brokers with varying lot amounts, call SET_AMOUNT
before. |
GET_AVGENTRY |
0 |
|
Average entry price for the preceding
GET_POSITION command, or 0 when
no position was open. The raw entry price from the broker is
returned; in case of options it might be required to divide it by
the Multiplier. |
GET_FILL |
Trade ID |
|
Deprecated;
replaced by BrokerTrade. Returned the
current fill amount of the open order, or -1 when
the order was not found or was not open anymore. |
GET_ACCOUNT |
String |
|
Fills the string with the account name. |
GET_DATA |
String |
|
General request to a REST API. The
string contains the request, usually a JSON object. It can
optionally begin with a '#' hash character and the last part of the post address
ending with a blank,
f.i. "#data "). The string is then filled with the
response from the API. Returns the response size in characters, or
0 when no valid response was returned. |
GET_BOOK |
T2* |
✔ |
Fills the T2 array with current quotes
from the order book. The asset is set with SET_SYMBOL;
bid prices are negative, the time field is
optional. The last T2 element is set to 0 for indicating the end
of the array. Returns the number of quotes. |
GET_TRADES |
TRADE* |
✔ |
Fill the given TRADE
array with the parameters of all open positions from the current account
(see remarks). Return the number of positions. |
GET_OPTIONS |
CONTRACT* |
✔ |
Fill the given CONTRACT
array with the option chain of the underlying set with SET_SYMBOL
(see remarks). |
GET_FUTURES |
CONTRACT* |
✔ |
Fill the given CONTRACT
array with the futures chain of the underlying set with SET_SYMBOL
(see remarks). |
GET_FOP |
CONTRACT* |
✔ |
Fill the given CONTRACT
array with the options of futures chain of the underlying set with SET_SYMBOL
(see remarks). |
GET_UNDERLYING |
0 |
✔ |
Get the underlying price for the preceding
brokerAsset call when the asset was an option. |
GET_GREEKS |
var[5] |
|
Get the greeks for a preceding
brokerAsset or
contractPrice call.
Fills the parameter array with P[0] = Implied
Volatility; P[1] = Delta; P[2] =
Gamma; P[3] = Vega; P[4] =
Theta. Greeks cannot be retrieved with 'fast' price type. |
SET_DELAY |
Time in ms |
|
Set delay in ms between commands sent to the broker
(normally 20). |
SET_WAIT |
Time in ms |
|
Set maximum wait time in ms for confirmation after a command was sent to the broker.
Default depends on the broker plugin; normally 60000. Increase the
time when trades need longer than 1 minute to open. |
GET_MAXTICKS |
0 |
✔ |
Return the maximum number of ticks to
be filled by BrokerHistory2. If this
command is not supported, it's 300 ticks. This command is called
at login to set the MaxTicks variable. |
GET_MAXREQUESTS |
0 |
✔ |
Return the maximum number of requests
per second allowed by the broker API. Sets up
MaxRequests if supported. |
GET_HEARTBEAT |
0 |
|
Return the maximum time in ms that the
API tolerates without a request. Sets up
TickTime if supported. |
GET_BROKERZONE |
0 |
✔ |
Return the time
zone of the timestamps set by the BrokerHistory2
function. Return 0 for UTC. Used for setting
BrokerZone. |
SET_DIAGNOSTICS |
0, 1 |
|
1 to enable, 0 to disable diagnostics output. When enabled, communication between plugin and API
and other plugin messages will be recorded in the log for diagnostic purposes. |
GET_LOCK |
0 |
|
Returns 1 if broker API calls must be
locked for synchronizing them among several connected Zorros;
returns -1 if broker API need not be locked. In this case the
NOLOCK flag is automatically set. |
SET_LOCK |
0, 1 |
|
Set (1) or release (0) a lock for synchronizing 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 broker, 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 all trading classes. |
SET_AMOUNT |
var pointer |
✔ |
Set the lot size for buy/sell
orders; for assets with arbitrary lot sizes. Automatically
sent before any order if the current
LotAmount is less than 1. |
SET_LEVERAGE |
Number |
✔ |
Set the leverage for buy/sell
orders; for assets with adjustable leverage. Automatically sent
before any order with the current Leverage
value. |
SET_PATCH |
Patch value |
|
Work around broker API issues that
cause wrong account or asset parameters. Retrieve the following parameters
in trade mode not from the broker
API, but
from the asset list or by calculating them
on the Zorro side
(numbers can be combined by addition):
1 - Balance and Equity;
2 - TradeProfit of open trades;
4 - TradeProfit of all trades;
8 - Server time; 16 -
Rollover and
Commission;
32 -
Leverage and MarginCost;
64 -
PIP, PIPCost,
LotAmount. |
SET_HWND |
HWND |
✔ |
Called before login with Zorro's window handle. The window handle can be used to
trigger asynchronous events and send messages to Zorro with the
PostMessage function. |
SET_FUNCTIONS |
Function pointer |
✔ |
Called before login with a pointer to Zorro's
function list, an array of function
pointers in the order given by include\func_list.h.
This allows the plugin to call Zorro functions, such as HTTP
or hash functions for REST APIs, by their number (see example). |
GET_CALLBACK |
Address pointer |
✔ |
Get the address of a plugin-supplied
callback function that is called at any WM_APP+3
message; automatically called after login. |
SET_BROKER |
Text |
|
Set the broker or exchange name when
a plugin supports multiple brokers or exchanges. Returns 0 when
the name did not match any, otherwise nonzero. |
SET_SERVER |
Text |
✔ |
Send the optional URL in the account
list Server field to the broker API. Automatically
called before login. Can be used to set a different URL for REST
endpoints. |
SET_CCY |
Text |
✔ |
Send the currency part of the account
list CCY field to the broker API. Automatically called before any
BrokerAccount call. |
SET_COMMENT |
Text |
|
Display the given text (255 characters max) in the broker platform, usually at the top of the chart window. |
SET_COMBO_LEGS |
2, 3, 4 |
✔ |
Declare the given number of following option trades as a combo order.
Most 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. |
SET_ORDERTYPE |
0 ... 11 |
✔ |
Switch between order types and
return the type if supported by the broker plugin, otherwise 0.
Automatically called at any order entry depending on
TradeMode and StopFactor. 0 -
Broker default
(highest fill probability) 1 - AON (all.or-none);
prevents partial fills
2 - GTC (good-till-cancelled); order stays
open until completely filled 3 -
AON+GTC 4 - Broker specific special order
type +8
- STOP; add a stop
order at distance Stop*StopFactor on NFA
accounts (see
remarks). |
SET_ORDERTEXT |
Text |
|
Set an arbitrary order comment for the
next order (255 characters max). Often also used for special orders, f.i. for trading binary options
with MT4, or for special order types like "STP LMT" with IB. Reset
with an empty string. |
SET_ORDERGROUP |
Text |
|
Set an order group name for the
next orders (255 characters max). Often used for grouping orders
together, f.i. for One-Cancels-Another (OCA) orders, depending on
the broker. Reset with an empty string. |
SET_PRICETYPE |
0 ... 8 |
|
Set the
type of prices returned by BrokerAsset and
BrokerHistory2, if applicable.
Return the type if supported by the broker plugin, otherwise
0. 0 - Broker default (ask/bid if available,
otherwise last trade price); 1 - enforce ask/bid quotes;
2 - enforce last trade price;
3 - special (broker specific); 4
- suppress price requests; 6 - adjusted last
trade price (for historical data); 8 - fast price requests:
ask, bid, or trade, whatever received first.
The spread is normally only
updated when ask/bid quotes are returned. |
SET_VOLTYPE |
0 ... 7 |
|
Set the type of volume data
returned by BrokerAsset and BrokerHistory2,
if applicable. Return the type if supported by the broker plugin,
otherwise 0.
0 - Broker default, usually quote size;
1 - no volume; 2 - tick
frequency; 3 - quote size (ask+bid);
4 - trade volume; 5 - ask size; 6 -
bid size; 7 - open interest. |
SET_VALTYPE |
0 .. 3 |
|
Set the type of
marketVal data returned by
BrokerAsset and BrokerHistory2, if
applicable. Return the type if supported by the broker plugin,
otherwise 0. 1
- no data; 2 - spread; 3 - WAP. |
GET_UUID |
String |
✔ |
Copies the UUID of the last opened
trade to the given string. |
SET_UUID |
String |
✔ |
Sets the UUID for the next command from
the given string. |
DO_EXERCISE |
Lots |
✔ |
Exercise the given number of contracts of the option type set with SET_SYMBOL. |
DO_CANCEL |
Trade ID |
|
Cancel the
remaining unfilled amount of the order with the given trade ID. If
ID == 0, all open orders are cancelled.
If ID == -1, cancel the order with the UUID set
before by SET_UUID. Otherwise, use a valid
ID of an open position. Returns 1
when the order was cancelled, or 0 when the order
was not found or could not be cancelled. |
PLOT_HLINE |
var[5] |
|
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 identifier number of the line. |
PLOT_TEXT |
var[4] |
|
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 identifier number of the text element. |
PLOT_MOVE |
var[3] |
|
Move the graphical element with the identifier given by the
first parameter P[0], 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 |
P[8] |
|
User supplied command with an array of 8 var parameters. |
4000..5999 |
char* |
|
User supplied command with a text string. |
Parameters:
Command |
Input, one of the commands from the list above. |
Parameter |
Input, parameter or data to the command. A 32 bit int
or pointer for 32 bit plugins, or a 64 bit long int
or pointer for 64 bit plugins. |
Parameters, P |
Input, array of up to 8 vars for commands that
set or retrieve multiple parameters. |
Symbol |
Input, char*, broker symbol of an asset (see Symbol).
Complex symbols, as for selected option contracts, can have the
underlying, exchange, expiry, and other parameters coded in the name
as described under IB Bridge. |
Text |
Input, char*, for commands that require a text string. |
Returns:
0 when the command is not supported by the broker plugin, otherwise the data to be retrieved.
brokerAsset (string Symbol, var* pPrice, var* pSpread, var *pVol)
Call the BrokerAsset function with the given
Symbol (f.i. SymbolLive) and return the price, spread, and volume.
brokerAccount (string
Name, string AccountID, var *pBalance, var *pTradeVal, var *pMarginVal);
Call the BrokerAccount function for the
account list entry given by Name and an optional account
identifier, and return the balance, open trade value, and allocated margin. Can be
used to retrieve account information when trading with
multiple brokers.
brokerRequest (string
Path, string Method, string Data): string
Call the BrokerRequest function for sending
arbitrary HTTP requests to the connected REST API. Path is the
relative URL including the query string, but without the endpoint root. If
Method begins with '$', the request will be
signed. Data is the optional request body. If no particular
Method and no body is given, a GET request is
sent. The response is returned and can be evaluated.
brokerTrades (int Filter): int
Call the GET_TRADES command. Cancel all currently open trades,
and replace them with the open positions on the broker account (if any).
Filter = 0 loads all positions,
Filter = 1 loads only positions matching the asset list,
Filter = 2 loads only
positions of assets that were already selected in the script,
Filter = 4 loads only positions of the current asset and prevents the
previous cancelling of open trades. Add 16 to
Filter for adjusting TradeUnits and
TradePriceOpen by the Multiplier,
as needed for option contracts with some broker APIs. The function returns
the number of entered positions. It can synchronize
script trades with the broker account. The account must support the
GET_TRADES command and have only open positions from the current Zorro
script. The enterTrade function is used for entering
the new trades. The entered trades are plain, without exit limits, TMFs, flags,
TradeVars, or any other trade parameter that is not stored on the broker
account. The algo identifiers of the trades are set to the current
algo. For correctly updating the trades, all assets must
have been used in the script.
Remarks:
- Commands marked internal are
automatically sent
by Zorro to the broker plugin. They need normally not be used in the
script. The other commands are not used by Zorro and available to the script.
If a command is not supported, it returns 0. Which of the commands are supported can be found on the description page of the broker plugin.
- The SET_PATCH command is always supported since
it's handled on the Zorro side. It lets Zorro estimate account and trade parameters, rather than
using the values from the broker API. This is required when the broker API calculates those parameters wrong, as
was the case for the account balance, equity, and open trade profit in
some FXCM API versions. Replacing those parameters has no effect on trading, but on the displayed equity and profit values on the Zorro panel. The estimated equity includes only the profit by trades of the current strategy, and thus is different to the account equity when other systems trade on the same account. The estimated trade result can also differ to the real result due to slippage and rollover.
- For preventing the interruption of a
command sequence by another Zorro instance - f.i. for
setting order parameters before sending the order - use either the SET_LOCK command
(if available) or the
lock function. They work like a Windows Mutex. Before the sequence,
use while(0 == brokerCommand(SET_LOCK,1)) wait(5);
for waiting until the lock was released, and setting it then.
Afterwards, brokerCommand(SET_LOCK,0) releases the lock after sending the command sequence.
If SET_LOCK is not supported by the plugin, use the
lock/unlock functions in a similar way to lock the part of the code.
- If the script connects to multiple
brokers, commands are sent to the broker assigned to trading
with the current asset (SourceTrade).
- Contract chains by
GET_OPTIONS or GET_FOP are filled with the following data from the
CONTRACT struct, which is defined in
include\trading.h:
time: a null-terminated string of up to 7 chars containing the
trading class symbol (if available) fAsk,
fBid: the ask and bid price (if available) fStrike: the strike price
fVal: the multiplier (if available)
Expiry: the expiration date in YYYYMMDD
format Type: the contract type,
PUT, CALL, FUTURE, EUROPEAN, BINARY; optionally an
exchange identifier coded in the upper 16 bits.
- Trade arrays by
GET_TRADES are filled with the following position data (the
TRADE struct is defined in
include\trading.h):
nId: a
unique trade identifier (if available) nLots: the
position amount flags: TR_SHORT
for short positions
fEntryPrice: the average entry price if available;
some brokers (IB) multiply the entry price with the options
multiplier.
fStrike: the strike price if applicable
tExitDate: the expiration date in
DATE format (if applicable) nContract: the contract type
if applicable, i.e. PUT or CALL; optionally an
exchange identifier coded in the upper 16 bits. If the
FUTURE, EUROPEAN, BINARY
flags are not available via broker API, they must be set by script. sInfo:
the trading class symbol (if applicable)
- Variables or text set up with brokerCommand
span class="Highlight">keep their content until modified by another brokerCommand.
Take care of this when a previous trading session has used this
command to set a variable or text.
- If the broker API provides no information about trades - as is
the case for most NFA compliant APIs - make sure to keep the
trades on the Zorro side and the broker side in sync. Don't close
positions or cancel orders on one side only.
- If the broker API supports a particular
order type, the plugin returns the order type on the SET_ORDERTYPE
command; otherwise it returns 0.
- SET_ORDERTYPE >= 8 places a
separate stop order when supported by the broker.
Dependent on the behavior of the broker API,
this order might stay alive even when the original trade was closed.
In that case cancel it manually: Send a DO_CANCEL
command with the stop order trade ID, which is normally the original
trade ID +1. Otherwise the stop order might stay open and trigger an
unwanted position in reverse direction.
- Not all price types are supported
with all assets. Check with your broker which prices types are
supported, and make sure to use SET_PRICETYPE
only when available for the selected asset. Otherwise leave it at
0
- Some commands send a 32 bit pointer as parameter, for
instance to pass a string or one or several
double variables to the plugin. The broker
plugin can then cast it to the required type for getting the
content, f.i. double NewLotAmount = *(double*)Parameter;
- User defined commands for special broker API settings
can be defined with a command number >
2000. Numbers below 2000 are reserved for predefined commands.
Examples:
brokerCommand(SET_COMMENT,strf("Algo %s",Algo)); // set a comment
brokerCommand(SET_PATCH,16+32); // take swap, commission, leverage from the asset list
var Greeks[5];
contractPrice(ThisContract);
brokerCommand(GET_GREEKS,Greeks); // get greeks of the current contract
// Read all positions from an asset list ///////////////////////
void main()
{
assetList("AssetsFix");
string Name;
while(Name = loop(Assets)) {
var Position = brokerCommand(GET_POSITION,Name);
printf("\n%6.4f %s",Position,Name);
if(!wait(10)) break;
}
}
// read and print the order book
void main()
{
static T2 Quotes[MAX_QUOTES];
brokerCommand(SET_SYMBOL,"AAPL");
int i,N = brokerCommand(GET_BOOK,Quotes);
printf("\nOrderbook: %i quotes",N);
for(i=0; i<N; i++)
printf("\nPrice %.2f Vol %.2f",(var)Quotes[i].fVal,(var)Quotes[i].fVol);
}
// read JSON data string from the Coinigy REST API
void main()
{
brokerCommand(SET_BROKER,"GDAX");
static char Buffer[MAX_BUFFER];
strcpy(Buffer,"#data "); // target point
strcat(Buffer,"{\n\"exchange_code\": \"GDAX\",");
strcat(Buffer,"\n\"exchange_market\": \"BTC/USD\",");
strcat(Buffer,"\n\"type\": \"bids\"\n}");
int Size = brokerCommand(GET_DATA,Buffer);
if(Size)
printf("\nResponse: %s",Buffer);
}
// Use Zorro HTTP functions in a REST API plugin
int (__cdecl *http_send)(const char* url,const char* data,const char* header) = NULL;
long (__cdecl *http_status)(int id) = NULL;
long (__cdecl *http_result)(int id,char* content,long size) = NULL;
int (__cdecl *http_free)(int id) = NULL;
...
DLLFUNC double BrokerCommand(int command,intptr_t parameter)
{
switch(command) {
case SET_FUNCTIONS: {
FARPROC* Functions = (FARPROC*)parameter;
(FARPROC&)http_send = Functions[139];
(FARPROC&)http_status = Functions[142];
(FARPROC&)http_result = Functions[143];
(FARPROC&)http_free = Functions[144];
return 1.;
}
...
}
return 0.;
}
See also:
Brokers, broker plugin, MTR4 bridge, FXCM plugin, IB plugin,
Oanda plugin
► latest
version online
|
Übersetzung (Deutsch)
brokerCommand (int Command, intptr_t Parameter): var
brokerCommand (int Command, string Text)
brokerCommand (int Command, var* Parameters)
Setzt verschiedene Broker-Plugin-Parameter oder ruft asset-spezifische Daten für spezielle Zwecke in einem Skript im [Trade] Modus ab.
Die Funktionen können optional vom Broker-Plugin bereitgestellt werden; sie geben 0 zurück, wenn sie nicht unterstützt werden oder keine Broker-Verbindung besteht.
Die Anzahl und Typen der Parameter hängen von Command ab. Benutzerspezifische Befehle an die Broker-API können hinzugefügt werden. Die
folgenden Befehle sind vordefiniert:
Befehl
|
Parameter |
Intern |
Rückgabe |
GET_TIME |
0 |
|
Letzte eingehende Kurszeit in der Server-Zeitzone, OLE DATE Format. |
GET_DIGITS |
Symbol |
|
Anzahl der relevanten Stellen nach dem Dezimalpunkt in den Kursangaben. |
GET_STOPLEVEL |
Symbol |
|
Das 'Sicherheitsnetz' Stop-Level der letzten Order (nur für Nicht-NFA-Konten). |
GET_TRADEALLOWED |
Symbol |
|
Handel ist für das Asset erlaubt. |
GET_MINLOT |
Symbol |
|
Mindest erlaubte Lotgröße. |
GET_LOTSTEP |
Symbol |
|
Schritt zur Änderung der Lotgrößen. |
GET_MAXLOT |
Symbol |
|
Maximal erlaubte Lotgröße. |
GET_MARGININIT |
Symbol |
|
Anfängliche Margin-Anforderungen für 1 Lot. |
GET_MARGINMAINTAIN |
Symbol |
|
Margin zur Aufrechterhaltung offener Positionen berechnet für 1 Lot. |
GET_MARGINHEDGED |
Symbol |
|
Hedged Margin berechnet für 1 Lot. |
GET_COMPLIANCE |
0 |
|
Kontobeschränkungen, eine Kombination der folgenden Flags: 1 - kein partielles Schließen; 2 - kein Hedging;
4 - FIFO-Konformität;
8 - kein Schließen von Trades; 15 - vollständig NFA-konformes Konto. |
GET_SERVERSTATE |
0 |
|
Status des Broker-Servers: 1
- Server verbunden; 2 - Server getrennt;
3 - Server war seit dem letzten GET_SERVERSTATE Befehl vorübergehend getrennt. |
GET_NTRADES |
0 |
|
Anzahl aller offenen Trades in diesem Konto. |
GET_POSITION |
Symbol |
✔ |
Netto offene Menge (wie
in BrokerBuy2) des gegebenen Symbols; negative Werte für Short
Positionen.
Für Broker mit variierenden Lotgrößen, rufen Sie SET_AMOUNT
vorher auf. |
GET_AVGENTRY |
0 |
|
Durchschnittlicher Einstiegspreis für den vorangegangenen
GET_POSITION Befehl, oder 0, wenn
keine Position offen war. Der rohe Einstiegspreis vom Broker wird
zurückgegeben; im Falle von Optionen muss er möglicherweise durch
den Multiplier geteilt werden. |
GET_FILL |
Trade ID |
|
Veraltet;
ersetzt durch BrokerTrade. Gibt die
aktuelle Füllmenge der offenen Order zurück, oder -1, wenn
die Order nicht gefunden wurde oder nicht mehr offen ist. |
GET_ACCOUNT |
String |
|
Füllt den String mit dem Kontonamen. |
GET_DATA |
String |
|
Allgemeine Anfrage an eine REST API. Der
String enthält die Anfrage, normalerweise ein JSON-Objekt. Er kann
optional mit einem '#' Hashtag beginnen und den letzten Teil der Post-Adresse
endend mit einem Leerzeichen,
z.B. "#data "). Der String wird dann mit der
Antwort von der API gefüllt. Gibt die Antwortgröße in Zeichen zurück oder
0, wenn keine gültige Antwort zurückgegeben wurde. |
GET_BOOK |
T2* |
✔ |
Füllt das T2 Array mit aktuellen Kursen
aus dem Orderbuch. Das Asset wird mit SET_SYMBOL gesetzt;
Bid-Preise sind negativ, das time Feld ist
optional. Das letzte T2 Element wird auf 0 gesetzt, um das Ende
des Arrays anzuzeigen. Gibt die Anzahl der Kurse zurück. |
GET_TRADES |
TRADE* |
✔ |
Füllt das gegebene TRADE
Array mit den Parametern aller offenen Positionen aus dem aktuellen Konto
(siehe Bemerkungen). Gibt die Anzahl der Positionen zurück. |
GET_OPTIONS |
CONTRACT* |
✔ |
Füllt das gegebene CONTRACT
Array mit der Optionskette des zugrunde liegenden Assets gesetzt mit SET_SYMBOL
(siehe Bemerkungen). |
GET_FUTURES |
CONTRACT* |
✔ |
Füllt das gegebene CONTRACT
Array mit der Futureskette des zugrunde liegenden Assets gesetzt mit SET_SYMBOL
(siehe Bemerkungen). |
GET_FOP |
CONTRACT* |
✔ |
Füllt das gegebene CONTRACT
Array mit den Optionen der Futureskette des zugrunde liegenden Assets gesetzt mit SET_SYMBOL
(siehe Bemerkungen). |
GET_UNDERLYING |
0 |
✔ |
Holt den zugrunde liegenden Preis für den vorangegangenen
brokerAsset Aufruf, wenn das Asset eine Option war. |
GET_GREEKS |
var[5] |
|
Holt die Greeks für einen vorangegangenen
brokerAsset oder
contractPrice Aufruf.
Füllt das Parameterarray mit P[0] = Implizite
Volatilität; P[1] = Delta; P[2] =
Gamma; P[3] = Vega; P[4] =
Theta. Greeks können nicht mit 'fast' price type abgerufen werden. |
SET_DELAY |
Zeit in ms |
|
Setzt die Verzögerung in ms zwischen an den Broker gesendeten Befehlen
(normalerweise 20). |
SET_WAIT |
Zeit in ms |
|
Setzt die maximale Wartezeit in ms für die Bestätigung nach dem Senden eines Befehls an den Broker.
Der Standard hängt vom Broker-Plugin ab; normalerweise 60000. Erhöhen Sie die
Zeit, wenn Trades länger als 1 Minute zum Öffnen benötigen. |
GET_MAXTICKS |
0 |
✔ |
Gibt die maximale Anzahl von Ticks zurück, die von BrokerHistory2 gefüllt werden sollen. Wenn dieser
Befehl nicht unterstützt wird, sind es 300 Ticks. Dieser Befehl wird
beim Login aufgerufen, um die MaxTicks Variable zu setzen. |
GET_MAXREQUESTS |
0 |
✔ |
Gibt die maximale Anzahl von Anfragen
pro Sekunde zurück, die von der Broker-API erlaubt sind. Setzt
MaxRequests, wenn unterstützt. |
GET_HEARTBEAT |
0 |
|
Gibt die maximale Zeit in ms zurück, die die
API ohne eine Anfrage toleriert. Setzt
TickTime, wenn unterstützt. |
GET_BROKERZONE |
0 |
✔ |
Gibt die Zeitzone der Zeitstempel zurück, die von der BrokerHistory2
Funktion gesetzt wurden. Gibt 0 für UTC zurück. Wird verwendet zum Setzen
von BrokerZone. |
SET_DIAGNOSTICS |
0, 1 |
|
1 zum Aktivieren, 0 zum Deaktivieren der Diagnostik-Ausgabe. Wenn aktiviert, wird die Kommunikation zwischen Plugin und API
sowie andere Plugin-Nachrichten im Log für Diagnosezwecke aufgezeichnet. |
GET_LOCK |
0 |
|
Gibt 1 zurück, wenn Broker-API-Aufrufe gesperrt werden müssen, um sie unter mehreren verbundenen Zorros zu synchronisieren;
gibt -1 zurück, wenn Broker-API nicht gesperrt werden muss. In diesem Fall wird das
NOLOCK Flag automatisch gesetzt. |
SET_LOCK |
0, 1 |
|
Setzt (1) oder gibt (0) eine Sperre frei, um Befehle unter mehreren verbundenen Zorros zu synchronisieren (siehe Bemerkungen). Gibt 0 zurück, wenn die Sperre bereits gesetzt war, sonst 1. |
SET_SLIPPAGE |
Pips |
|
Setzt die maximal erlaubte Slippage (Standard = 5 Pips) in ungünstiger Richtung für nachfolgende Kauf- oder Verkaufsaufträge. Höhere erlaubte Slippage führt zu weniger Requotes, erlaubt aber, Trades zu einem schlechteren Preis einzugehen. Beachten Sie, dass die erlaubte Slippage nicht garantiert ist; Trades können dennoch zu höherer Slippage abhängig vom Broker, Marktzugangsmethode und Server-Setup eingehen. |
SET_SYMBOL |
Symbol |
✔ |
Setzt das Symbol für nachfolgende Befehle. |
SET_MAGIC |
Number |
|
Setzt eine "Magic Number" zur Identifizierung von Trades, die vom aktuellen Skript geöffnet wurden. |
SET_MULTIPLIER |
Number |
✔ |
Setzt den Multiplikator zum Abrufen von Options- und Futuresketten. |
SET_CLASS |
Name |
|
Setzt den Namen der Handelsklasse. Rufen Sie dies auf, bevor Sie das Symbol für Options- und Futuresketten setzen; verwenden Sie eine leere Zeichenkette ("") für alle Handelsklassen. |
SET_AMOUNT |
var pointer |
✔ |
Setzt die Lotgröße für Kauf-/Verkaufsaufträge; für Assets mit beliebigen Lotgrößen. Wird automatisch vor jedem Auftrag gesendet, wenn die aktuelle
LotAmount kleiner als 1 ist. |
SET_LEVERAGE |
Number |
✔ |
Setzt die Hebelwirkung für Kauf-/Verkaufsaufträge; für Assets mit anpassbarer Hebelwirkung. Wird automatisch vor jedem Auftrag mit dem aktuellen Leverage
Wert gesendet. |
SET_PATCH |
Patch value |
|
Umgeht Broker-API-Probleme, die
falsche Konto- oder Asset-Parameter verursachen. Ruft die folgenden Parameter
im Trade-Modus nicht von der Broker-API ab, sondern
von der Asset-Liste oder durch Berechnung auf der Zorro-Seite
ab (Zahlen können durch Addition kombiniert werden):
1 - Balance und Equity;
2 - TradeProfit offener Trades;
4 - TradeProfit aller Trades;
8 - Serverzeit; 16 -
Rollover und
Kommission;
32 -
Hebelwirkung und MarginCost;
64 -
PIP, PIPCost,
LotAmount. |
SET_HWND |
HWND |
✔ |
Wird vor dem Login mit Zorros Fensterhandle aufgerufen. Das Fensterhandle kann verwendet werden, um
asynchrone Ereignisse auszulösen und Nachrichten an Zorro mit der
PostMessage Funktion zu senden. |
SET_FUNCTIONS |
Function pointer |
✔ |
Wird vor dem Login mit einem Zeiger auf Zorros
Funktionsliste, ein Array von Funktionszeigern
in der Reihenfolge gegeben durch include\func_list.h, aufgerufen.
Dies ermöglicht dem Plugin, Zorros Funktionen, wie HTTP
oder Hash-Funktionen für REST APIs, anhand ihrer Nummer aufzurufen (siehe Beispiel). |
GET_CALLBACK |
Address pointer |
✔ |
Holt die Adresse einer vom Plugin bereitgestellten
Callback-Funktion, die bei jeder WM_APP+3
Nachricht aufgerufen wird; wird automatisch nach dem Login aufgerufen. |
SET_BROKER |
Text |
|
Setzt den Broker- oder Börsennamen, wenn
ein Plugin mehrere Broker oder Börsen unterstützt. Gibt 0 zurück, wenn
der Name keinem entspricht, ansonsten ungleich 0. |
SET_SERVER |
Text |
✔ |
Sendet die optionale URL im Kontolistenfeld Server an die Broker-API. Wird automatisch
vor dem Login aufgerufen. Kann verwendet werden, um eine andere URL für REST
Endpunkte zu setzen. |
SET_CCY |
Text |
✔ |
Sendet den Währungsanteil des Kontolistenfelds CCY an die Broker-API. Wird automatisch vor jedem
BrokerAccount Aufruf aufgerufen. |
SET_COMMENT |
Text |
|
Zeigt den gegebenen Text (max. 255 Zeichen) in der Broker-Plattform an, normalerweise oben im Chart-Fenster. |
SET_COMBO_LEGS |
2, 3, 4 |
✔ |
Deklariert die gegebene Anzahl der folgenden Options-Trades als Combo-Order.
Die meisten Broker bieten reduzierte Margen und Kommissionen für Combos an. Um dies zu nutzen, setzen Sie die Combo-Leg-Nummer und rufen Sie sofort die enter Befehle für die Kontrakte auf. Die Order wird bearbeitet, nachdem der letzte enter Befehl empfangen wurde.
Wenn die Order fehlschlägt, gibt der letzte enter 0 zurück. Das Skript muss dann die vorherigen Trades stornieren.
Alle Combo-Trades müssen passende Ablaufdaten und Basiswerte haben; andernfalls wird die Order nicht akzeptiert. |
SET_ORDERTYPE |
0 ... 11 |
✔ |
Wechselt zwischen Ordertypen und
gibt den Typ zurück, wenn er vom Broker-Plugin unterstützt wird, sonst 0.
Wird automatisch bei jeder Order-Eingabe abhängig von
TradeMode und StopFactor aufgerufen. 0 -
Broker-Standard
(höchste Füllwahrscheinlichkeit) 1 - AON (all.or-none);
verhindert Teil-Fills
2 - GTC (good-till-cancelled); Order bleibt
offen, bis sie vollständig gefüllt ist 3 -
AON+GTC 4 - Broker-spezifischer spezieller Order
Typ +8
- STOP; fügt eine Stop-Order mit Abstand Stop*StopFactor auf NFA
Konten hinzu (siehe
Bemerkungen). |
SET_ORDERTEXT |
Text |
|
Setzt einen beliebigen Order-Kommentar für die
nächste Order (max. 255 Zeichen). Wird oft auch für spezielle Orders verwendet, z.B. für den Handel mit binären Optionen
mit MT4 oder für spezielle Ordertypen wie "STP LMT" mit IB. Setzt
mit einer leeren Zeichenkette zurück. |
SET_ORDERGROUP |
Text |
|
Setzt einen Ordergruppen-Namen für die
nächsten Orders (max. 255 Zeichen). Wird oft verwendet, um Orders
zusammenzufassen, z.B. für One-Cancels-Another (OCA) Orders, abhängig vom
Broker. Setzt mit einer leeren Zeichenkette zurück. |
SET_PRICETYPE |
0 ... 8 |
|
Setzt den
Typ der Preise, die von BrokerAsset und
BrokerHistory2 zurückgegeben werden, falls anwendbar.
Gibt den Typ zurück, wenn er vom Broker-Plugin unterstützt wird, sonst
0. 0 - Broker-Standard (Ask/Bid, wenn verfügbar,
sonst letzter Handelspreis); 1 - Erzwingt Ask/Bid-Kurse;
2 - Erzwingt den letzten Handelspreis;
3 - Spezial (Broker-spezifisch); 4
- Unterdrückt Preisabfragen; 6 - angepasster letzter
Handelspreis (für historische Daten); 8 - schnelle Preisabfragen:
Ask, Bid oder Trade, was zuerst empfangen wird.
Der Spread wird normalerweise nur
aktualisiert, wenn Ask/Bid-Kurse zurückgegeben werden. |
SET_VOLTYPE |
0 ... 7 |
|
Setzt den Typ der Volumendaten
zurückgegeben von BrokerAsset und BrokerHistory2,
falls anwendbar. Gibt den Typ zurück, wenn er vom Broker-Plugin unterstützt wird,
sonst 0.
0 - Broker-Standard, normalerweise Quote-Größe;
1 - kein Volumen; 2 - Tick
Häufigkeit; 3 - Quote-Größe (Ask+Bid);
4 - Handelsvolumen; 5 - Ask-Größe; 6 -
Bid-Größe; 7 - Open Interest. |
SET_VALTYPE |
0 .. 3 |
|
Setzt den Typ der
marketVal Daten, die von
BrokerAsset und BrokerHistory2 zurückgegeben werden, falls
anwendbar. Gibt den Typ zurück, wenn er vom Broker-Plugin unterstützt wird,
sonst 0. 1
- keine Daten; 2 - Spread; 3 - WAP. |
GET_UUID |
String |
✔ |
Kopiert die UUID des zuletzt geöffneten
Trades in den gegebenen String. |
SET_UUID |
String |
✔ |
Setzt die UUID für den nächsten Befehl aus
dem gegebenen String. |
DO_EXERCISE |
Lots |
✔ |
Übt die gegebene Anzahl von Kontrakten des mit SET_SYMBOL gesetzten Optionstyps aus. |
DO_CANCEL |
Trade ID |
|
Storniert den
verbleibenden ungefüllten Betrag der Order mit der gegebenen Trade ID. Wenn
ID == 0, werden alle offenen Orders storniert.
Wenn ID == -1, storniert die Order mit der UUID, die
zuvor mit SET_UUID gesetzt wurde. Andernfalls, verwenden Sie eine gültige
ID einer offenen Position. Gibt 1 zurück,
wenn die Order storniert wurde, oder 0, wenn die Order
nicht gefunden wurde oder nicht storniert werden konnte. |
PLOT_HLINE |
var[5] |
|
Platziert eine horizontale Linie bei einem gegebenen Preis im Chart-Fenster der Broker-Plattform. Es werden 5 Parameter verwendet: P[0] = immer 0; P[1] = Preisposition; P[2] = Linienfarbe; P[3] = Linienbreite; P[4] = Linienstil. Gibt die Identifikationsnummer der Linie zurück. |
PLOT_TEXT |
var[4] |
|
Platziert ein Textelement bei einer Preisposition am rechten Rand des Chart-Fensters. Es werden 5 Parameter verwendet: P[0] = immer 0; P[1] = Preisposition; P[2] = Textfarbe; P[3] = Textgröße in Punkten. Gibt die Identifikationsnummer des Textelements zurück. |
PLOT_MOVE |
var[3] |
|
Bewegt das grafische Element mit der durch den
ersten Parameter P[0], gegebenen Identifikationsnummer, die horizontale Position durch P[1] und die vertikale Position durch P[2]. |
PLOT_STRING |
Text |
|
Setzt oder ändert den Textinhalt für das zuletzt erstellte oder verschobene Textelement. |
PLOT_REMOVE |
Identifier |
|
Löscht das grafische Element mit der gegebenen Identifikationsnummer. |
PLOT_REMOVEALL |
0 |
|
Entfernt alle grafischen Elemente aus dem Chart. |
2000..2999 |
var |
|
Benutzerdefinierter Befehl mit einem einzelnen numerischen Parameter. |
3000..3999 |
P[8] |
|
Benutzerdefinierter Befehl mit einem Array von 8 var Parametern. |
4000..5999 |
char* |
|
Benutzerdefinierter Befehl mit einer Textzeichenkette. |
Parameters:
Befehl |
Eingabe, einer der Befehle aus der obigen Liste. |
Parameter |
Eingabe, Parameter oder Daten für den Befehl. Ein 32-bit int
oder Zeiger für 32-bit Plugins, oder ein 64-bit long int
oder Zeiger für 64-bit Plugins. |
Parameters, P |
Eingabe, Array von bis zu 8 vars für Befehle, die
mehrere Parameter setzen oder abrufen. |
Symbol |
Eingabe, char*, Broker-Symbol eines Assets (siehe Symbol).
Komplexe Symbole, wie für ausgewählte Optionskontrakte, können das
Basis-Asset, die Börse, das Ablaufdatum und andere Parameter im Namen kodiert haben,
wie unter IB Bridge beschrieben. |
Text |
Eingabe, char*, für Befehle, die eine Textzeichenkette erfordern. |
Returns:
0 wenn der Befehl vom Broker-Plugin nicht unterstützt wird, ansonsten die abzurufenden Daten.
brokerAsset (string Symbol, var* pPrice, var* pSpread, var *pVol)
Ruft die BrokerAsset Funktion mit dem gegebenen
Symbol (z.B. SymbolLive) auf und gibt den Preis, Spread und das Volumen zurück.
brokerAccount (string
Name, string AccountID, var *pBalance, var *pTradeVal, var *pMarginVal);
Ruft die BrokerAccount Funktion für den
Kontolisten Eintrag gegeben durch Name und eine optionale Konto-ID auf und gibt das Guthaben, den offenen Trade-Wert und die zugewiesene Margin zurück. Kann verwendet werden, um Kontoinformationen abzurufen, wenn mit
mehreren Brokern gehandelt wird.
brokerRequest (string
Path, string Method, string Data): string
Ruft die BrokerRequest Funktion für das Senden
beliebiger HTTP-Anfragen an die verbundene REST API auf. Path ist die
relative URL einschließlich der Abfragezeichenkette, aber ohne den Endpunkt-Root. Wenn
Method mit '$' beginnt, wird die Anfrage
signiert. Data ist der optionale Anfragekörper. Wenn keine spezifische
Method und kein Körper angegeben sind, wird eine GET Anfrage gesendet. Die Antwort wird zurückgegeben und kann ausgewertet werden.
brokerTrades (int Filter): int
Ruft den GET_TRADES Befehl auf. Storniert alle derzeit offenen Trades,
und ersetzt sie durch die offenen Positionen auf dem Broker-Konto (falls vorhanden).
Filter = 0 lädt alle Positionen,
Filter = 1 lädt nur Positionen, die zur Asset-Liste passen,
Filter = 2 lädt nur
Positionen von Assets, die bereits im Skript ausgewählt wurden,
Filter = 4 lädt nur Positionen des aktuellen Assets und verhindert das
vorherige Stornieren offener Trades. Fügen Sie 16 zu
Filter hinzu, um TradeUnits und
TradePriceOpen durch den Multiplier anzupassen,
wie es für Optionskontrakte mit einigen Broker APIs benötigt wird. Die Funktion gibt
die Anzahl der eingegebenen Positionen zurück. Sie kann
Skript-Trades mit dem Broker-Konto synchronisieren. Das Konto muss den
GET_TRADES Befehl unterstützen und nur offene Positionen vom aktuellen Zorro
Skript haben. Die enterTrade Funktion wird verwendet, um
die neuen Trades einzugeben. Die eingegebenen Trades sind einfach, ohne Exit-Limits, TMFs, Flags,
TradeVars oder andere Trade-Parameter, die nicht auf dem Broker-Konto gespeichert sind. Die Algo-Identifikatoren der Trades werden auf das aktuelle
Algo gesetzt. Für das korrekte Aktualisieren der Trades müssen alle Assets
im Skript verwendet worden sein.
Bemerkungen:
- Befehle, die mit intern markiert sind, werden
automatisch von Zorro an das Broker-Plugin gesendet. Sie müssen normalerweise nicht im
Skript verwendet werden. Die anderen Befehle werden von Zorro nicht verwendet und sind im Skript verfügbar.
Wenn ein Befehl nicht unterstützt wird, gibt er 0 zurück. Welche Befehle unterstützt werden, kann auf der Beschreibungsseite des Broker-Plugins gefunden werden.
- Der SET_PATCH Befehl wird immer unterstützt, da
er auf der Zorro-Seite behandelt wird. Er lässt Zorro Konto- und Trade-Parameter schätzen, anstatt
die Werte von der Broker-API zu verwenden. Dies ist erforderlich, wenn die Broker-API diese Parameter falsch berechnet, wie
es bei den Kontoständen, der Equity und dem offenen Trade-Profit in
einigen FXCM API-Versionen der Fall war. Das Ersetzen dieser Parameter hat keinen Einfluss auf das Trading, sondern auf die angezeigten Equity- und Profitwerte im Zorro-Panel. Die geschätzte Equity umfasst nur den Profit durch Trades der aktuellen Strategie und ist daher anders als die Konto-Equity, wenn andere Systeme auf demselben Konto handeln. Das geschätzte Trade-Ergebnis kann auch vom realen Ergebnis abweichen aufgrund von Slippage und Rollover.
- Um die Unterbrechung einer
Befehlssequenz durch eine andere Zorro-Instanz zu verhindern - z.B. zum
Setzen von Order-Parametern vor dem Senden der Order - verwenden Sie entweder den SET_LOCK Befehl
(wenn verfügbar) oder die
lock Funktion. Sie funktionieren wie ein Windows Mutex. Vor der Sequenz,
verwenden Sie while(0 == brokerCommand(SET_LOCK,1)) wait(5);
um zu warten, bis die Sperre freigegeben wurde, und setzen sie dann.
Danach gibt brokerCommand(SET_LOCK,0) die Sperre nach dem Senden der Befehlssequenz frei.
Wenn SET_LOCK vom Plugin nicht unterstützt wird, verwenden Sie die
lock/unlock Funktionen ähnlich, um den Code-Teil zu sperren.
- Wenn das Skript mit mehreren
Brokern verbunden ist, werden Befehle an den Broker gesendet, der dem aktuellen Asset zugeordnet ist (SourceTrade).
- Optionsketten durch
GET_OPTIONS oder GET_FOP werden mit den folgenden Daten aus der
CONTRACT Struktur gefüllt, die in
include\trading.h definiert ist:
time: eine nullterminierte Zeichenkette von bis zu 7 Zeichen, die das
Handelsklassen-Symbol enthält (falls verfügbar) fAsk,
fBid: die Ask- und Bid-Preise (falls verfügbar) fStrike: der Strike-Preis
fVal: der Multiplikator (falls verfügbar)
Expiry: das Ablaufdatum im YYYYMMDD
Format Type: der Vertragstyp,
PUT, CALL, FUTURE, EUROPEAN, BINARY; optional ein
Börsenkennung in den oberen 16 Bits codiert.
- Trade-Arrays durch
GET_TRADES werden mit den folgenden Positionsdaten gefüllt (die
TRADE Struktur ist in
include\trading.h definiert):
nId: einen
eindeutigen Trade-Identifier (falls verfügbar) nLots: die
Positionsmenge flags: TR_SHORT
für Short-Positionen
fEntryPrice: den durchschnittlichen Einstiegspreis, falls verfügbar;
einige Broker (IB) multiplizieren den Einstiegspreis mit dem Options
Multiplikator.
fStrike: den Strike-Preis, falls anwendbar
tExitDate: das Ablaufdatum im
DATE Format (falls anwendbar) nContract: den Vertragstyp
falls anwendbar, d.h. PUT oder CALL; optional eine
Börsenkennung in den oberen 16 Bits codiert. Wenn die
FUTURE, EUROPEAN, BINARY
Flags nicht über die Broker-API verfügbar sind, müssen sie vom Skript gesetzt werden. sInfo:
das Handelsklassen-Symbol (falls anwendbar)
- Variablen oder Texte, die mit brokerCommand
gesetzt wurden, behalten ihren Inhalt bis sie durch einen anderen brokerCommand geändert werden.
Achten Sie darauf, wenn eine vorherige Handelsrunde diesen
Befehl verwendet hat, um eine Variable oder einen Text zu setzen.
- Wenn die Broker-API keine Informationen über Trades bereitstellt - wie es
bei den meisten NFA-konformen APIs der Fall ist - stellen Sie sicher, dass Sie die
Trades auf der Zorro-Seite und der Broker-Seite synchron halten. Schließen Sie
Positionen oder stornieren Sie Orders nicht nur auf einer Seite.
- Wenn die Broker-API einen bestimmten
Ordertyp unterstützt, gibt das Plugin den Ordertyp beim SET_ORDERTYPE
Befehl zurück; andernfalls gibt es 0 zurück.
- SET_ORDERTYPE >= 8 platziert eine
separate Stop-Order, wenn vom Broker unterstützt.
Abhängig vom Verhalten der Broker-API,
könnte diese Order aktiv bleiben, auch wenn der ursprüngliche Trade geschlossen wurde.
In diesem Fall stornieren Sie sie manuell: Senden Sie einen DO_CANCEL
Befehl mit der Stop-Order Trade ID, die normalerweise die ursprüngliche
Trade ID +1 ist. Andernfalls könnte die Stop-Order offen bleiben und eine
unerwünschte Position in entgegengesetzter Richtung auslösen.
- Nicht alle Preisarten werden
mit allen Assets unterstützt. Überprüfen Sie bei Ihrem Broker, welche Preisarten unterstützt werden, und stellen Sie sicher, dass Sie SET_PRICETYPE
nur verwenden, wenn es für das ausgewählte Asset verfügbar ist. Andernfalls lassen Sie es bei 0.
- Einige Befehle senden einen 32-bit Zeiger als Parameter, zum Beispiel um
einen String oder ein oder mehrere
double Variablen an das Plugin zu übergeben. Das Broker
Plugin kann diesen dann in den erforderlichen Typ für den Zugriff auf den
Inhalt umwandeln, z.B. double NewLotAmount = *(double*)Parameter;
- Benutzerdefinierte Befehle für spezielle Broker-API-Einstellungen
können mit einer Befehlsnummer >
2000 definiert werden. Nummern unter 2000 sind für vordefinierte Befehle reserviert.
Beispiele:
brokerCommand(SET_COMMENT,strf("Algo %s",Algo)); // setze einen Kommentar
brokerCommand(SET_PATCH,16+32); // nehme Swap, Kommission, Hebel aus der Asset-Liste
var Greeks[5];
contractPrice(ThisContract);
brokerCommand(GET_GREEKS,Greeks); // hole Greeks des aktuellen Kontrakts
// Alle Positionen aus einer Asset-Liste lesen ///////////////////////
void main()
{
assetList("AssetsFix");
string Name;
while(Name = loop(Assets)) {
var Position = brokerCommand(GET_POSITION,Name);
printf("\n%6.4f %s",Position,Name);
if(!wait(10)) break;
}
}
// lese und drucke das Orderbuch
void main()
{
static T2 Quotes[MAX_QUOTES];
brokerCommand(SET_SYMBOL,"AAPL");
int i,N = brokerCommand(GET_BOOK,Quotes);
printf("\nOrderbook: %i quotes",N);
for(i=0; i<N; i++)
printf("\nPrice %.2f Vol %.2f",(var)Quotes[i].fVal,(var)Quotes[i].fVol);
}
// lese JSON-Datenstring von der Coinigy REST API
void main()
{
brokerCommand(SET_BROKER,"GDAX");
static char Buffer[MAX_BUFFER];
strcpy(Buffer,"#data "); // Zielpunkt
strcat(Buffer,"{\n\"exchange_code\": \"GDAX\",");
strcat(Buffer,"\n\"exchange_market\": \"BTC/USD\",");
strcat(Buffer,"\n\"type\": \"bids\"\n}");
int Size = brokerCommand(GET_DATA,Buffer);
if(Size)
printf("\nResponse: %s",Buffer);
}
// Verwende Zorros HTTP-Funktionen in einem REST API Plugin
int (__cdecl *http_send)(const char* url,const char* data,const char* header) = NULL;
long (__cdecl *http_status)(int id) = NULL;
long (__cdecl *http_result)(int id,char* content,long size) = NULL;
int (__cdecl *http_free)(int id) = NULL;
...
DLLFUNC double BrokerCommand(int command,intptr_t parameter)
{
switch(command) {
case SET_FUNCTIONS: {
FARPROC* Functions = (FARPROC*)parameter;
(FARPROC&)http_send = Functions[139];
(FARPROC&)http_status = Functions[142];
(FARPROC&)http_result = Functions[143];
(FARPROC&)http_free = Functions[144];
return 1.;
}
...
}
return 0.;
}
Siehe auch:
Broker, Broker-Plugin, MT4 Bridge, FXCM Plugin, IB Plugin,
Oanda Plugin
► neueste
Version online
|