Hi community,
I am new to this exciting platform and want to build a simple grid trading system.
My first step is to create a limit order with a take profit.
How to place a limit order at a fixed price with a take profit?
I wrote this for a limit order:
newTicket = self.LimitOrder("AUDCAD", 1000, 0.97)
I want to buy 1000 units of AUDCAD at a price of 0.97$
Now I need to add a take profit of 50 pips to my order. How to do that?
Thanks in advance!
Cheers, Robert
Jing Wu
Once the order is filled, you can place a limit sell order to take the profit. self.tickets is a list to save the old order tickets so you can retrieve the ticket in the next time loop. Once the limit buy order is filled, empty the list.
# In initialize() self.tickets = [] # In OnData() ticket = self.LimitOrder("AUDCAD", 1000, 0.97) self.tickets.append(ticket) if self.tickets[0].Status == OrderStatus.Filled: self.LimitOrder("AUDCAD", -1000, self.tickets[0].AverageFillPrice+0.05) self.tickets = []
Jacob Barbee
If you add a stop limit order would it cancel the limit order after you have entered the trade?
Louis Szeto
Hi Jacob
We suggest using LimitOrder instead of StopLimitOrder as its behavior is checking on the opposite direction (stop loss), so if you order a take profit by that, it will be executed immediately. Thus, it is necessary to cancel this limit order explicitly:
Best
Louis Szeto
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.
Robert Rauer
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!