Create List of Pending Orders
Create List of Pending Orders
22 Oct 2013, 21:08
Hi,
I would like to create a list of pending orders and add the last pending order.. similar to the list of open positions
Can you please explain how in the case of opened positions the position variable is allowed but the following code generates an error. Do I have to create a routine onPendingOrderOpen() or can I just add it when a ConditionalBuy() is successful...
Thanks
private readonly List<PendingOrder> _PendingPositions = new List<PendingOrder>();
///
/// Create Conditional Buy Order
///
private void ConditionalBuy()
{
LastOrderSuccessful = true;
//Buy ONCE at each trigger level when the Buy price is under the trigger price
Trade.CreateBuyStopOrder(Symbol, Volume, ContingentOrderPrice, null, null);
if (LastOrderSuccessful)
{
Print("CO() ***** CONDITIONAL ORDER SUCCESSFUL!! *****");
//Add to Pending Order List
_PendingPositions.Add(PendingOrder order);
}
}
Replies
Spotware
17 Aug 2015, 21:27
Dear Trader,
We do not provide coding assistance services. We more than glad to assist you with specific questions about cAlgo.API. You also can contact one of our Partners or post a job in Development Jobs section for further coding assistance.
@Spotware
Spotware
23 Oct 2013, 12:08
It has to be added in the OnPendingOrderCreated method.
cAlgo uses asynchronous operation. So, after it sends the request for a pending order with Trade.CreateBuyStopOrder to the server, the order will not have been created when the execution reaches the next statements if (LastOrderSuccessful)...
See:
/api/robot/onpendingordercreated-26ec
One more note on C# syntax:
This is not a proper call to a method: _PendingPositions.Add(PendingOrder order);
The above statement will produce a compiler error.
It has to be _PendingPositions.Add(order);
When you declare methods you need to specify the parameter types:
This is a method declaration:
When you call methods you omit the parameter types. Only the variable name is necessary in the parameter list:
This is a method call:
See also:
http://msdn.microsoft.com/en-us/library/ms173114.aspx
http://msdn.microsoft.com/en-us/library/67ef8sbd.aspx
@Spotware