1. CancelOrder (OrdID As Long) As Long
Cancels an order.
Parameters:
OrdID - the ID of the order that will be cancelled.
Result:
If the returned value is equal to the OrdID, then the order has been cancelled.
A negative result indicates an error and contains the error number
(see the
Error Description Table).
Example: CancelOrder (12345678) - 12345678 (order is cancelled).
CancelOrder (12345678) - (-8). Error: Market is closed
2. CancelOrder_ASync (OrdID As Long, RequestID As Long, errNumber As Long)
Asynchronous function for cancelling an order. The function sends a cancellation request and
returns a request ID. When the order has been cancelled the callback function "CancelOrderExecuted"
is executed, where you can check the result.
It returns two parameters: RequestID and errNumber, which have to be passed by reference.
RequestID - a unique ID which allows you to track the order status
in the callback function. errNumber contains error information.
Parameters:
OrdID - the ID of the order that will be cancelled.
RequestID - the cancellation request ID used in the callback fucntion to track the order status
errNumber - the parameter specifies whether the asynchronous request was successful: 0 if OK and a negative number otherwise
(see the Error Description Table).
Result:
RequestID - the ID of the cancellation request
errNumber - returns an error number in case of failure or 0 otherwise (see Error Description
Table).
Example: CancelOrder_ASync (12345678, RequestID1, errNumber1)
RequestID1 - 453628
errNumber1 - 0
...
The callback function
CancelOrderExecuted (RequestID As Long, OrdID As Long) is called if the order has been successfully cancelled.
If there was a problem or an error while cancelling the order, the callback function
ErrorRaise(ByVal ReqID_Err As Long, ByVal ErrNumber_Err As Long, ByVal ErrDescription_Err As String) is called,
from which you can find out the reason for failure.
3. ClosePosition (Instrument As String) As Long
Closes the position on the specified Instrument.
Parameters::
Instrument - the instrument symbol
Result::
When successfull the function returns 1.
A negative number indicates an error, which can be found in the Error Description Table).
Example: ClosePosition("EUR/USD") - 1 (position is closed)
4. GetAccSum (InCurrency As String, errNumber As Long) as Double
Returns the current account balance in the specified currency
The error information is returned in errNumber. It should be
defined in advance and passed by reference to the function.
Parameters:
InCurrency - currency symbol (Example: InCurrency = "EUR").
errNumber - the result of the function. 0 indicates success and a negative number - failure (see the Error Description
Table).
Example:
GetAccSum ("USD", errNumber1) - 2345.33 (in USD)
errNumber1 = 0 - success.
5. GetAccSum_S (InCurrency As String)
For use with scripting languages. Returns the current account balance in the specified currency.
The result is returned in a string with the following format: RES2345.33 *ERR0*.
The figure after the "RES" mark is the amount and the number after the "ERR" mark contains the
error or success code.
If the function fails, the error code is a negative number and is 0 otherwise.
Use the function GetParam to parse the result.
Result:Returns the account balance in a string
Parameters:
InCurrency - currency symbol (Example: InCurrency = "EUR").
Example:
GetAccSum_S ("USD") - Result - RES2345.33 *ERR0*
GetParam("RES", Result) - returns 2345.33
GetParam("ERR", Result) - returns 0 (success)
6. GetChartData (Instrument As String, iTypeInter As
String, fname As String, DateFrom As Double, DateTo As Double, errNumber As
Long) As Long
Exports chart data to a file.
Parameters:
Instrument - instrument code
iTypeInter - time period:
| "1" - 1 min. |
"5" - 5 min. |
"30" - 30 min. |
"60" - 1 hour |
| "4" - 4 hours |
"24" - 1 day |
"7" - 1 week |
"33" - 1 month |
Returns 0 in errNumber when successfull and negative value otherwise
Fname - the name of the file where the data will be exported - for example: C:\chart\eurusd5.txt (the path to the file must
be created in advance!);
DateFrom - marks the start of the export period
DateTo - marks the end of the export period.
Both dates should be doubles. Use the function ConvertDateToDouble(Date as String) to convert the dates before passing them.
errNumber - error number (see Error Description
Table)
Example:
GetChartData("EUR/USD", "24", "C:\chart\eurusd5.txt", 234242.2246, 353535.666, errNumber1) - 1
errNumber1 = 0 - indicates success
The data is exported to a comma delimited file with the following format:
<date>, <open>, <hi>, <low>,
<close>, <volume> crlf
NOTE - Do not specify the time part of the second date. By default it is 23:59:59
and at the moment it can not (and should not) be changed.
7. GetChartData_S (Instrument As String, iTypeInter As String, fname As String, DateFrom As Double, DateTo As Double) As Long
For use with scripting languages. Exports chart data to a file.
Parameters:
Instrument - instrument code
iTypeInter - interval:
| "1" - 1 min. |
"5" - 5 min. |
"30" - 30 min. |
"60" - 1 hour |
| "4" - 4 hours |
"24" - 1 day |
"7" - 1 week |
"33" - 1 month |
Fname - file name - for example: "C:\chart\eurusd5.txt" (Note that the path to the file must exist);
DateFrom - a date, which marks the start of the export period;
DateTo - a date, which marks the end of the export period;
Both dates should be doubles. Use the function ConvertDateToDouble(Date as String) to convert the dates before passing them.
Result: The result is returned in a string with the following format: RES1*ERR0. The parameters can be obtained via the
function GetParam. ERR is 0 if the export was successfull and a negative number otherwise.
Example::
GetChartData_S("EUR/USD", "24", "C:\chart\eurusd5.txt", 234242.2246, 353535.666) - result "RES1*ERR0"
GetParam("RES", Result) = 1
GetParam("ERR", Result) = 0
The resulting file is comma delimited and is in the following format:
<date>, <open>, <hi>, <low>,
<close>, <volume> crlf
NOTE - Do not specify the time part of the second date. By default it is 23:59:59
and at the moment it can not (and should not) be changed.
8. GetErrDescription (ErrorNumber As Long) As String
Returns the error description corresponding to the error number.
Example: GetErrDescription (-10) -> "-10 - CFD trading not authorized."
9. GetUsedMargin (InCurrency As String, errNumber As Long) As Double
Returns the used margin in the specified currency.
Parameters:
InCurrency - the currency in which the result is calculated. (Example: InCurrency = "EUR");
errNumber - If the function succeeds, the return value is 0.
If the function fails, the return value is a negative number.
To get extended error information call GetErrDescription or see the error
description table)
Example:
GetUsedMargin ("USD", errNumber) - 1403.34 USD
errNumber - 0
10. GetUsedMargin_S (InCurrency As String) As String
Returns the used margin in the specified currency. For use with scripting languages.
Returns a string in the following format: RES<result>*ERR<err number or 0>* containing the result.
Parameters:
InCurrency - the currency in which the result is calculated (Example: InCurrency = "EUR");
Example:
GetUsedMargin ("USD") - returns the string "RES1403.34 *ERR0*". Use the function GetParam to obtain the two parameters -
the result and the error information.
GetParam("RES", Result) - 1403.34
GetParam("ERR", Result) - 0
To get extended error information call GetErrDescription or see the error
description table
11. GetFreeMargin (InCurrency As String, errNumber As Long) as Double
Returns the free margin in the specified currency.
Parameters:
InCurrency -
the currency in which the result is calculated (Example: InCurrency = "EUR")
errNumber - If the function succeeds, the return value is 0,
otherwise the return value is a negative number. To get extended error information call GetErrDescription or see
see the
Error Description Table.
Example:
GetFreeMargin ("USD", errNumbe1) - 5431. 31 (in USD)
errNumbe1 - 0
12. GetFreeMargin_S (InCurrency As String)
Returns the free margin in the specified currency. For use with scripting languages.
Returns a string in the following format: RES<result>*ERR<err number or 0>* containing the result. Use the function GetParam to parse the string and get the two parameters.
Parameters:
InCurrency - The currency in which the result is calculated (Example: InCurrency = "EUR")
Example:
GetFreeMargin_S("USD", errNumbe1) - returns RES5431.31 *ERR0*
GetParam("RES", Result) - Result 34324.44 USD
GetParam("ERR", Result) - Result 0 - the function succeeded
13. GetOrdList_Async (Instrument As String, ordStatus As Long,
ordType As Long, ordBuySell As String, ordDate1 As Double, ordDate2 As Double,
RequestID As Long, errNumber As Long)
This is an asynchronous function which returns a filtered list of orders.
The list can be filtered by various parameters.
When called, the function sends a request to the server to get the list.
Each individual order is returned by
the callback function GetOrdListExecuted. The function is called back every time an item of the list arrives.
Result:
Returns two parameters: RequestID and errNumber. Use RequestID with the callback function to track the status of the request.
If the function succeeds, the return value is 0,
otherwise the return value is a negative number. To get extended error information call GetErrDescription or see
see the Error Description Table.
Parameters:
Instrument - Instrument symbol (Example: "EUR/USD"). Can be left blank, in which case it is ignored.
ordStatus - order status 1 - ordered, 2 - confirmed, 3 - completed, 4 - cancelled, 5 - awaiting cancellation; CANNOT NOT BE LEFT BLANK.
ordType - order type: 1 - market, 2 - limit, 3 - stop, 4 - One cancels the other (OCO); - CANNOT BE LEFT BLANK.
ordBuySell - buy - 'B' or sell - 'S'; Can be left blank, in which case it is ignored.
ordDate1 - Starting date; CANNOT NOT BE LEFT BLANK
ordDate2 - end date: CANNOT NOT BE LEFT BLANK
RequestID - A return parameter to track the status of the request
errNumber - error number (see Error Table)
Example:
GetOrdList_Async ("EUR/USD", 3, 2, "B", 01.01.2010, 30.01.2010, RequestID1, errNumber1)
RequestID1 - 242334
errNumber1 - 0
...
The result is returned by the function
GetOrdListExecuted:
(RequestID As
Long, OrdID As Long, Instrument As String,
ordStatus As Long, ordType As
Long, ordBuySell As String,
ordDate1 As Double, ordDate2 As Double, ordCount
As Double,
ordPrice As Double, ordPrice1 As Double, errNumber As Long)
RequestID - the ID of the request returned by GetOrdList_Async;
OrdID - the order ID;
Instrument - instrument symbol;
ordStatus - order status: 1 - ordered, 2 - confirmed, 3 - completed, 4 - canceled, 5 - awaiting cancellation;
ordType - order type: 1 - market, 2 - limit, 3 - stop, 4 - One Cancels the Other (OCO);
ordBuySell - buy - "B" or sell - "S";
ordDate1 - the date the order was placed. The date is a double. Use the function ConvertDoubleToDate to get the date in a string;
ordDate2 - the date the order status was last changed converted to Double. Use the function ConvertDoubleToDate to get the date in a string;
ordCount - order volume;
ordPrice - order price;
ordPrice1 - order placed price;
errNumber - error number, (see the Error Description
Table) to get extended error information
14. GetOrdStatus (OrdID As Long) As Long
Returns the status of the order with ID = OrdID
Parameters:
OrdID - the order ID
Result: Returns an integer. If the returned value is a positive number, it denotes the status of the order as follows:
1 - ordered, 2 - confirmed, 3 - executed, 4 - canceled, 5 - awaiting cancellation;
A negative number indicates an error (see the Error Description Table).
Example: GetOrdStatus (12345678) - 3 (completed).
15. GetOrdStatus_S(OrdID As Long)
Returns the status of the order with ID = OrdID. For use with scripting languages.
Parameters:
OrdID - the order ID
Result: Returns an integer. If the returned value is a positive number,
then the function was successfull and it denotes the status of the order as follows:
1 - ordered, 2 - confirmed, 3 - completed, 4 - canceled, 5 - awaiting cancellation;
A negative number indicates an error (see the Error Description Table).
Example: GetOrdStatus_S (12345678) - 3 (completed).
16. GetPosition (Instrument As String, Count As Double, Price As
Double, errNumber As Long)
Returns the size and the average price of a position.
Parameters:
Instrument - instrument symbol(Example: "EUR/USD");
Count - variable in which position size is returned. Should be passed by
reference;
Price - variable in which the average price of the position is returned
errNumber - if 0 then the function was successfull.
A negative number indicates an error, which can be found in (see the Error Description Table)
Example:
GetPosition ("USD/JPY", "USD", errNumber1)
errNumber1 - 0
Result:
Count - 10 000;
Price - 89.4250
17. GetPosition_S (Instrument As String) as String
Returns position's size and the average price. For use with scripting languages
Parameters:
Instrument instrument symbol(Example: "EUR/USD");
Result - returns a string containing the the return values. Use the function GetParam to parse the string and get the parameters.
Example
GetPosition_S ("USD/JPY")
Result: CNT1000*PR1.2567*ERR0
CNT the figure after the "CNT" mark is the position size.
PR the figure after the "PR" mark is the average price.
ERR the error NUMBER (see the Error Description Table).
GetParam("CNT", "CNT1000*PR1.2567*ERR0") - 1000
GetParam("PR", "CNT1000*PR1.2567*ERR0") - 1.2567
GetParam("ERR", "CNT1000*PR1.2567*ERR0") - 0
18. GetPositionRes (Instrument As String, InCurrency As String,
errNumber As Long) As Double
Returns the current P/L of a position in the specified currency.
Parameters:
Instrument - position's instrument (Example: Instrument= "EUR/USD");
InCurrency - currency in which the result is calculated (Example:
InCurrency = "EUR");
errNumber - if 0, the function was successfull,
a negative number indicates an error, which can be found in the Error Description Table
Result:
Returns the P/L of the specified position
Example:
GetPositionRes ("EUR/USD", "EUR", errNumber1) - 34324.44 (in "EUR")
errNumber1 - 0
19. GetPositionRes_S (Instrument As String, InCurrency As
String) As String
Returns the current P/L of a position in the specified currency. For use with scripting languages
Parameters:
Instrument - position's instrument (Example: "EUR/USD");
InCurrency - currency in which the result is calculated (Example:
InCurrency = "EUR");
Result: Returns a string containing the return values. The string is in the following format "RES34324.44 *ERR0*".
Use the function GetParam to parse the string and get the return values. The figure after the "RES" mark is
the current P/L of the position and the number after the
the "ERR" shows whether the function was successful (0) or not (a negative value)
Example:
GetPositionRes_S ("EUR/USD", "EUR") -> RES34324.44 *ERR0*
GetParam("RES", "RES34324.44 *ERR0*") -> 34324.44 EUR
GetParam("ERR", "RES34324.44 *ERR0*") -> 0 (error number)
20. GetPositionsRes (InCurrency As String, errNumber As Long)
As Double
Returns the total P/L of all open positions in the specified currency.
Parameters:
InCurrency - currency in which the result is calculated (Example:
InCurrency = "EUR");
errNumber - this return parameter shows whether the function was successful (0) or not (a negative value)
See the Error Description Table to get extended error information.
Result:
Returns a double, containing the total P/L of all open positions calculated in the specified currency.
Example:
GetPositionRes ("EUR" , errNumber1) -> 34114.44 (in "EUR")
errNumber1 - 0
21. GetPositionsRes_S (InCurrency As String) As
String
Returns the current total P/L of all open positions in the specified currency. For use with scripting languages
Parameters
:
InCurrency - currency in which the result is calculated (Example:
InCurrency = "EUR")
Result: Returns a string containing the P/L and the error information. Use the function GetParam to parse the string and get the return values.
The current total P/L of all open positions in the specified currency.
Example:
GetPositionsRes ("EUR") - Result RES34114.44*ERR0*
GetParam("RES", "RES34114.44*ERR0*") - Result 34114.44 EUR
GetParam("ERR", "RES34114.44*ERR0*") - Result ErrorNumber - 0
22. GetQuote (Instrument As String QBid As Double, QAsk As
Double, QHi As Double, QLow As Double, errNumber As Long)
Returns the current quotes for the specified instrument.
Parameters:
Instrument - instrument symbol (Example: "EUR/USD")
QBid, QAsk, QHi, QLow, ErrNumber - Bid, Ask, High, Low, error. The
parameters should be passed by reference.
Result:
Returns the current bid, ask and the daily hi and low values for the specified instrument.
ErrNumber indicates weather the function call was successful - 0 or not - a negative number. See the Error Description Table
Example:
GetQuote ("USD/GBP", QBid1, QAsk1, QHi1, QLow1, ErrNumber1)
QBid1 - 1.3681
QAsk1 - 1.3684
QHi1 - 1.3689
QLow1 - 1.3680
ErrNumber1 - 0 (successfull call)
23. GetQuote_S (Instrument As String)
Returns the current quotes for the specified instrument. For use with scripting languages.
Parameters:
Instrument - instrument symbol (Example: "EUR/USD")
Result: - returns the current bid, ask and the daily hi and low values for the specified instrument.
The result is returned in a single string with the following format: BID1.3681*ASK1.3684*HI1.3689*LOW1.3680*ERR0*.
Use the function GetParam to parse the string and get the return values.
Example:
GetQuote ("USD/GBP") - Result = BID1.3681*ASK1.3684*HI1.3689*LOW1.3680*ERR0*
GetParam("BID", Result) - 1.3681
GetParam("ASK", Result) - 1.3684
GetParam("HI", Result) - 1.3689
GetParam("LOW", Result) - 1.3680
GetParam("ERR", Result) - 0
24. GetTotalResult (InCurrency As String, errNumber As Long) As Double
Returns the account equity in the specified currency
Parameters:
InCurrency - currency in which the result is calculated (Example: InCurrency = "EUR");
errNumber - a parameter, in which the error information is returned. 0
indicates successful execution, a negative number indicates an error - see The error description table.
Example:
GetTotalResult ("USD" , errNumber1) = 5307.23
errNumber1 = 0
25. GetTotalResult_S(InCurrency As String) As String
Returns the account equity in the specified currency. For use with scripting languages.
Parameters:
InCurrency - currency in which the result is calculated (Example: InCurrency = "EUR");
Result:The result is returned in a single string with the following format: "RES5307.23 *ERR0*".Use the function GetParam to parse the string and get the return values.
Example:
GetTotalResult ("USD") - Result - RES5307.23 *ERR0*
GetParam("RES", Result) - 5307.23
GetParam("ERR", Result) - 0
26. NewOrder (Instrument As String, ordCount As Long,
ordPriceReq1 As Double, ordPriceReq2 As Double, ordType As Long, ordBuySell As
String, ordValidity As String) As Long
Places a new order.
Parameters:
Instrument - instrument symbol (Example: "EUR/USD");
ordCount - the order volume in units (not lots!);
ordPriceReq1 and ordPriceReq2 are as follows:
The parameter
ordPriceReq2: is only used for OCO orders, otherwise should be set to 0.
ordPriceReq1:
- If we are placing a market order, ordPriceReq1 and ordPriceReq2 should be 0. The order is executed at the current market price;
- If we are placing a LIMIT BUY order, ordPriceReq1 should be <= current BID price - 1/2*SPREAD
- If we are placing a LIMIT SELL order, ordPriceReq1 should be >= current ASK price + 1/2*SPREAD
- If we are placing a STOP SELL order, ordPriceReq1 should be <= current BID price - 1/2*SPREAD
- If we are placing a STOP BUY order, ordPriceReq1 should be >= current ASK price + 1/2*SPREAD
ordPriceReq2: - The parameter is used for OCO (one-cancels-the-other) orders only;
If we are placing an OCO BUY order, ordPriceReq1 is the price of a STOP BUY order and ordPriceReq2 is the price of a LIMIT BUY order
- ordPriceReq1 should be >= ASK + 1/2*SPREAD and
- ordPriceReq2 should be <= BID - 1/2*SPREAD
If we are placing an OCO SELL order, ordPriceReq1 is the price of the LIMIT SELL order and ordPriceReq2 is the price of the STOP SELL order
- ordPriceReq1 should be >= ASK + 1/2*SPREAD and
- ordPriceReq2 should be <= BID - 1/2*SPREAD
ordType - order type: 1 - market, 2 - limit, 3 - stop, 4 - OCO;
ordBuySell - 'B' - buy, 'S' - sell;
ordValidity - string showing the order validity: '1' - valid until the end of the day, '2' - valid until cancelled.
Result:
Returns the ID of the ticket assigned to the order by the server. If the result is a negative number, that indicates an error.
Example:
NewOrder ("EUR/USD", 10000, 0, 0, 1, "B", 2) - market order buy 10 lots (10000) "EUR/USD" validity: until cancelled
NewOrder ("EUR/USD", 10000, 1.3680, 0, 2, "S", 2) - limit order sell 10 lots (10000) "EUR/USD" at 1.3680, validity: until cancelled
27. NewOrder_Async (Instrument As String, ordCount As Long,
ordPriceReq1 As Double, ordPriceReq2 As Double, ordType As Long, ordBuySell As
String, ordValidity As String, RequestID As Long, errNumber As Long)
Places an order to get executed asynchronously. The function
returns a result as soon as the order was sent to the server.
An ID is assigned to the request, which then is used to further track the execution of the order.
When it gets executed,
the call-back function NewOrderExecuted(ByVal ReqID_NOE As Long, ByVal ordID_NOE As Long, ByVal ordStatus_NOE As Long, ByVal errNumber As Long)
is called.
Result:
If successfull, the function returns 0 and sends the order to get executed, otherwise returns a negative number.
Check the
The error description table to get extended error information. The parameter RequestID is used to further track the execution of the order.
Parameters:
Instrument - instrument symbol (Example: "EUR/USD");
ordCount - the order volume in units (not lots!);
ordPriceReq1 and ordPriceReq2 are as follows:
The parameter
ordPriceReq2: is only used for OCO orders, otherwise should be set to 0.
ordPriceReq1:
- If we are placing a market order, ordPriceReq1 and ordPriceReq2 should be 0. The order is executed at the current market price;
- If we are placing a LIMIT BUY order, ordPriceReq1 should be <= current BID price - 1/2*SPREAD
- If we are placing a LIMIT SELL order, ordPriceReq1 should be >= current ASK price + 1/2*SPREAD
- If we are placing a STOP SELL order, ordPriceReq1 should be <= current BID price - 1/2*SPREAD
- If we are placing a STOP BUY order, ordPriceReq1 should be >= current ASK price + 1/2*SPREAD
ordPriceReq2: - The parameter is used for OCO (one-cancels-the-other) orders only;
If we are placing an OCO BUY order, ordPriceReq1 is the price of a STOP BUY order and ordPriceReq2 is the price of a LIMIT BUY order
- ordPriceReq1 should be >= ASK + 1/2*SPREAD and
- ordPriceReq2 should be <= BID - 1/2*SPREAD
If we are placing an OCO SELL order, ordPriceReq1 is the price of the LIMIT SELL order and ordPriceReq2 is the price of the STOP SELL order
- ordPriceReq1 should be >= ASK + 1/2*SPREAD and
- ordPriceReq2 should be <= BID - 1/2*SPREAD
ordType - order type: 1 - market, 2 - limit, 3 - stop, 4 - OCO;
ordBuySell - 'B' - buy, 'S' - sell;
ordValidity - string showing the order validity: '1' - valid until the end of the day, '2' - valid until cancelled.
Example:
NewOrder ("EUR/USD", 10000, 0, 0, 1, "B", 2) - Market price order buys 10
lots(10000) "EUR/USD" validity: until cancelled;
NewOrder ("EUR/USD", 10000, 1.3680, 0, 2, "S", 2) - limit sells 10
lots(10000) "EUR/USD" at 1.3680, validity: until cancelled.
28. GetOrdParams (OrdID As Long, errNumber As Long) As
String
Returns a string containig various parameters of the order with ID = ordID
The different parameters are marked in the string as follows:
ST - order status
I - instrument
CNT - order volume
PR - execution price
P1 - placed price
P2 - second price (for OCO orders)
BS - operation (BUY or SELL)
TY - order type - market=1/limit=2/stop=3/oco=4
Use GetParam(String key, String src_str) get the individual values.
Parameters:
OrdID - order ID.
errNumber - 0 when successful or a negative number otherwise (see the Error Description
Table)
Example:
GetOrdParams(467298, errNumber)
Result - *IAUD/NZD*CNT1000*PR1.23424*ST3*BSB
GetParam("I", Result) - Instrument: AUD/NZD
GetParam("CNT", Result) - Quantity: 1000
GetParam("PR", Result) - Price: 1.23424
GetParam("ST", Result) - Status: 3
GetParam("BS", Result) - Buy/Sell: B
29. GetOrdParams_S(OrdID As Long) As String
Returns the instrument ID, price, status and the type of an order -
Buy/Sell.
Parameters:
OrdID - order number.
Example:
GetOrdParams_S(467298, errNumber)
Result - *IAUD/NZD*CNT1000*PR1.23424*ST3*BSB*ERR0
GetParam("I", Result) - Instrument: AUD/NZD
GetParam("CNT", Result) - Quantity: 1000
GetParam("PR", Result) - Price: 1.23424
GetParam("ST", Result) - Status: 3
GetParam("BS", Result) - Buy/Sell: B
GetParam("ERR", Result) - Error: 0
30. GetClnNum() As String
Returns the client number.
Example:
GetClnNum() - Result - "000102310"
31. GetApiVersion() As String
Returns the version of the Delta Trading API.
Example:
GetApiVersion() - Result - "1.0.41"
32. GetDTVersion() As String
Returns the version of the Delta Trading platform.
Example:
GetDTVersion() - Result - "4.0.12"
33. GetParam(strKey as String, strExpr as String) As
String
The functions designed to work with scripting languages pack the return parameters in a single string.
GetParam is a helper function, wich can be used to parse the
string and return each individual parameter.
Parameters:
strKey - the name of the parameter we want;
strExpr - the string to be parsed.
Example:
GetParam("CNT", "*IAUD/NZD*CNT1000*PR1.23424*ST3*BSB*ERR0") -
here we want the "CNT" parameter, which is 1000.
34. CreateClientAPI(Optional ByVal strExtNumber As String = "") As Long
As there can be multiple instances of Delta Trading running at the same time, we have to specify which instance the
API will be working with. This is done through the function CreateClientAPI - it binds the API to the specified account and
all subsequent operations are performed on this account.
Parameters:
strExtNumber - The account number.
You can find it it menu "Settings/General Settings/Account Number" of Delta Trading.
When not specified, the API binds itself to one of the running Delta Trading instances.
Result:
When successful returns 0, otherwise - a negative number.
CreateClientAPI("000123456") - The API gets bound to the instance of Delta Trading, running for account number 000123456.
35. DestroyClientAPI() As Long
Destroys Delta Trading API. For each CreateClinetAPI call there should be a corresponding call to DestroyClientAPI()
36. GetFlgRefreshedPos()
GetFlgRefreshedPos - checks wether the communication with the server is OK.
GetFlgRefreshedPos() will rerturn "0" if the communication is OK and "1" otherwise.
GetPosition() and the other "Position related" functions should be called only if GetFlgRefreshedPos returns "0",
otherwise the values those functions return might not be actual.
An example:
long err;
String flg = GetFlagRefreshPos(err);
while (flg != "0")
{
txt = "Error refreshing Delta Trading Positions. Trying again agfter 3 seconds...";
Sleep(3000);
flg= GetFlagRefreshPos(err);
}
//now it is OK to call GetPosition
GetPosition("EUR/USD" ....)
37.GetAllPosList_S( ref err_no) as String
Returns a string containig a list of all open positions, separated by ! - like this:
EUR/USD*100000*1.35685*0*0*0!USD/JPY*200000*1.35685*0*0*0
The 1-st item is the symbol,
the second - the volume,
third is the average price,
4-6 - limit/stop/oco price if there are limit/stops/oco on that position.
Parse the string to get the values.