by admin » Fri Feb 27, 2009 8:09 pm
For bridge we use a script that checks all orders asynchronously, but we can use synchronously direct calls from expert advisor.
This almost completely eliminates the delays.
Parameters for the direct calling from the mt4 expert advisor (Bridge Metatrader4 -MBTrading Terminal)
int MBTLogin(int iId, string pszName, string pszPassword, int timeout = 10);
Function make logon to MBT.
Parameters:
iId int; User Identifier.
pszName String; User Name.
pszPassword String; User Password.
timeout int; tick time to logon delay (default 10);
int MBTConnected(string pszAccount);
Function check on MBT account connected;
Parameters:
pszAccount String; Account Number.
int CancelOrder(string pszAccount, string pszTradeID);
Function submits a request to cancel an existing open order
Parameters:
pszAccount String; Account Number.
pszTradeID String; Order Number.
int NewOrder(string pszAccount, string pszSymbol, string pszAction, int iQuantity,
string pszOrderType, double fStop, double fLimit, string pszDesc);
Function submits a request to enter a new order and returns order TradeID.
Parameters:
pszAccount String; Account Number.
pszSymbol String; Traded symbol.
pszAction String; Action "BUY", "SELL".
iQuantity int; Number of equity.
pszOrderType String; Order type "MARKET", "LIMIT", "STOP", "STOP LIMIT".
fStop: Stop price.
fLimit: Limit price.
pszDesc String; destination for the order.
int ChangeOrder(string pszAccount, string pszSymbol, string pszAction, int iQuantity,
string pszOrderType, double fStop, double fLimit, string pszDesc,
string pszTradeID);
Function submits request to change an existing order with updated parameters.
Parameters is corresponds to the function NewOrder, pszTradeID is a order number.
int SubmitOrder(int iBuySell, int iVolume, string pszSymbol, double dPrice1, double dPrice2,
double dPrice3, double dPrice4, int iOrdType, string pszDesc);
Function SubmitOrder submits a request to enter a new order.
Parameters:
lBuySell Long; enter 10000 (VALUE_BUY), 10001 (VALUE_SELL), or 10002 (VALUE_SELLSHT)
lVolume Long; number of equity shares, options contracts, or futures contracts to transact.
For a forex order, enter 10000 for a mini-lot and 100000 for a full-sized lot
(the SDK accepts single shares, not full lot sizes like the retail Navigator).
Entering 10000 for a mini-lot in the SDK is equivalent to entering 1 for a
mini-lot in the retail Navigator (entering 1 in the SDK is the equivalent of
entering 0.0001 in the retail Navigator).
bstrSymbol String; the security being traded, e.g. "MSFT" for equities, "/YMqy" for futures
(where q = quarter, y = year; e.g. "/YMU7"), "EUR/USD" for forex.
dPrice1 Double; limit price for limit orders, "approximate" price for market orders. Must
always be supplied, even for market orders.
dPrice2 Double; stop/trigger price for Stop Limit, Stop Market, Limit+Stop, Stop trail and
Stop TTO orders (otherwise, pass zero).
dPrice3 Double; discretionary price for Discretionary orders; lower threshold for TTO VALUE_BUY
orders (upper threshold for VALUE_SELL/VALUE_SELLSHT). Trailing stop price for
plus orders.
dPrice4 Double; lower threshold for TTO VALUE_BUY orders (upper threshold for
VALUE_SELL/VALUE_SELLSHT). See TTOs for an example.
iOrdType Long; type of order being placed, i.e., VALUE_LIMIT, VALUE_MARKET, etc. See the
complete list of order types here or on our website.
pszDesc String; destination for the order. Valid values can be seen in the retail Navigator
by entering a symbol and right clicking on the Routes button ("MBTX").
If SubmitOrder returns S_OK (0), if order token and passes it to the order server else
return error;
int ReplaceOrder(string pszOrdNum, int iQuant, int iOrdType; double dPrice1, double dPrice2,
double dPrice3, double dPrice4);
Function ReplaceOrder is request to replace an existing order with updated parameters.
Parameters is corresponds to the function SubmitOrder;