Labels and a New Method to Create Orders
Labels and a New Method to Create Orders
13 Feb 2013, 10:37
MarketOrderRequest
Creates a market order request that can be used as a parameter in the Trade.Send() method, in order to send a market order request to the server. It is similar to Trade.CreateBuyMarketOrder and Trade.CreateSellMarketOrder with the addition that there are more parameters that can be specified such as Label, Slippage and SL/TP in pips. The Label is typically used as a user identifier of the order created by a specific robot.
Required Parameters
Type |
Parameter Name |
Description |
TradeType |
tradeType |
Buy or Sell |
int |
volume |
Trade monetary amount |
Optional Parameters
Type |
Parameter Name |
Description |
string
|
Label |
Label can be used to identify the position or order created with this order request |
int |
SlippagePips |
SlippagePips can be used to set the range (in pips) from the current rate for which the order can be filled. When range is specified, actual executed price cannot vary from the current price for more than specified value |
int |
StopLossPips |
StopLossPips may be used to set the stop loss in pips |
int |
TakeProfitPips |
TakeProfitPips may be used to set the take profit in pips |
Example 1:
var request = new MarketOrderRequest(TradeType.Buy, 10000); Trade.Send(request);
Example 2:
var request = new MarketOrderRequest(TradeType.Sell, 10000) { Label = " Robot1", SlippagePips = 2, StopLossPips = 10, TakeProfitPips = 20 }; Trade.Send(request);
Example 3:
var request = new MarketOrderRequest(TradeType.Buy, 1000) { Label = "58999" }; Trade.Send(request);
LimitOrderRequest and StopOrderRequest
LimitOrderRequest and StopOrderRequest create limit and stop order requests respectively, which can be used as parameters in the Trade.Send() method, in order to send a limit/stop order request to the server. Just as in Trade.CreateSellLimitOrder/CreateBuyLimitOrder and Trade.CreateSellStopOrder/CreateBuyStopOrder with the addition that Label can be assigned. The Label is typically used as an identifier of the order created by a specific robot.
Required Parameters
Type |
Parameter Name |
Description |
TradeType |
tradeType |
Buy or Sell |
int |
volume |
Trade monetary amount |
double |
targetPrice |
The price the order should filled at |
Optional Parameters
Type |
Parameter Name |
Description |
string
|
Label |
Label can be used to identify the position or order created with this order request |
double? |
StopLoss |
StopLoss may be used to set the stop loss in price |
double? |
TakeProfit |
TakeProfit may be used to set the take profit in price |
DateTime? |
Expiration |
The date and time the order should expire |
Example 1:
var request = new LimitOrderRequest(TradeType.Sell, 1000, targetPrice); Trade.Send(request);
Example 2:
var request = new StopOrderRequest(TradeType.Sell, 1000, targetPrice) { Expiration = DateTime.Now.AddMinutes(30), Label = "Robot32", StopLoss = stopLoss, TakeProfit = takeProfit }; Trade.Send(request);
Replies
admin
14 Feb 2013, 16:59
RE:
Also, is there a way to count the number of active positions/orders with same label?
For positions in the account:
var count = Account.Positions.Count(position => position.Label == "1234");
For pending orders in the account:
var count = Account.PendingOrders.Count(order => order.Label == "1234");
@admin
phamvanthanh
06 Mar 2013, 10:52
Hi admin,
anyway to control slippages for pending orders which have become market orders?
@phamvanthanh
cAlgo_Fanatic
06 Mar 2013, 11:33
Currently no. Market range can be implemented for Stop Order Requests in the future. Limit Orders don't have any slippage.
@cAlgo_Fanatic
AlexanderRC
17 Mar 2014, 13:13
RE: RE:
amiscell said:
cAlgo_Fanatic said:
Currently no. Market range can be implemented for Stop Order Requests in the future. Limit Orders don't have any slippage.
Is slippage on stop orders this still in the plans?
Repeating the question. Any plans for this?
@AlexanderRC
Spotware
18 Mar 2014, 09:14
RE:
tekASH said:
Hello Admin
today while opening cTrader I was asked to download updates of 12.5 mb...usually, after installign updates it shows what's new....but this it didnt. What novelties are installed lately?
note: I had installed February updates prior to this one.
cTrader had to to be updated, because we extended cAlgo.API. History collection was added.
cTrader was optimized and several minor issues were fixed in last release.
@Spotware
admin
13 Feb 2013, 10:43
Position.Label and PendingOrder.Label
Label
A Label is an identifying string, associated with an order or position. One can specify a label using the new request-based API for creating orders; in that case the created order will have the specified label. When the order is filled, the resulting position will also have the same label.
Example 1:
Example 2:
@admin