I have been back testing a strategy that scales in two contracts at a time and places a stop at the Low of the signal bar (current bar) when entering a long position and a stop at the High of the signal bar when entering a short position.
I received this error in the trace output during back testing and also live testing:
"8/25/2014 1:10:52 PM Entered internal PlaceOrder() method at 8/25/2014 1:10:52 PM: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1158.0 SignalName='' FromEntrySignal=''
**NT** A Sell stop order placed at '8/25/2014 1:10:52 PM' has been ignored since the stop price is greater than or equal to close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy."
What I think is happening:
If a short signaling bar signals to set a stop at it's high, 1158.0, but the next bar opens equal to or above that high of 1158.0. Say 1158.0 or 1158.1, the short is effectively trying to enter itself higher than the stop.
Attached is a screenshot of the problem bar(s) during backtest. A gold dot represents the stop for short positions entered. The magenta bars represent a Short should be entered on the next bar.
Q: How can I capture this error and enter some logic to fix the strategy. I need to somehow capture the order and if it is going to error out, cancel the stop and any associated short entry signal if there is one.
I have only one bar series for the strategy and CalculateOnBarClose is set to true.
Thanks in advance for any help you can offer!
Comment