PROTECTED SOURCE SCRIPT
Position Sizer Simplified

This is a Pine Script® indicator for TradingView called "Position Sizer Simplified". Its primary function is to help a trader quickly calculate the appropriate position size for a trade based on their chosen risk tolerance, account size, and the trade's entry/stop-loss levels. The results are displayed neatly in a customizable table on the chart.
This tool is essential for proper risk management in trading.
Core Functionality & Inputs
The script uses a few key inputs to perform its calculations:
Account & Risk Configuration
Account Size: You can define and switch between two account sizes (account_size_1 and account_size_2) using the account_option toggle ("P1" or "P2"). The chosen size determines the total capital.
Risk % per Trade (risk_percent): This is the percentage of your chosen account size that you are willing to lose on a single trade. Example: 0.5% risk on a $180,000 account means you risk $900 per trade.
Trade Parameters
Entry Price, Stop Loss Price, Target Price: These are the manual prices a trader enters for their planned trade.
Reset All Inputs (enable_reset): A toggle to quickly clear the three price inputs by setting them to 0.
🧮 Key Calculations
The script calculates several critical values to determine the position size:
Risk per Trade: The actual dollar amount you are risking:
Account Size×(100Risk %)
Stop Distance: The price difference between the entry and stop-loss:
Entry Price−Stop Loss Price
(This assumes a Long trade; for a Short trade, the calculation would be reversed, but the magnitude must be positive for the next step).
Position Size: The maximum number of shares/contracts you can buy/sell while keeping the dollar risk within your Risk per Trade amount. This is the main output:
Position Size=Floor(Stop DistanceRisk per Trade)
The math.floor() function ensures the position size is a whole number (no fractional shares).
Capital Required: The total cost to open the calculated position:
Position Size×Entry Price
Risk/Reward (R:R) Ratio: The potential reward compared to the risk taken:
Stop DistanceTarget Price−Entry Price
Table Display & Customization
The script's output is displayed in a customizable table on the chart.
Display Toggles
A large section of boolean (input.bool) variables (e.g., show_position_size, show_rr_ratio) allows the user to turn on/off individual rows in the results table, customizing what information is shown.
Visual Settings
Table Position: The user can select one of four corners for the table (Top Right, Bottom Right, Top Left, Bottom Left).
Colors and Size: Extensive inputs are provided to customize the table's background, border, font size, and text colors.
Conditional Coloring
The script uses colors to provide quick visual warnings and checks on key metrics:
Risk % per Trade:
Green/Lime for ≤1.0% (Low Risk)
Orange for >1.0% and ≤2.0% (Medium Risk)
Red for >2.0% (High Risk)
R:R Ratio:
Green/Lime for ≥2 (Good)
Red for <2 (Bad)
Capital Check:
Green if Capital Required ≤ Account Size (Within Limit)
Red if Capital Required > Account Size (Exceeds Account)
Displayed Outputs
The table provides a comprehensive set of calculated metrics, including:
Current Ticker: The symbol of the asset being traded.
Position Size: The calculated share/contract quantity.
Risk per Trade: The dollar amount risked.
Stop Distance (pts/%): How far the stop-loss is from the entry price, in both price points and a percentage of the entry price.
Target Reward ($/%): The potential profit in dollars and as a percentage.
R:R Ratio: The calculated Risk/Reward ratio.
Target 1 (50%): Half the distance to the full target (potential partial take profit).
Target 2 (100%): The full target_price.
Capital Check: A quick status on whether the trade exceeds the total account size.
Summary: A single line detailing the trade direction (Long/Short), prices, size, and R:R ratio.
This indicator is a powerful tool for traders who want to maintain strict, quantifiable risk control on every position they take.
This tool is essential for proper risk management in trading.
Core Functionality & Inputs
The script uses a few key inputs to perform its calculations:
Account & Risk Configuration
Account Size: You can define and switch between two account sizes (account_size_1 and account_size_2) using the account_option toggle ("P1" or "P2"). The chosen size determines the total capital.
Risk % per Trade (risk_percent): This is the percentage of your chosen account size that you are willing to lose on a single trade. Example: 0.5% risk on a $180,000 account means you risk $900 per trade.
Trade Parameters
Entry Price, Stop Loss Price, Target Price: These are the manual prices a trader enters for their planned trade.
Reset All Inputs (enable_reset): A toggle to quickly clear the three price inputs by setting them to 0.
🧮 Key Calculations
The script calculates several critical values to determine the position size:
Risk per Trade: The actual dollar amount you are risking:
Account Size×(100Risk %)
Stop Distance: The price difference between the entry and stop-loss:
Entry Price−Stop Loss Price
(This assumes a Long trade; for a Short trade, the calculation would be reversed, but the magnitude must be positive for the next step).
Position Size: The maximum number of shares/contracts you can buy/sell while keeping the dollar risk within your Risk per Trade amount. This is the main output:
Position Size=Floor(Stop DistanceRisk per Trade)
The math.floor() function ensures the position size is a whole number (no fractional shares).
Capital Required: The total cost to open the calculated position:
Position Size×Entry Price
Risk/Reward (R:R) Ratio: The potential reward compared to the risk taken:
Stop DistanceTarget Price−Entry Price
Table Display & Customization
The script's output is displayed in a customizable table on the chart.
Display Toggles
A large section of boolean (input.bool) variables (e.g., show_position_size, show_rr_ratio) allows the user to turn on/off individual rows in the results table, customizing what information is shown.
Visual Settings
Table Position: The user can select one of four corners for the table (Top Right, Bottom Right, Top Left, Bottom Left).
Colors and Size: Extensive inputs are provided to customize the table's background, border, font size, and text colors.
Conditional Coloring
The script uses colors to provide quick visual warnings and checks on key metrics:
Risk % per Trade:
Green/Lime for ≤1.0% (Low Risk)
Orange for >1.0% and ≤2.0% (Medium Risk)
Red for >2.0% (High Risk)
R:R Ratio:
Green/Lime for ≥2 (Good)
Red for <2 (Bad)
Capital Check:
Green if Capital Required ≤ Account Size (Within Limit)
Red if Capital Required > Account Size (Exceeds Account)
Displayed Outputs
The table provides a comprehensive set of calculated metrics, including:
Current Ticker: The symbol of the asset being traded.
Position Size: The calculated share/contract quantity.
Risk per Trade: The dollar amount risked.
Stop Distance (pts/%): How far the stop-loss is from the entry price, in both price points and a percentage of the entry price.
Target Reward ($/%): The potential profit in dollars and as a percentage.
R:R Ratio: The calculated Risk/Reward ratio.
Target 1 (50%): Half the distance to the full target (potential partial take profit).
Target 2 (100%): The full target_price.
Capital Check: A quick status on whether the trade exceeds the total account size.
Summary: A single line detailing the trade direction (Long/Short), prices, size, and R:R ratio.
This indicator is a powerful tool for traders who want to maintain strict, quantifiable risk control on every position they take.
受保護腳本
此腳本以閉源形式發佈。 不過,您可以自由且不受任何限制地使用它 — 在此處了解更多資訊。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
受保護腳本
此腳本以閉源形式發佈。 不過,您可以自由且不受任何限制地使用它 — 在此處了解更多資訊。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。