Blog

Trail Stop Loss to Break-Even Price when Backtesting

In this post, we’ll show you two variations of the Trail Stop Loss to Break-Even Price when backtesting on https://algotest.in.

Building block 1 – Square off

Before we understand Trail SL to BE, we must first understand the Square off option available on algotest.in.

Let’s say we are short a 920straddle with a stop loss on each leg at 20%, and “Square off: Partial” selected. A large market move in one direction will lead to one leg’s SL being hit. In this scenario, we will only exit that leg and continue to hold the position of the other leg. For example – if my call and put entry prices were both Rs 100, then my SL for each leg is Rs 120. Most likely the call SL will get hit first if the market goes up first. In this scenario, the put will continue to be in the market, with its stop-loss unchanged at Rs 120. A similar scenario unfolds if the market goes down first, in which case your put SL will be hit while the call stays in the market.

What happens in the case of “Square off: Complete”? In this case, when either the put or the call SL is hit, the entire position will exit. So unlike above, any leg’s stop loss will lead to the strategy exiting completely when Square off: Complete is selected.

Trail Stop Loss to Break-even – Intro example

What happens if a user selects “Square off: Partial” and “Trail Stop Loss to Break-Even” in the above example?

In this case, if the SL of the call gets hit, the SL of the put is adjusted from Rs 120 to Rs 100. This Rs 100 is the entry price of the put option. Now if the market starts going back down, our put price will start increasing. In this case, we will exit the trade once the put price reaches 100. At Rs 100, our put exit price will equal the put entry price, so this becomes our “Break even”. Hence for this trade, we have “trailed our SL to break-even price feature”

Building block 2 – Iron Condor

The next building block towards understanding algotest.in’s Trail Stop Loss to Break-Even is to read this blog entry about a short iron condor strategy which we shared a few days ago. To summarize, we have two short legs and two long legs in this strategy. The short legs each have a stop loss of 50 points. The long legs have no stop loss associated with them.

Finally – Trail Stop Loss to Break-even price when backtesting

Trail SL to Break-Even

So now that we’re short the above iron condor, let’s assume this is our opening position along with the entry prices:

Long 1 PE strike 30000 @ Rs 5, no stop loss.
Short 1 PE strike 32000 @ Rs 125, stop loss = Rs 175
Short 1 CE strike 37000 @ Rs 150, stop loss = Rs 200
Long 1 CE strike 40000 @ Rs 10, no stop loss

Trail SL to Break-Even – difference between “SL Legs” and “All Legs”

SL Legs

When “SL Legs” is selected, if PE stop loss is hit first, only the short CE stop loss will be updated to its break-even price. So the new positions will be (changes are in bold):

Long 1 PE strike 30000 @ Rs 5, no stop loss.
Short 1 CE strike 37000 @ Rs 150, stop loss = Rs 150
Long 1 CE strike 40000 @ Rs 10, no stop loss

Notice that the CE stop loss is updated to Rs 150. A similar scenario will occur if the CE stop loss is hit first:

Long 1 PE strike 30000 @ Rs 5, no stop loss.
Short 1 PE strike 32000 @ Rs 125, stop loss = Rs 125
Long 1 CE strike 40000 @ Rs 10, no stop loss

All Legs

Now, when “All Legs” is selected, even legs in your strategy that had no defined stop loss will now have a stop loss! So in our above example, if the PE stop loss is hit first, the new positions become (changes are in bold):

Long 1 PE strike 30000 @ Rs 5, stop loss = Rs 5
Short 1 CE strike 37000 @ Rs 150, stop loss = Rs 150
Long 1 CE strike 40000 @ Rs 10, stop loss = Rs 10

Notice that “All Legs” sets the trail stop loss to the break-even price for all legs of the strategy, irrespective of whether you set a stop loss for that individual leg or not! Here’s how our short iron condor looks if the CE stop loss is hit first:

Long 1 PE strike 30000 @ Rs 5, stop loss = Rs 5
Short 1 PE strike 32000 @ Rs 125, stop loss = Rs 125
Long 1 CE strike 40000 @ Rs 10, stop loss = Rs 10

AlgoTest

View Comments

  • Excellent! You guys are getting better every day! Keep them coming.... Thanks a lot for giving us such a wonderful backtesting platform....

    Cheers....

Recent Posts

Detailed Pricing Information for AlgoTest

Hello and welcome to the detailed pricing page for AlgoTest. You will find a breakdown of our pricing model here.…

7 months ago

Explore AlgoTest’s Strategy Builder Tool for Options Trading

Introduction Options trading can be lucrative for investors looking to diversify their portfolios and take advantage of market opportunities. However,…

2 weeks ago

Error on AlgoTest? Here’s what you can do!

While it is not the most common occurrence, sometimes the strategies you create can go into errors. In such situations,…

3 months ago

Candle Close Implementation on AlgoTest

Exciting news for our traders: Candle Close Implementation has arrived at AlgoTest! To understand AlgoTest’s implementation of Candle Close here…

5 months ago

Introducing Synthetic Futures: Your New Edge in Trading

At AlgoTest, we are constantly innovating to bring our users the most advanced and user-friendly trading tools. So we are…

4 months ago

New Feature : Margin Estimate required to take a trade

In our bid to provide additional support to traders in making trading decisions, we have now launched the feature 'Margin…

5 months ago

This website uses cookies.