OPEN-SOURCE SCRIPT
Risk Module

This indicator provides a visual reference for position sizing and approximate stop and target placement. It supports trade planning by calculating equalized risk per trade and maintaining consistent exposure across different markets.
For more information about the concept, see the post Position Sizing and Risk Management.
Fixed Fractional Risk
The indicator calculates the number of shares that can be traded to maintain consistent monetary risk. The formula is based on the distance between the current price and stop reference, adjusting position size proportionally. A closer stop results in a larger position size, while a wider stop results in a smaller one.
Stop and Target
Stop placement is derived from volatility using the Average True Range (ATR). The target is plotted as a multiple of the stop distance, defining the risk-to-reward relationship in R units.
Chart Elements
The stop and target levels are plotted above and below the current price, with the stop marked by a red dot and the target by a green dot. The information table displayed on the chart shows the number of shares to trade, stop level, and target level.
Setup and Configuration
This configuration only needs to be set once, but can be adjusted later if preferred.
1. Start by setting the account size and risk percentage per trade to define the monetary amount risked on each trade. These values form the basis for position size calculation.
2. Set the ATR multiplier to determine stop distance, common values range between 1 and 3 ATR. Lower values place stops closer to price, increasing sensitivity but risking short-term noise. Higher values widen the stop, which reduces noise impact but extends time in risk.
3. Set the R-multiple to determine target distance relative to the stop. A value of 1 represents a 1:1 risk-to-reward relationship. Lower values reduce potential reward but tend to increase win rate, whereas higher values increase potential reward but tend to reduce win rate. The selection depends on system characteristics and trade expectancy.
When the parameters are defined, the indicator displays the stop, target, and calculated position size on the chart. All that remains is to enter the trade with the number of shares shown in the table and place bracket orders at the plotted stop and target levels.
Settings Overview
For more information about the concept, see the post Position Sizing and Risk Management.
Fixed Fractional Risk
The indicator calculates the number of shares that can be traded to maintain consistent monetary risk. The formula is based on the distance between the current price and stop reference, adjusting position size proportionally. A closer stop results in a larger position size, while a wider stop results in a smaller one.
Position Size = (Account Size × Risk %) ÷ (Entry Price – Stop Price)
Stop and Target
Stop placement is derived from volatility using the Average True Range (ATR). The target is plotted as a multiple of the stop distance, defining the risk-to-reward relationship in R units.
Stop = Price ± ATR × Multiplier
Target = Price ± (R × Risk Distance)
Chart Elements
The stop and target levels are plotted above and below the current price, with the stop marked by a red dot and the target by a green dot. The information table displayed on the chart shows the number of shares to trade, stop level, and target level.
Setup and Configuration
This configuration only needs to be set once, but can be adjusted later if preferred.
1. Start by setting the account size and risk percentage per trade to define the monetary amount risked on each trade. These values form the basis for position size calculation.
2. Set the ATR multiplier to determine stop distance, common values range between 1 and 3 ATR. Lower values place stops closer to price, increasing sensitivity but risking short-term noise. Higher values widen the stop, which reduces noise impact but extends time in risk.
3. Set the R-multiple to determine target distance relative to the stop. A value of 1 represents a 1:1 risk-to-reward relationship. Lower values reduce potential reward but tend to increase win rate, whereas higher values increase potential reward but tend to reduce win rate. The selection depends on system characteristics and trade expectancy.
When the parameters are defined, the indicator displays the stop, target, and calculated position size on the chart. All that remains is to enter the trade with the number of shares shown in the table and place bracket orders at the plotted stop and target levels.
Settings Overview
- Account Size / Risk %: Defines account capital and per-trade exposure.
- ATR Multiplier: Adjusts stop distance relative to volatility.
- R Multiple: Sets target distance relative to stop (risk-reward ratio).
- Position: Choose Long or Short direction.
- Table Position: Controls information table placement and scale.
סקריפט קוד פתוח
ברוח TradingView אמיתית, היוצר של הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יכולים לבדוק ולאמת את הפונקציונליות שלו. כל הכבוד למחבר! למרות שאתה יכול להשתמש בו בחינם, זכור שפרסום מחדש של הקוד כפוף לכללי הבית שלנו.
Technical Trading: Research and Application
stockleave.com/
stockleave.com/
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.
סקריפט קוד פתוח
ברוח TradingView אמיתית, היוצר של הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יכולים לבדוק ולאמת את הפונקציונליות שלו. כל הכבוד למחבר! למרות שאתה יכול להשתמש בו בחינם, זכור שפרסום מחדש של הקוד כפוף לכללי הבית שלנו.
Technical Trading: Research and Application
stockleave.com/
stockleave.com/
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.