New to the forum, and trying to figure out how to track a trade from entry to execution to exit. Does the Trades class do this? (see sample code below)... I'm trying to iterate through all open positions and close them if they meet certain criteria. Thanks.
protected override void OnBarUpdate()
{
// Condition set 1
if (Close[0] > Close[10]
&& Close[0] > Close[20] + 0.0005
&& Close[0] > Close[20])
{
EnterLong(100000);
}
for (int i=0; i < Performance.RealtimeTrades.Count; i++)
{
if(Performance.RealtimeTrades[i].Entry.Order.OrderState == OrderState.Filled
&& Performance.RealtimeTrades[i].Exit.Order.OrderState != OrderState.Filled)
{
if(Performance.RealtimeTrades[i].Entry.Price - Close[0] > .00025
&& Performance.RealtimeTrades[i].Entry.MarketPosition == MarketPosition.Long)
{
ExitLongLimit(Close[0] - .0001);
}
if(Performance.RealtimeTrades[i].Entry.Price - Close[0] < -.0005
&& Performance.RealtimeTrades[i].Entry.MarketPosition == MarketPosition.Long)
{
ExitLongLimit(Close[0] - .0001);
}
}
}
}

Comment