In this article, I will teach you how to set your stop-loss and take-profit levels. But before we dive into the process, let me explain what a stop-loss and tak



stock trading

stock API

Prices API


How to set Stop-Loss and Take-Profit for your selected stock.


blog post cover photo

Image credit: stop loss and take profit

In this article, I will teach you how to set your stop-loss and take-profit levels. But before we dive into the process, let me explain what a stop-loss and take-profit are.

In stock trading, stop-loss and take-profit are crucial tools used to manage risk and optimize profits.

Stop-loss is a predefined price level set by a trader to limit potential losses on a trade. When the stock price reaches this level, the stop-loss order automatically triggers, selling the stock to prevent further loss. In simple terms, this is the price at which the trader is willing to sell the stock to minimize losses.

Take-profit is a predetermined price level at which a trader decides to sell a stock to lock in profits. Once the stock price reaches this level, the take-profit order executes, securing the gains made on the trade. In simple terms, this is the price at which a trader will close their position with profits.

Both stop-loss and take-profit orders are essential for disciplined trading, helping traders protect their capital and maximize returns by automatically executing trades based on predetermined criteria.

Understanding and effectively using these tools can significantly improve trading outcomes and reduce emotional decision-making in volatile markets.

Now that you've learned what SL (Stop-Loss) and TP (Take-Profit) are, let's dive into the calculation process and I will teach you how to set those levels correctly. Of course, a lot depends on your risk appetite. The riskier you are, the higher losses you may be willing to take, in anticipation of higher returns without closing positions prematurely. Conversely, risk-averse traders prefer to minimize risk and close positions earlier.

To calculate these levels, you first need to determine your stock's standard deviation, which is calculated using the formula:

standard deviation formula

where x are individual data points mu is the mean of the data points and N is the number of data points.

Let's consider an example. Suppose we have the following daily closing prices of a stock over a period of 5 days: 25.50, 25.75, 26.00, 25.90, 26.10. To calculate the standard deviation of these stock prices, we first need to find the mean. Sum all the prices and divide by 5, since there are five days. It will equal 25.85.

Then calculate squared differences from the mean:

(25.50 - 25.85)^2 = (-0.35)^2 = 0.1225

(25.75 - 25.85)^2 = (-0.10)^2 = 0.0100

(26.00 - 25.85)^2 = (0.15)^2 = 0.0225

(25.90 - 25.85)^2 = (0.05)^2 = 0.0025

(26.10 - 25.85)^2 = (0.25)^2 = 0.0625

Then sum all squared differences:

0.1225+ 0.0100 + 0.0225 + 0.0025 + 0.0625 = 0.22.

The last step is to take the square root of 0.22/5 or the square root of 0.044, which equals approximately 0.21. Now we have the stock's standard deviation or some traders call it volatility, indicating that the stock typically deviates from its average by 0.21 units. Ideally, larger datasets, such as 360 days or more, provide a more accurate standard deviation.

Now that you know how much the stock can deviate from its average, you can set your stop-loss and take-profit prices.

To aim for higher earnings on the stock, set a higher take-profit level. Multiply the standard deviation by 3. In our example, multiply 0.21 by 3 to get 0.63. Then, add 0.63 to the stock's market price, which is 26.10 in our case, resulting in a take-profit level of 26.73.

For the stock's stop-loss, use a smaller standard deviation. Multiply the standard deviation by 2 and subtract from the market price. In our case, the calculation would be: 26.10 - (0.21 * 2) = 25.68, which is the stop-loss price.

The rule of thumb is that the more risk you're willing to take, the higher the multiplier you should use. If you increase the stop-loss multiplier, don't forget to adjust the take-profit accordingly. For instance, if you're comfortable with more risk, you could use 4 standard deviations for the stop-loss and 5 standard deviations for the take-profit.

As demonstrated in this article, calculating stock SL (Stop-Loss) and TP (Take-Profit) requires some effort. If you use a large dataset as recommended, manual calculation becomes impractical. Therefore, I've developed a simple web-based application that sets stop-loss and take-profit for selected stocks based on the rules explained here. The application extracts stock prices using FMP Historical Price API. You can access this app by cloning my GitHub repository and make sure to read the README file for instructions. I hope you found this article helpful!

Other Blogs

Nov 25, 2023 6:39 AM - Parth Sanghvi

DCF Valuation vs. Comparable Companies Analysis: Choosing the Right Valuation Method

Choosing the Right Valuation Method: DCF vs. Comparable Companies Analysis Introduction: Valuation methods play a pivotal role in determining the fair value of a company, aiding investors in making informed investment decisions. Two commonly used methods, DCF Valuation and Comparable Companies A...

blog post title

Dec 23, 2023 2:19 AM - Parth Sanghvi

Understanding the Limitations of DCF Analysis: A Guide to Overcoming Challenges

Introduction: Discounted Cash Flow (DCF) analysis stands as a cornerstone in valuing investments, yet its efficacy is contingent upon various assumptions and methodologies. While a powerful tool, DCF analysis comes with inherent limitations and challenges that investors must acknowledge to make i...

blog post title

Dec 25, 2023 2:28 AM - Parth Sanghvi

Integrating Sustainability into Valuations: Navigating ESG Factors within the Discounted Cash Flow (DCF) Model

Introduction: The investment landscape is undergoing a profound shift with a heightened emphasis on sustainability and responsible investing. In this blog post, we explore the intersection of Environmental, Social, and Governance (ESG) considerations within the Discounted Cash Flow (DCF) model, h...

blog post title


Financial Modeling Prep API provides real time stock price, company financial statements, major index prices, stock historical data, forex real time rate and cryptocurrencies. Financial Modeling Prep stock price API is in real time, the company reports can be found in quarter or annual format, and goes back 30 years in history.
2017-2024 © Financial Modeling Prep