OPEN-SOURCE SCRIPT
Position Sizing Calculator

A simple automated calculator that shows how many shares can be bought or sold if a specific maximum amount is to be risked on the position.
The risk per share is assumed to be the distance to the respective buy or sell line of the Supertrend indicator. This is based on a calculation of the ATR for the last ten days, which is multiplied by a fixed factor and plotted against the highest or lowest candle of the past ten days.
The parameters can be changed manually. By default, a risk of $500 per trade is assumed.
For each of the last bars, the calculator displays the distance to the calculated exit and, through a simple division, calculates the number of shares that could be bought or sold in a potential long or short position to achieve this hypothetical maximum risk.
Of course, there is no guarantee that the respective price will actually be reached, but the calculator can help provide a reference point for sizing the position.
The principle is clearly visible in the screenshots: FRT is a stock that moves slowly and is only a short distance from the stop-loss level. At the current price of $114.47 and a calculated stop at $108.99, 91 shares could be purchased to risk $500. In total, that would be an order of $10,416.77 for a long position.
SOUN, on the other hand, has a very wide margin to the stop-loss; it is a stock with high volatility. Therefore, only 300 shares can be purchased here to achieve the same hypothetical risk. The position would thus be worth only $2,841.
Designed by tuvot_1a, programmed by Claude.
The risk per share is assumed to be the distance to the respective buy or sell line of the Supertrend indicator. This is based on a calculation of the ATR for the last ten days, which is multiplied by a fixed factor and plotted against the highest or lowest candle of the past ten days.
The parameters can be changed manually. By default, a risk of $500 per trade is assumed.
For each of the last bars, the calculator displays the distance to the calculated exit and, through a simple division, calculates the number of shares that could be bought or sold in a potential long or short position to achieve this hypothetical maximum risk.
Of course, there is no guarantee that the respective price will actually be reached, but the calculator can help provide a reference point for sizing the position.
The principle is clearly visible in the screenshots: FRT is a stock that moves slowly and is only a short distance from the stop-loss level. At the current price of $114.47 and a calculated stop at $108.99, 91 shares could be purchased to risk $500. In total, that would be an order of $10,416.77 for a long position.
SOUN, on the other hand, has a very wide margin to the stop-loss; it is a stock with high volatility. Therefore, only 300 shares can be purchased here to achieve the same hypothetical risk. The position would thus be worth only $2,841.
Designed by tuvot_1a, programmed by Claude.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。