Back

StopMarketOrder and execution trigger level seem inconsistent....

Hi

I'm trying to figure out StopMarketOrder and seem to find strange behaviors, unless I'm completly missing something

The code below places an order on EURUSD and as soon as it is filled places a Stop (loss) market order a few tick below (please note that for the sake of testing I've hardcoded the stop and it is linked to the start date!)

here is what is logged 

2017-09-06 00:00:00 :    bar - H: 1.19106 L: 1.19101 C: 1.19104
2017-09-06 00:00:00 :    OrderEvent: Submitted: Buy 83000.0 EURUSD
2017-09-06 00:00:00 :    OrderEvent: Filled: Buy 83000.0 EURUSD - filled @ 1.19116
 

2017-09-06 00:00:00 :    Setting stop loss @ 1.1908
2017-09-06 00:00:00 :    OrderEvent: Submitted: Sell -83000.0 EURUSD - STOP @ 1.19080

//so far so good!

 

2017-09-06 00:01:00 :    bar - H: 1.19106 L: 1.19101 C: 1.19104
2017-09-06 00:02:00 :    bar - H: 1.19108 L: 1.19102 C: 1.19102
2017-09-06 00:03:00 :    bar - H: 1.19106 L: 1.19102 C: 1.19105
2017-09-06 00:04:00 :    bar - H: 1.19107 L: 1.19103 C: 1.19106
2017-09-06 00:05:00 :    bar - H: 1.19105 L: 1.19103 C: 1.19103
2017-09-06 00:06:00 :    OrderEvent: Filled: Sell -83000.0 EURUSD - STOP @ 1.19080 - filled @ 1.19080
2017-09-06 00:06:00 :    bar - H: 1.19103 L: 1.19091 C: 1.19092

You can see that the low is 1.19091 and yet somehow my stop at 1.1908 was triggered 

Why was the StopOrder triggered whe it was a full tick above... is it a bug? or has it something to do with bid ask and or slippage models?

thanks

Update Backtest








When we are working with Forex, we have quote bar data. So when the algorithm looks for fills for a sell, it is going to look at bid's low. The StopMarketOrder was filled because there was a Bid.Low at 1.19079:

Log("bar - H: " + cBar.High.ToString("#.00000") + " L: " + cBar.Low.ToString("#.00000") + " C: " + cBar.Close.ToString("#.00000"));
Log("ASK - H: " + cBar.Ask.High.ToString("#.00000") + " L: " + cBar.Ask.Low.ToString("#.00000") + " C: " + cBar.Ask.Close.ToString("#.00000"));
Log("BID - H: " + cBar.Bid.High.ToString("#.00000") + " L: " + cBar.Bid.Low.ToString("#.00000") + " C: " + cBar.Bid.Close.ToString("#.00000"));
1

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


ok, thanks

0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed