OPEN-SOURCE SCRIPT
Risk & Position Calculator

This indicator is called "Risk & Position Calculator".
This indicator shows 4 information on a table format.
1st: 20 day ADR% (ADR%)
2nd: Low of the day price (LoD)
3rd: The percentage distance between the low of the day price and the current market price in real-time (LoD dist.%)
4th: The calculated amount of shares that are suggested to buy (Shares)
The ADR% and LoD is straightforward, and I will explain more on the 3rd and 4th information.
__________________________________________________________________________________
The Lod dist.% is a useful tool if you are a breakout buyer and use the low of the day price as your stop loss, it helps you determine if a breakout buy is at a risk tight area (~1/2 ADR%) or it is more of a chase (>1 ADR%).
I use four different colors to visualize this calculation results (green, yellow, purple, and red).
Green: Lod dist.% <= 0.5 ADR%
Yellow: 0.5 ADR% < Lod dist.% <= 1 ADR%
Purple: 1 ADR% < Lod dist.% <= 1.5 ADR%
Red: 1.5 ADR% < Lod dist.%
(e.g., if Lod dist.% is colored in Green, it means your stop loss is <= 0.5 ADR%, therefore if you buy here, the risk is probably tight enough)
__________________________________________________________________________________
The Shares is a useful tool if you want to know exactly how many shares you should buy at the breakout moment. To use this tool, you first need to input two information in the indicator setting panel: the account size ($) and portfolio risk (%).
Account Size ($) means the dollar value in your total account.
Portfolio Risk (%) means how much risk you are willing to take per trade.
(e.g. a 1% portfolio risk in a 5000$ account is 50$, which is the risk you will take per trade)
After you provide these two inputs, the indicator will help you calculate how many shares you should buy based on the calculated Dollar Risk ($), real-time market price, and the low of the day price.
(e.g. Dollar Risk (50$), real-time market price (100$), Lod price (95$) -> then you will need to buy 50/(100-95) = 10 shares to meet your demand, so it will display as Shares { 10 } )
In addition, I also introduce a mechanism that helps you avoid buying too big of a position relative to your overall account . I set the limit to 25%, which means you don't put more than 25% of your account money into a single trade, which helps prevent single stock risk.
By introducing this mechanism, it will supervise if the suggested Shares to buy exceed max position limit (25%). If it actually exceeds, instead of using Dollar Risk ($) to calculate Shares, it will use position limit to calculate and display the max Shares you should buy.
__________________________________________________________________________________
That's it. Hope you find this explanation helpful when you use this indicator. Have a great day mate:)
This indicator shows 4 information on a table format.
1st: 20 day ADR% (ADR%)
2nd: Low of the day price (LoD)
3rd: The percentage distance between the low of the day price and the current market price in real-time (LoD dist.%)
4th: The calculated amount of shares that are suggested to buy (Shares)
The ADR% and LoD is straightforward, and I will explain more on the 3rd and 4th information.
__________________________________________________________________________________
The Lod dist.% is a useful tool if you are a breakout buyer and use the low of the day price as your stop loss, it helps you determine if a breakout buy is at a risk tight area (~1/2 ADR%) or it is more of a chase (>1 ADR%).
I use four different colors to visualize this calculation results (green, yellow, purple, and red).
Green: Lod dist.% <= 0.5 ADR%
Yellow: 0.5 ADR% < Lod dist.% <= 1 ADR%
Purple: 1 ADR% < Lod dist.% <= 1.5 ADR%
Red: 1.5 ADR% < Lod dist.%
(e.g., if Lod dist.% is colored in Green, it means your stop loss is <= 0.5 ADR%, therefore if you buy here, the risk is probably tight enough)
__________________________________________________________________________________
The Shares is a useful tool if you want to know exactly how many shares you should buy at the breakout moment. To use this tool, you first need to input two information in the indicator setting panel: the account size ($) and portfolio risk (%).
Account Size ($) means the dollar value in your total account.
Portfolio Risk (%) means how much risk you are willing to take per trade.
(e.g. a 1% portfolio risk in a 5000$ account is 50$, which is the risk you will take per trade)
After you provide these two inputs, the indicator will help you calculate how many shares you should buy based on the calculated Dollar Risk ($), real-time market price, and the low of the day price.
(e.g. Dollar Risk (50$), real-time market price (100$), Lod price (95$) -> then you will need to buy 50/(100-95) = 10 shares to meet your demand, so it will display as Shares { 10 } )
In addition, I also introduce a mechanism that helps you avoid buying too big of a position relative to your overall account . I set the limit to 25%, which means you don't put more than 25% of your account money into a single trade, which helps prevent single stock risk.
By introducing this mechanism, it will supervise if the suggested Shares to buy exceed max position limit (25%). If it actually exceeds, instead of using Dollar Risk ($) to calculate Shares, it will use position limit to calculate and display the max Shares you should buy.
__________________________________________________________________________________
That's it. Hope you find this explanation helpful when you use this indicator. Have a great day mate:)
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.