Duplicate Orders
Duplicate Orders
19 Sep 2015, 18:03
I'm trying to cancel orders which duplicate positions using the following code but its not working. Any suggestions would be appreciated.
for (int i = Positions.Count - 1; i >= 0; i--)
{
position = Positions[i];
var PositionLabel = position.Label;
var PositionVolume = position.Volume;
foreach (var order in PendingOrders) // Loop is intended to find orders which duplicate positions and cancel them
{
if ((order.Label == PositionLabel) && (order.Volume == PositionVolume))
{
CancelPendingOrder(order);
}
}
ClickAlgo
19 Sep 2015, 20:59
So what you are doing is:
The Pseudocode above shows that you will close all orders where a position exists with the same label name and the same volume amount.
You are missing a curly brace at the end of your code and you could have written your iterations like this:
I am sure you can work the rest out. :-)
@ClickAlgo