+ Reply to Thread
Results 1 to 4 of 4

Stop Loss Backtesting Formula

  1. #1
    Registered User
    Join Date
    05-06-2020
    Location
    Australia
    MS-Off Ver
    15.41
    Posts
    2

    Stop Loss Backtesting Formula

    Hi, 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

    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!

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Stop Loss Backtesting Formula

    Welcome to the forum.

    A simple if statement should suffice:

    =IF(C1<B1,B1,A1)

    Change the cell references to suit.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    05-06-2020
    Location
    Australia
    MS-Off Ver
    15.41
    Posts
    2

    Re: Stop Loss Backtesting Formula

    Thanks so much! I've been laying awake at night trying to figure this out in my head! What a dumbo.

    Thats perfect.

    If anyone else is looking for the same answer, this is for Longs.

    =IF(C1<B1,A1,B1)

    For Shorts, this seems to work:

    =IF(C1>B1,A1,B1)

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Stop Loss Backtesting Formula

    So what happens if C1=B1???

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Drawdown and High watermark with stop loss
    By gauravks3 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-29-2015, 06:27 PM
  2. Drawdown and Stop Loss
    By gauravks3 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-23-2015, 01:14 PM
  3. Trailing Stop Loss Tracking
    By Excelguy10 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-06-2015, 11:40 AM
  4. Percentage trailing stop loss
    By saivenkat in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-21-2013, 11:53 PM
  5. [SOLVED] Help getting trailing stop loss UDF to work?
    By hadamhiram in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-31-2013, 01:15 AM
  6. Stock Stop Loss Formula
    By zmr325 in forum Excel General
    Replies: 3
    Last Post: 11-28-2005, 09:15 PM
  7. [SOLVED] Stop Loss Formulas for Stock Trading
    By zmr325 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-28-2005, 03:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1