I have currently achieved this with the following code:
protected override void OnBarUpdate()
{
[...]
order_scalp = EnterShort(3, "Scalper");
order_runner = EnterShort(1, "Runner");
}
protected override void OnOrderUpdate(Cbi.Order order, double limitPrice, double stopPrice,
int quantity, int filled, double averageFillPrice,
Cbi.OrderState orderState, DateTime time, Cbi.ErrorCode error, string comment)
{
if (filled == quantity)
{
double profitTarget = 0;
if (order.Name == "Runner")
{
profitTarget = averageFillPrice - 5;
}
else
{
profitTarget = averageFillPrice - 1;
}
SetProfitTarget(order.Name,CalculationMode.Price, profitTarget);
SetStopLoss(order.Name,CalculationMode.Price, averageFillPrice + 1.0, false);
}
}
But I want both short orders to happen on the same bar, right now the two orders are executed in consecutive bars.
I have not found a way to set a ProfitTarget for 3 of the 4 differently.
I am currently running backtesting in strategy analyzer.
Any help would be appreciated, I have been googling and searching this forum as well as the reference doc but could not find a solution to my problem.

Comment