OPEN-SOURCE SCRIPT

Risk & Position Sizing Calculator

195
LEGAL DISCLAIMER — READ FIRST

**This script and this description are for EDUCATIONAL PURPOSES ONLY.**

- This is **not** investment advice, a trading recommendation, or a solicitation to buy or sell any stock, index, or F&O (Futures & Options) contract.
- Nothing in this script or description constitutes a recommendation to trade Nifty, Bank Nifty, or any stock, in cash, futures, or options.
- The script does **not** predict market direction and does **not** guarantee profit. Past performance of any rule-set (including the EMA-crossover logic used here) does not guarantee future results.
- Trading in equities, futures, and options carries a **high risk of loss**, including the possible loss of your entire invested capital, and is not suitable for everyone.
- All entries, exits, position sizes, and trading decisions remain **solely your own responsibility**.
- Please independently verify all information and **consult a SEBI-registered Investment Adviser** before making any trading or investment decision.
- The creator of this script accepts **no liability** for any financial loss arising from its use.

By using this script, you acknowledge that you understand and accept the above.

---

1. What This Script Is

A **risk and position-sizing calculator** for TradingView, with an **optional mechanical signal add-on**. It does two separate jobs:

1. **Risk Calculator (always on):** tells you how many lots you could safely trade on any chart (Nifty, Bank Nifty, or a stock), given your capital and risk tolerance — the math, not a prediction.
2. **Signal Add-on (optional, toggle on/off):** plots a Buy marker based on one fixed technical rule (EMA crossover, optionally RSI-filtered), then tracks that trade and marks profit-booking levels (T1/T2/T3) and stop-loss on the chart, with alerts.
3 hours ago
Release Notes
ns on top of any chart (Nifty, Bank Nifty, or a stock) and answers: "If I enter here, how many lots can I safely trade given my capital and risk tolerance?"
1. Inputs (4 setting groups)

Capital & Risk — your capital, risk % per trade, and Caution/High-Risk thresholds that color-code the dashboard.
Stop-Loss Method — ATR-based (volatility-derived) or Swing High/Low (distance to recent swing point).
Contract Details — lot size (65 for Nifty by default, editable) and direction (Long/Short).
Targets — T1/T2/T3 as multiples of your risk (1R, 2R, 3R), mirroring the T1/T2/T3 in your original screenshot.

2. Calculations

Uses current close as "entry."
Computes stop-loss distance via ta.atr() × multiplier, or highest/lowest price over your lookback.
Derives stop-loss price and the three target prices as R-multiples from entry.
Computes risk amount (capital × risk%), risk per lot (SL distance × lot size), and max safe lots (risk amount ÷ risk per lot) — the same math behind "Safe Lots" in your dashboard tool.
Flags a zone: SAFE / CAUTION / HIGH RISK based on your risk % vs. the thresholds.

3. Visuals

Dashed/dotted lines on the chart for entry, stop-loss, and the three targets.
A dashboard table (top-right corner) showing all the numbers, updated on the latest bar.

What it doesn't do: pull option-chain data (strike, premium, decay) — not accessible

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。