Hi,
I've hit a problem where the backtesting server seems to ignore my order's stop loss and take profit levels. Judging from the logs the price have long since passed the stop-loss level, yet the trade is not being closed. Any idea why this would happen?
Also, still unsure of how to check whether a ticket is closed. The OrderEvent.Status enumeration only specified whether an order got filled or not, but contains no detail on when an order is automatically closed by the server.
Any ideas?
Kind regards,
Kepler
JayJayD
Hi there Kepler,
When I use stop loss orders, first I make the entry to the market using a MarketOrder, then I use StopMarketOrder order to set the stoploss.
Check lines 81 and 82 in the main.cs file in this example.
Also check this clearer example by Jonathan Evans.
Alexandre Catarino
Please put the following code line in the OnOrderEvent method:
public override void OnOrderEvent(OrderEvent orderEvent) { Log(orderEvent.ToString()); }
and check the logs.
We should have seen a line with the information about the submission of the StopLimit orders, but we couldn't. It seems that the code lines that place these orders are never hit.
Kepler Engelbrecht
Hi JayJayD,
The engine doesn't allow that though?
JayJayD
Of course the engine is Unable to get field StopPrice on order of type Market
Before asking for the StopPrice, make sure you are refering to a StopMarketOrder or a StopLimitOrder.
Kepler Engelbrecht
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!