Thanks Josh~ Will try it out~
Looks it should be specified in Create()? Is it possible to specify which position to close at run-time, in CalcBar()?
I have a lot of signals generating Buy and SellShort orders.
And have another monitor signal to determine when to sell (or cover) a position. Where this monitor signal doesn't have the order objects from other signals which generated the positions.
For example, in simple, to stop a long position if it losses more than 50 points:
Code: Select all
protected override void CalcBar() {
for (int i = 0; i < CurrentPosition.OpenTrades.Count; i++) {
if (CurrentPosition.OpenTrades[i].IsLong) {
if (Bars.CloseValue - CurrentPosition.OpenTrades[i].EntryOrder.Price < -50)
SellOrder.Send (CurrentPosition.OpenTrades[i].EntryOrder.Contracts);
}
}
}
The above code will sell all position. But I want to keep other positions running until they also meet the criteria.
Is it possible to make it work?