Stop Loss Backtesting Formula

ComCool3000

New Member
Joined
May 6, 2020
Messages
1
Office Version
  1. 2016
Platform
  1. MacOS
Hi, I’m trying to figure out a formula that I’m finding a bit tricky. I’m backtesting a trading strategy and currently focusing on optimising a stop loss percentage. I have 8.5 years worth of data and I want to be able to tweak a Stop Loss percentage number to see what would have given optimum results. For the trades that were successful, I want the formula to give me either the Exit price (if the trade was completed) or the Stop Loss price (if the lowest price during the trade fell below the Stop Loss and triggered it.


A = Exit price (if stop is not triggered)
B = Stop Loss (represented as price, not percentage)

C = Lowest price for the duration fo the trade

D = Result : Either A or B depending on whether the Stop loss was triggered by C falling below B


I need a formula that says:

D = A
unless
C falls below B,
in which case
D = B


Example 1:
A (Exit Price) = 100
B (Stop Loss) = 90
C (Lowest) = 98
In this case, D = 100
(lowest price did not go under stop loss, therefore D = A (Exit price)



Example 2:
A (Exit Price) = 100
B (Stop Loss) = 90
C (Lowest) = 85
In this case, D = 90
(lowest price did go under stop loss and triggered it, therefore D = B (Stop loss)



Any ideas greatly appreciated!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Welcome to the forum.

Is this what you're after?

MrExcel posts18.xlsx
BCDEF
2Trade1Trade2Trade3Trade4
3Exit100100100100
4StopLoss90909090
5Lowest988590110
6result10090100100
Sheet22
Cell Formulas
RangeFormula
C6:F6C6=IF(C5<C4,C4,C3)
 
Upvote 0

Forum statistics

Threads
1,223,677
Messages
6,173,791
Members
452,534
Latest member
autodiscreet

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top