Based on EMA or whatever, if criteria is met we
try
{
SetTrailStop(CalculationMode.Ticks, 20);
EnterLong("123") or EnterShort("321")
}
catch....
I am running the strategy against the playback of the last week (7/24 through 7/28). There are a couple places (at least two) where this issue occurs, the order criteria is met and so I enter long or short, the order gets submitted and filled. The problem is when the TrailStop attempts to get created I get an error Stop price can't be changed below the market....From watching the data the bar seems to have a huge influx of volume one way and then the other. My strategy isn't looking for the volume but something in the price it hits forces an order and then before the trailing stop order can get positioned the price has gone fully the other way.
I have attempted to handle this error in a couple places. First I wrapped the orderEntry in a try catch but that did not capture the error. I then overrode the OnOrderUpdate event, I found that the ErrorCode object in that event has the error that occurred. So I wrapped the call to the base method in a try catch but that didn't capture it either. Meaning I get the error and I can display it but the strategy is still force stopped and the position is left open.
My question is, it seems like the OnOrderUpdate only gets this error after the fact. What event can I override to get ahead of this error and handle it so that NInja doesn't shut down the strategy?

Comment