I have this peace of code for going long and short simultaniosly as a simple range breakout system:
high = Highs[1][0];
low = Lows[1][0];
var longOrder = EnterLongStopMarket(0, true, 1, high + 1, "LongRBO");
if (longOrder != null)
{
longOrder.Oco = Guid.NewGuid().ToString();
_orders.Add(longOrder);
}
var shortOrder = EnterShortStopMarket(0, true, 1, low - 1, "ShortRBO");
if (shortOrder != null)
{
shortOrder.Oco = Guid.NewGuid().ToString();
_orders.Add(shortOrder);
}
protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity,
MarketPosition marketPosition, string orderId, DateTime time)
{
if(marketPosition == MarketPosition.Long)
{
SetStopLoss(CalculationMode.Price, high - MaxStop);
SetProfitTarget(CalculationMode.Price, high + MaxStop * TakeProfitFaktor);
}
if (marketPosition == MarketPosition.Short)
{
SetStopLoss(CalculationMode.Price, low + MaxStop);
SetProfitTarget(CalculationMode.Price, low - MaxStop * TakeProfitFaktor);
}
}
Now, the problem is short orders never work, they get canceled when the Long order gets triggered.
Setting different OCO strings didn't solve the problem.
What am I doing wrong here?
Best regards,
Johnny

Comment