How can I have 2 different take profit levels for 1 position for example, when TP1 is hit it removes 50% of the order and moves StopLoss to TP1 Level while heading to TP2?
Don't have an account? Join QuantConnect Today
QuantConnect Community Discussions
QUANTCONNECT COMMUNITY
LEAN is the open-source algorithmic trading engine powering QuantConnect. Founded in 2012 LEAN has been built by a global community of 180+ engineers and powers more than 300+ hedge funds today.
Join QuantConnect's Discord server for real-time support, where a vibrant community of traders and developers awaits to help you with any of your QuantConnect needs.
The Open-Quant League is a quarterly competition between universities and investment clubs for the best-performing strategy. The previous quarter's code is open-sourced, and competitors must adapt to survive.
How to set 2 take profit levels for 1 order in C# and move stop loss to TP1 level when TP1 is hit.
Continue ReadingRefer to our Research Guidelines for high quality research posts.
Create an account on QuantConnect for the latest community delivered to your inbox.
Sign Up Today
|
|
|||||||
|
|
||||||||
|
Having 2 different Take profit levels for 1 order C#
Itumeleng Moreotlotlo | June 2021
How can I have 2 different take profit levels for 1 position for example, when TP1 is hit it removes 50% of the order and moves StopLoss to TP1 Level while heading to TP2?
QuantConnectâ„¢ 2025. All Rights Reserved
Varad Kabade
Hi Itumeleng Moreotlotlo,
We suggest creating a limit order at TP1 for half the quantity of assets currently in the portfolio to implement the above. When the limit order gets filled, we can create a Stop-limit order with Stop price as TP1 and limit price as TP2.
Refer to the attached backtest for reference.
Best,
Varad kabade
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.
Itumeleng Moreotlotlo
Hi Varad kabade, can you please add comments on your code it does not make sense to me
Regards
Itumeleng
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.
Varad Kabade
Hi Itumeleng Moreotlotlo,
In the attached algorithm, we have added a brief description and comments. Note that, unlike the previous algorithm, instead of using StopLimitOrder when TP1 is reached, we are putting two limit orders at TP1 and TP2, and after achieving TP1, we are putting a StopMarketOrder with stop loss as TP1. For further assistance regarding any code snippet, please post in this thread along with the code snippet. Refer to the attached backtest.
Best,
Varad Kabade
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!