Support Board
Date/Time: Sun, 02 Feb 2025 16:56:37 +0000
Post From: ACSIL - trailing stop loss and orders
[2019-09-17 16:04:50] |
MattK - Posts: 42 |
On my first backtest order, the Trade Activity says: "Updating move to breakeven stop reference price on parent modification/fill to 2850". The entry is 2850 but it sets the stop at 2846! I don't understand why. I changed the stop loss part to try and make it tighter but I think it makes it worst. I just can't figure out why... It's driving me nuts. // Update the trailing stop loss if the new low is higher than the previous low.
// Gotta make sure the new stop loss is not lower than the initial one NewPossibleStop = currentLow - 2*sc.TickSize; if (PositionData.PositionQuantity == 1 && currentLow > previousLow && currentHigh > previousHigh && currentStop < NewPossibleStop && NewPossibleStop > orderStop) { s_SCTradeOrder ExistingOrder; if (sc.GetOrderByOrderID(Stop1OrderID, ExistingOrder) != SCTRADING_ORDER_ERROR) { s_SCNewOrder ModifyOrder; ModifyOrder.InternalOrderID = Stop1OrderID; ModifyOrder.Price1 = NewPossibleStop; sc.ModifyOrder(ModifyOrder); DebugMessage.Format("Current time: %d:%d", Hour, Minute); sc.AddMessageToLog(DebugMessage, 1); DebugMessage.Format("Updating stop loss to: %f on entry: %f", NewPossibleStop, orderPrice); sc.AddMessageToLog(DebugMessage, 1); currentStop = currentLow - 2*sc.TickSize; } } |