How do we set stop loss and take profits ?

Back

Lets say i i bought EURUSD at 1.05 and want to set a stop loss about 15 pips below and a take profit 40 pips above the buy price.

The most examples i saw were not that clear and bad documented.

How the heck do we do this ? Could someone give an detailed example of how we implement this in an easy way ? :/

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.


See the attached.

Basically, you would reset the current price of whatever your "buy-in" variable was set to only when you don't hold the equity, making it available for comparison to the current price in order to determine if you need to sell. Upon selling, the next OnData call will cause you to take a position in the attached example (although, of course, you can always set conditions for entry into the position by replacing Portfolio.Invested with whatever alternative of your choosing).

0


Just noticed a typo in the code documentation. The second if statement should instead be:

if CurrentPrice > self.BuyIn*(1+0.05) or CurrentPrice < self.BuyIn*(1-0.05): # Sell if +/- 5 pct from buy

 

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