I am trying to use the floating point arithmetic to place my stop limit orders and cancel them if the condition for triggering becomes false, but it doesn't seem to work.
I expected the logic below to return a ceiling of 2, in case the StopOffsetTicks / CancelOffsetTicks was 2 ((2 + 1) / 2 = 1.5, hence a ceiling of 2), but it returns a ceiling of 1.
Am I doing something wrong here?
offsetLimitStop = (StopOffsetTicks + 1) / 2;
cancelLongShort = (CancelOffsetTicks + 1) / 2;
.
.
.
AtmStrategyCreate(OrderAction.Buy, OrderType.StopLimit, currentAsk + Math.Ceiling(offsetLimitStop) * TickSize, currentAsk + Math.Ceiling(offsetLimitStop) * TickSize,
TimeInForce.Day, longOrderId, "3C", longAtmId, (atmCallbackErrorCode, atmCallBackId) =>...
.
.
.
else if ((longAtmId.Length != 0 && isLongAtmStrategyCreated && CONDITION FALSE && currentAsk <= triggerPriceLong - Math.Ceiling(cancelLongShort) * TickSize) // Cancel if condition becomes false and price pulls back by CancelOffsetTicks * TickSize
Comment