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が提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。