EnterLongStopLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, double stopPrice, string signalName)
StopLoss=EnterLongStopLimit(0,yes,Position.Quantit y,0,SMA[0],"InitialStop")
StopLoss=EnterLongStopLimit(0,yes,Position.Quantit y,0,Position.AveragePrice + 4 * TickSize,"Scratch")
what happens is that the initial stop of StopLoss with the name "InitialStop" will be placed after position entered, and when the condition is met to place the scratch order, it will place a new order and keep the old InitialStop order as well.
I have seen that if I keep the signal name the same, then it will just amend the order, which is great as that's what I am looking for but it will obviously keep the same signal name, which is not great because I like to see the signal name on the chart as the name itself is usually written as a reason for that order (in this case, "initial stop", and "scratch")
What is the best (clean) way to cancel the old initial stop order and keep the scratch order? Keep in mind that the initial stop order is placed in OnBarUpdate because it needs to have updated values for the changing SMA[0] value. But obviously the scratch order is a fixed price.
I was thinking of via OnOrderUpdate to cancel the initial order if the scratch order is active?
Comment