Custom Orders

Hi, I'm new to Quantconnect.

1. I've looked at the documentation and am still a little confused as how to (for forex) buy at a certain price. Would I do this by submitting a StopMarketOrder or LimitOrder? What is the difference between StopMarketOrder and LimitOrder for quantconnect? They both Submit/fill when teh price is reached but a limit order will fill if the current price is better than the one we set. How does it consider what is better? If my number was the close *.999m is beter less than or greater than, or does that depend on whether my quantity is positive or negative?

2. If I wanted to cancle an order after a certain amount of days, lets say 3 days or something, from when it was placed how would I go about doing that? Do order tickets hold the date that they were placed/filled or do I have to manually manage that?

Thank you!

Update Backtest

Maybe i can help you at 2 with this link where you can find an example of time + orders:

More enhanced stuff:

And you may need 3 trading days not usual days:

Properties of Orderevent:


Differenced between stopmarket order and marketordner are explained by millions of people on youtube and every broker :)


1. Short answer: Limit orders are what you want to use most of the time. Their logic is BUY IF PRICE BELOW X and SELL IF PRICE ABOVE X conversely.

StopMarketOrder (and StopLimitOrder) typically aren't suited to enter and regularly exit positions. To consider why that is, consider that the trigger logic for such an order is SELL IF PRICE BELOW X (or conversely BUY IF PRICE ABOVE X). Basically, this logic makes you suspectible to mean reversion movements. Why is it even there then? It's there to act as a stoploss (hence the name), placing a bound on your losses. However, beware the order may be filled at a worse price than the trigger price. Particularly, market (and stop market) orders are problematic in this respect.

There's no silver bullet. Intraday, Limit orders have a tendency to fill at the limit price when the market moves through it, resulting in an immediate small loss (or big, if market is volatile).

2. The OrdetTicket returned from an order call holds an order identifier number. I would recommend storing the OrderTicket (although it is possible to only store the number and find the order via other methods).


Update Backtest


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.


This discussion is closed