PROTECTED SOURCE SCRIPT
更新済

Risk Management Plan (Shares)

458
What it does

This indicator displays a compact risk-management panel on the chart (middle-right). It helps you size positions, quantify risk in % and $, estimate shares to buy, and derive suggested stop/target prices from your chosen risk and R/R ratio. It also shows the % move from entry to stop/target and a “Max. Share Price (per system)” threshold derived from your accepted loss and R/R.

Why it’s useful

Many losses come from oversizing and inconsistent risk. This panel keeps the key numbers in one place—capital exposure, shares, stop/target math, and % distances—so your trade planning remains disciplined and repeatable.

Inputs

1. Capital Size ($)
2. Position Size (%)
3. Defined Risk (%) on capital
4. R/R Ratio (R:1) – enter R
5. Entry Price ($) (optional; if 0, the script uses close

Calculations (key formulas)

1. Position Size ($) = Capital × Position Size (%)
2. Shares to Buy = floor(Position Size ($) ÷ Entry Price)
3. Defined Risk ($) = Capital × Defined Risk (%)
4. Suggested Stop Price = (Position Size ($) − Defined Risk ($)) ÷ Shares
5. Suggested Target Price = (Position Size ($) + Defined Risk ($) × R) ÷ Shares
6. Entry → Stop (%) = (Entry − Stop) ÷ Entry × 100 (displayed negative)
7. Entry → Target (%) = (Target − Entry) ÷ Entry × 100
8. Max. Share Price (per system) = Position Size ($) × R ÷ |Defined Risk ($)|

How to use

1. Set Capital Size, Position Size (%), Defined Risk (%), and R/R.
2. Optionally set Entry Price (otherwise the script uses the chart’s close).
3. Read the panel: entry (blue), stop values (red), target values (green), risk (%) and ($) displayed negative for clarity.
4. Use Max. Share Price (per system) as a quick threshold check under your risk assumptions.

Note: If the Suggested Target or Suggested Stop is not aligned with your trading plan, adjust Position Size (%), R/R Ratio, and/or Defined Risk (%). The panel will update the levels accordingly so you can match your plan.

Notes & limitations

* Indicator only (no signals or strategy backtest).
* No lookahead/repainting; values depend on user inputs and current chart data.
* Educational use only; trading involves risk. Consider fees, slippage, and market conditions.

Version: v1.0 – Initial release (Pine Script v6)
リリースノート
What it does

This indicator displays a compact risk-management panel on the chart (middle-right). It helps you size positions, quantify risk in % and $, estimate shares to buy, and derive suggested stop/target prices from your chosen risk and R/R ratio. It also shows the % move from entry to stop/target and a “Max. Share Price (per system)” threshold derived from your accepted loss and R/R.

Why it’s useful

Many losses come from oversizing and inconsistent risk. This panel keeps the key numbers in one place—capital exposure, shares, stop/target math, and % distances—so your trade planning remains disciplined and repeatable.

Inputs:

• Capital Size ($)
• Position Size (%)
• Defined Risk (%) on capital
• R/R Ratio (R:1) – enter R
• Entry Price ($) (optional; if 0, the script uses close)

Calculations (key formulas):

• Position Size ($) = Capital × Position Size (%)
• Shares to Buy = floor(Position Size ($) ÷ Entry Price)
• Defined Risk ($) = Capital × Defined Risk (%)
• Suggested Stop Price = (Position Size ($) − Defined Risk ($)) ÷ Shares
• Suggested Target Price = (Position Size ($) + Defined Risk ($) × R) ÷ Shares
• Entry → Stop (%) = (Entry − Stop) ÷ Entry × 100 (displayed negative)
• Entry → Target (%) = (Target − Entry) ÷ Entry × 100
• Max. Share Price (per system) = Position Size ($) × R ÷ |Defined Risk ($)|

How to use:

1. Set Capital Size, Position Size (%), Defined Risk (%), and R/R.
2. Optionally set Entry Price (otherwise the script uses the chart’s close).
3. Read the panel: entry (blue), stop values (red), target values (green), risk (%) and ($) displayed negative for clarity.
4. Use Max. Share Price (per system) as a quick threshold check under your risk assumptions.
5. Note: If the Suggested Target or Suggested Stop is not aligned with your trading plan, adjust Position Size (%), R/R Ratio, and/or Defined Risk (%). The panel will update the levels accordingly so you can match your plan.

Notes & limitations:

• Indicator only (no signals or strategy backtest).
• No lookahead/repainting; values depend on user inputs and current chart data.
• Educational use only; trading involves risk. Consider fees, slippage, and market conditions.

Version: v1.1 – Initial release (Pine Script v6).
リリースノート
What it does

This indicator displays a compact risk-management panel on the chart (middle-right). It helps you size positions, quantify risk in % and $, estimate shares to buy, and derive suggested stop/target prices from your chosen risk and R/R ratio. It also shows the % move from entry to stop/target and a “Max. Share Price (per system)” threshold derived from your accepted loss and R/R.
Why it’s useful

Many losses come from oversizing and inconsistent risk. This panel keeps the key numbers in one place—capital exposure, shares, stop/target math, and % distances—so your trade planning remains disciplined and repeatable.

Inputs:

• Capital Size ($)
• Position Size (%)
• Defined Risk (%) on capital
• R/R Ratio (R:1) – enter R
• Entry Price ($) (optional; if 0, the script uses close)

Calculations (key formulas):

• Position Size ($) = Capital × Position Size (%)
• Shares to Buy = floor(Position Size ($) ÷ Entry Price)
• Defined Risk ($) = Capital × Defined Risk (%)
• Suggested Stop Price = (Position Size ($) − Defined Risk ($)) ÷ Shares
• Suggested Target Price = (Position Size ($) + Defined Risk ($) × R) ÷ Shares
• Entry → Stop (%) = (Entry − Stop) ÷ Entry × 100 (displayed negative)
• Entry → Target (%) = (Target − Entry) ÷ Entry × 100
• Max. Share Price (per system) = Position Size ($) × R ÷ |Defined Risk ($)|

How to use:

1. Set Capital Size, Position Size (%), Defined Risk (%), and R/R.
2. Optionally set Entry Price (otherwise the script uses the chart’s close).
3. Read the panel: entry (blue), stop values (red), target values (green), risk (%) and ($) displayed negative for clarity.
4. Use Max. Share Price (per system) as a quick threshold check under your risk assumptions.
5. Note: If the Suggested Target or Suggested Stop is not aligned with your trading plan, adjust Position Size (%), R/R Ratio, and/or Defined Risk (%). The panel will update the levels accordingly so you can match your plan.

Notes & limitations:

• Indicator only (no signals or strategy backtest).
• No lookahead/repainting; values depend on user inputs and current chart data.
• Educational use only; trading involves risk. Consider fees, slippage, and market conditions.

Version: 1.2 – Initial release (Pine Script v6).
リリースノート
Risk Management Plan (v1.3)

What it is

A clean, on-chart risk & position sizing panel for equities. It standardizes your process: size the trade, cap risk, and see suggested Stop/Target levels with consistent rounding and clear color cues.

This is not a buy/sell signal. Educational tool only.

How it works

You provide Capital, Position Size Rule (%), Risk per Trade (%) (on total capital), R/R Ratio (R:1), and an optional Entry Price (leave 0 to use the current close). The panel (right-center) computes:

Inputs:
• Capital Size ($)
• Position Size Rule (%)
• Risk per Trade (%)
• R/R Ratio (R:1)
• Entry Price ($) (manual; 0 = close)

Outputs on the panel:

• Max Position Size ($)
• Max Share Price (per risk system)
• Shares to Buy (integer, always rounded down)
• Real Position Size ($) = Entry × Shares
• Real Position Size (%) = Real / Capital
• Suggested Stop Price (rounded up to 2 decimals)
• Entry to Stop (%) (displayed negative, red)
• Suggested Target Price (rounded up to 2 decimals)
• Entry to Target (%)
• Real Expected Loss ($) = (Stop × Shares) − Real Position (red)
• Real Expected Gain ($) = (Target × Shares) − Real Position (green)

Note: If the suggested Target or Stop doesn’t match your plan, adjust Position Size Rule (%), R/R Ratio, and/or Risk per Trade (%). Levels will update accordingly.

Quick start:

1. Add the indicator to the chart of the stock you’re analyzing.
2. In Inputs, set Capital, Position Size Rule, Risk per Trade, R/R Ratio, and Entry Price (optional).
3. Review the panel (right-center). R/R shows with a green background; risk/negative metrics are red; entry value is blue.
4. Use Shares to Buy (integer) plus Suggested Stop/Target as your baseline.
5. If levels don’t fit, tweak the inputs until they align with your plan.

Rounding & formatting rules:

• Shares to Buy: floor (always down, no decimals).
• Suggested Stop/Target: ceil to 2 decimals (always up).
• Percentages: 2 decimals.
• Risk (%) displayed as negative.
• Color scheme: red = risk/loss, green = target/gain, blue = entry.

Disclaimer:

This script is for education and information only and is not financial advice or a trade recommendation. Use at your own risk.
________________________________________
What’s new in v1.3
• ✅ Shares to Buy restored to the panel (integer, rounded down).
• ✅ Added Real Position Size (%) (ceil to 2 decimals).
• ✅ Suggested Stop/Target now use consistent round-up to 2 decimals; percentages are derived from those rounded levels.
• ✅ Added Real Expected Loss/Gain ($) at the end of the panel.
• ✅ Labels refined to trading jargon; R/R highlighted with green background & white text.
リリースノート
Risk Management Plan — Update v1.4

What’s new:

• Conditional rule check: Max Share Price (per risk system) now shows green when Entry ≤ MaxPrice (within risk rule), red when it exceeds, and gray when not applicable.
• Compact styling: That same row uses a smaller font to keep the panel tidy.
• Final reminder banner: Added a merged-row note at the bottom — “¡No setup, No trade! 🚫” — centered for visibility.
• Kept by demand: Shares to Buy is back in the panel (integer, always rounded down).

Recap (what the panel does):

On-chart risk & position sizing for equities. You set Capital, Position Size Rule (%), Risk per Trade (%) (on total capital), R/R Ratio (R:1) and optionally Entry Price (leave 0 to use the current close). The panel computes and displays:

• Max Position Size ($)
• Max Share Price (per risk system) (now color-coded)
• Shares to Buy (integer, floor)
• Real Position Size ($) = Entry × Shares
• Real Position Size (%) = Real / Capital
• Suggested Stop Price (rounded up to 2 decimals)
• Entry to Stop (%) (shown negative, red)
• Suggested Target Price (rounded up to 2 decimals)
• Entry to Target (%)
• Real Expected Loss ($) = (Stop × Shares) − Real Position (red)
• Real Expected Gain ($) = (Target × Shares) − Real Position (green)

Tip: If the suggested Target or Stop doesn’t fit your plan, adjust Position Size Rule (%), R/R Ratio, and/or Risk per Trade (%). Levels will update accordingly.

Rounding & formatting:

• Shares to Buy: floor (always down, no decimals).
• Suggested Stop/Target: ceil to 2 decimals (always up).
• Percentages: 2 decimals.
• Risk (%) displayed as negative.
• Color scheme: red = risk/loss, green = target/gain, blue = entry.

How to use:

1. Add the indicator to the stock you’re analyzing.
2. In Inputs, set Capital, Position Size Rule, Risk per Trade, R/R Ratio, and Entry (optional).
3. Review the right-center panel. Use Shares to Buy plus the suggested Stop/Target as your baseline, then refine inputs until they match your plan.

Disclaimer:
This script is for education and information only. It is not financial advice and not a buy/sell signal. Use at your own risk.
リリースノート
What’s new

• Fixed, non-draggable box: Rebuilt with line.new + linefill.new on the last bar; previous objects are deleted each tick, so the visuals always lock to price (no mouse dragging, no drift with zoom/scale).
• Customizable colors (Style tab): Pick colors for Profit Area, Loss Area, and each label (Target, Stop, Entry).
• Clearer labels: “TP” → Target, “TSL” → Stop Loss.
• New Entry label: Blue by default, placed at your Entry Price.
• Width control: Bars ahead (width) to set the horizontal size of the box.
• Core math unchanged: Same sizing, rounding, and table you’re used to.

How to use:

1. Set Capital Size ($), Position Size (%), Defined Risk (%), R/R Ratio (R:1), and Entry Price ($).
2. The script computes:
o Shares to Buy (floored to an integer)
o Real Position Size ($/%)
o Suggested Stop/Target (ceil to 2 decimals)
o Entry→Stop / Entry→Target (%)
o Real Expected Loss/Gain ($)
3. The chart displays a non-draggable box from Entry→Target (green fill) and Entry→Stop (red fill), plus three labels: Target, Stop Loss, Entry Price.

Tips

• If nothing appears, make sure Entry Price > 0 and Shares to Buy ≥ 1.
• The drawing updates only on the last bar (live or replay) to guarantee stability.
• Adjust Bars ahead (width) to suit your timeframe/viewport.

Scope: This version is long-only by design.

Disclaimer: For educational use only. Not financial advice.
リリースノート
What’s new:

• Label text colors (per type): added inputs to set Target, Stop Loss, and Entry Price label text colors independently.
• Entry Price label: new blue label anchored at the entry level.
• Label wording: renamed TP → Target and TSL → Stop Loss for clarity.

Visual & UI

• Zoom-proof TP/SL block retained (price-anchored lines + linefill, recreated each bar with new + delete[1] so it never drifts or becomes draggable).
• Right-panel table layout: now uses 3 columns with a merged right spacer to prevent overlap with the price axis.
• Table outline restored: full top/left/bottom border visible for a neat card look.
• Style controls: keep full control over profit/loss area fills, label backgrounds, and now label text colors.

Defaults & logic

• R/R default set to 3.0 (enter the “R” and the script computes target accordingly).
• All sizing/risk math unchanged: shares rounded down, Max Share Price (per risk system) shown, and real expected $ loss/gain calculated.

Notes

• Objects are auto-recreated on the last bar to stay fixed under zoom/scale.
• Spacer column is intentionally subtle to keep the table readable next to the axis.
リリースノート
Update: Added Daily ATR + Estimated Time to Target/Stop (Sessions)

This update introduces three new rows in the right-side table:

1. ATR Daily ($)

- The script now displays the Daily ATR (ATR 14, Wilder) using a Daily timeframe request (request.security(..., "D", ta.atr(14))).
- This keeps the volatility reference consistent across chart timeframes, so even if you are viewing 1H/4H, the ATR shown is still Daily.

2. Time to Target (Est.) and Time to Stop (Est.)

- The script now provides an estimated number of trading sessions required to reach the Target or Stop level.

How the session estimate is computed

ATR measures the average daily range (movement magnitude), not direction. Price rarely moves in a straight line toward a level; part of the daily range is usually “spent” in pullbacks, wicks, and sideways action.

To turn Daily ATR into a practical estimate of net progress per session, the script uses a conservative efficiency assumption:

- Expected net progress per session ≈ 0.45 × Daily ATR

Then the time estimate is:

- Time to Stop (sessions) = CEIL( Distance to Stop ÷ (0.45 × ATR Daily) )
- Time to Target (sessions) = CEIL( Distance to Target ÷ (0.45 × ATR Daily) )

Where:

Distance to Stop = Entry − Stop
Distance to Target = Target − Entry

CEIL() rounds up to the next full session.

Notes:

- These values are estimates, not predictions. Markets can reach levels faster or slower depending on regime changes, gaps, and volatility expansion/contraction.
- The 0.45 factor is a baseline meant to reflect non-linear price behavior (zigzags). It does not imply directional edge and should be used as a planning metric only.
リリースノート
Update: Breakeven Zone (1:1) Visualization + Table Row

This update adds a new Breakeven zone ($) level (the 1:1 point) to improve trade planning and risk clarity.

* Breakeven zone ($) is calculated as the price where the position reaches +1R:
Breakeven Price = Entry Price + (abs(Real Expected Loss $) / Shares)
(i.e., the same distance above Entry as the Stop is below Entry).

* The script now draws the Breakeven level on the chart and highlights the area between Entry and Breakeven with a dedicated fill, similar to the Profit/Loss areas.

* A label is placed directly at the Breakeven price level for clear visual alignment.

Notes: This feature is a visual planning aid only. It does not predict price direction or outcomes.
リリースノート
Update: Optional Manual Stop/Target + Breakeven Zone + Daily ATR Time Estimates

This update adds three major improvements while keeping the original risk plan structure intact:

Optional Manual Stop & Target Inputs
You can now enter Stop Price ($) and/or Target Price ($) manually.

If left at 0, the script behaves exactly as before (levels are calculated from your risk model and R/R input).

If provided, the script uses your manual levels and automatically recalculates the remaining risk metrics (implied risk $, implied risk %, and the effective R/R).

Breakeven Zone (1:1 level)
A new Breakeven zone ($) is displayed to show the 1R (1:1) price level based on your active risk.
Formula:
Breakeven Price = Entry Price + |Real Expected Loss ($)| / Shares
This is also visualized on the chart as a dedicated highlighted area with its own label.

Daily ATR + Estimated Time to Target/Stop (in sessions)
The table now includes ATR Daily ($) (ATR(14) from the Daily timeframe) and two new estimates:

Time to Target (Est.)

Time to Stop (Est.)

Estimation approach (volatility-based, not directional):

Compute a conservative daily progress proxy: Daily Progress ≈ 0.45 × ATR(14) Daily

Convert distance into an estimated number of sessions:

Sessions to Target ≈ ceil((Target − Entry) / Daily Progress)

Sessions to Stop ≈ ceil((Entry − Stop) / Daily Progress)

Notes: ATR measures average movement, not direction. These time estimates are rough planning heuristics, not predictions and not trading advice.
リリースノート
Update: “Max. time into Op.” + Time-to-Target Feasibility Check

This update adds a new planning control to the risk table:

New input: Max. time into Op. (sessions)
Define the maximum number of daily sessions you are willing to stay in the trade.

Updated table logic: Time to Target (Est.) now includes a feasibility marker:

✅ if Time to Target (Est.) ≤ Max. time into Op.
❌ if Time to Target (Est.) > Max. time into Op.

How the estimate is computed (volatility-based, not directional):

Daily ATR is taken from the Daily timeframe: ATR(14).
A conservative “daily progress” proxy is used: Daily Progress ≈ 0.45 × ATR(14) Daily.

Then: Time to Target (Est.) ≈ ceil((Target − Entry) / Daily Progress).

Notes: ATR measures average movement, not direction. This feature is intended for time budgeting and scenario planning only. It is not a prediction and not financial advice.
リリースノート
Update: Manual Stop → Auto Target (RR-based) + Symmetric Fallback

This update improves the optional manual level workflow:

* If you manually set Entry and Stop but leave Target Price (optional) at 0, the script now automatically calculates the Target using your defined R/R:

  • 1R = Entry − Stop
  • Target = Entry + (1R × R/R)


* Symmetric behavior is also included:

If you manually set Entry and Target but leave Stop Price (optional) at 0, the script calculates the Stop from the same R/R logic:

Stop = Entry − (Target − Entry) / R/R

If both Stop and Target are provided, the script respects both manual inputs.
If neither is provided, the script behaves exactly as before (original computed levels).

Notes: This change aligns the plotted areas/labels and risk metrics with the actual distance-based risk implied by your manual Stop/Target inputs. This tool is for planning/visualization only and is not financial advice.
リリースノート
Update: Visual/UX refinements (no logic changes)

• Improved readability by introducing dedicated text contrast colors:
o Added a darker red for text on white backgrounds (Stop / Loss / “Time to Stop”) to enhance legibility.
o Adjusted the Breakeven Zone value text to an amber tone to match the breakeven area theme and avoid competing with the Entry blue.

• Compliance markers updated to hard rules:
o Risk per Trade, R/R Ratio, and Real Position Size now display ✅ when within limits and ❌ when limits are violated.

• Iconography cleanup:
o Entry Price now uses a price-tag icon (🏷️) and all icons are placed at the end of the value with consistent spacing (no trailing spaces).

Notes:
• No changes were made to the existing table layout, cell fills, or calculation logic.
• This script remains an educational risk-planning tool; it does not generate trade signals.
リリースノート
This update adds an optional “Shares to Buy (optional)” input.

• If Shares to Buy = 0, the script keeps the original behavior and automatically calculates position size (shares) from your Account Capital and Position Size Rule.
• If you enter a value > 0, the script uses your manual share count and recalculates all risk-management outputs accordingly (real position size, stop/target projections, real risk %, real R/R, and time estimates).

No changes were made to the existing table layout, colors, or overall structure—this is strictly an additional sizing option for traders who prefer defining shares manually.

Note: This indicator is for informational/educational purposes only and is not financial advice.
リリースノート
Updated the table layout: **“Real Expected Gain ($)”** is now displayed directly below **“Real Expected Loss ($)”**.
リリースノート
This update adds new visualization controls to keep the chart cleaner and fully user-configurable:

• Added separate toggles to show/hide:
o Breakeven zone fill
o Breakeven label
o TRIM label
• TRIM is now available as an optional label on the chart, driven by the TRIM (%) input.
• No changes to the risk/position calculations or the table logic—this is a display/UX enhancement only.

As always, this script is for educational purposes and does not constitute financial advice.
リリースノート
Table order fix

• Minor UI refinements only — no changes to the calculation logic.

Note: This script is for planning/education purposes and does not constitute financial advice.
リリースノート
Optional Area Visibility Controls

Added new visibility toggles to show/hide the Profit area, Loss area, and Breakeven area independently.

This update is display-only: all calculations, sizing logic, risk metrics, labels, and table values remain unchanged
リリースノート
Minor formatting tweak: “Real R/R Ratio (R:1)” in the table is now displayed with 1 decimal (e.g., 3.2:1) for cleaner readability.

免責事項

この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。