OPEN-SOURCE SCRIPT

Ultimate Position Sizing Tool

278
AntiGravity Risk Pro v2

A complete position-sizing and risk-management tool for crypto futures.

AntiGravity Risk Pro v2 is designed to help you calculate the appropriate position size before entering a trade, based on your account size, risk, entry, stop-loss and trade parameters.

The indicator is built for linear USDT and USDC crypto futures and is designed to plan one isolated-margin position at a time.

The goal is simple:

Define your risk first → define your invalidation → calculate your position size.

---

🔹 What Does It Calculate?

The indicator brings several important calculations into one dashboard:

- Position / order size

- Base-asset quantity

- Risk amount

- Potential target profit

- Gross R:R

- Net R:R

- Break-even price


- Initial margin

- Notional value

- Fee reserves

- Funding reserve

- Leverage

- Leverage cap

- Estimated liquidation price

- Liquidation distance / buffer

- Capital allocation

- Exchange quantity and notional limits


This allows you to plan the entire position before placing the order.

---

🔹 1. Account & Risk

Equity

Enter your total trading account equity.

Risk Mode

Choose between:

Account % — risk a percentage of your account.

Fixed $ — risk a specific dollar amount.


Example:

$1,000 account × 1% risk = $10 risk budget

Max Capital Allocation

Limits how much of your available capital can be committed to the position.

This is separate from risk.

Risk % = how much you can lose.
Capital Allocation % = how much capital can be committed.

Available Balance

Use either your full equity as available balance or manually enter your actual free margin.

---

🔹 2. Trade Setup


Select:

Long / Short

Then define your entry.

Entry Modes

Market / Floating
Uses the current price and continuously updates the plan.

Manual Price
Enter your own planned entry.


Reference Bar Close
Use the close of a selected historical/reference candle.

---

🔹 3. Stop-Loss

You have three options:

Entry %

Set the stop as a percentage from entry.

Manual Price

Enter the exact stop-loss price.

ATR


Calculate the stop using ATR length and multiplier.

The indicator automatically checks that the stop is on the correct side of the entry.

For example:

Long → SL below entry
Short → SL above entry


---

🔹 4. Take-Profit

Choose between:

Net R:R

Calculates the target using your desired R:R while considering modeled trading costs.


Gross R:R

Uses pure price-distance R:R without incorporating those costs into the target calculation.

Entry %

Set the target as a percentage from entry.

Manual Price

Enter your exact target price.


The indicator also calculates the resulting Net R:R so you can see how costs affect the trade.

---

🔹 5. Fees, Slippage & Funding

The tool allows you to include:

- Entry fee

- Exit fee

- Entry slippage

- Exit slippage

- Funding reserve


This makes the risk and reward calculation more realistic than simply using the distance between entry and stop.

Use fee values appropriate to your exchange and trading tier.

---

🔹 6. Leverage & Liquidation

Leverage

Choose:

Auto — calculates leverage based on the model's requirements and limits.

Manual — specify your own leverage.

Maximum Leverage

Set the maximum leverage allowed by your exchange/contract.


Maintenance Margin Rate

Used by the simplified liquidation model.

Liquidation Buffer

Adds a safety distance between your stop and the estimated liquidation level.

Estimated Liquidation Price


The indicator provides a model-based liquidation estimate based on your configured assumptions.

⚠️ Important: This is NOT your exchange's exact liquidation price. Actual liquidation depends on the exchange's mark price, maintenance margin, risk tier, fees and other exchange-specific rules.

---

🔹 7. Exchange / Contract Settings

You can configure the important execution constraints:

- Contract multiplier

- Price tick size

- Quantity step

- Minimum quantity

- Minimum notional

- Maximum quantity

- Maximum notional

- Maximum leverage

The calculated quantity is rounded according to the configured quantity step and price tick.

This helps make the calculated position more realistic for actual exchange execution.

---

🔹 8. Auto-Resize

Auto-Resize can automatically reduce the calculated position when it exceeds configured constraints such as:

- Capital allocation

- Available balance

- Maximum quantity

- Maximum notional

- Leverage limits

If the position has been reduced because of a capital constraint, the dashboard clearly indicates that it was resized for capital.

---

🔹 9. Dashboard

The on-chart dashboard gives you the most important information at a glance.

Depending on the display mode, you can see:

Order Size
The calculated quantity and base-asset amount.

Entry / SL / TP
Your complete trade plan.

Risk / Target $
Estimated loss at SL and profit at TP.


Net R:R / BE
Net reward-to-risk and modeled break-even.

Leverage / Margin
Selected leverage and required initial margin.

Notional
Total position value.

Estimated Liquidation
Model-based liquidation level and distance.


Capital / Reserve
Capital requirement and fee/funding reserve.

Plan Status
Shows whether the plan is valid, resized or invalid, including the reason when something fails.


---

🔹 10. Chart Visualization

You can display:

- Entry line

- Stop-loss line

- Take-profit line

- Break-even line

- Estimated liquidation line

- Profit zone

- Risk zone

- Price labels

You can also control the lookback and label position to keep the chart clean.

A compact one-row HUD is available when you want only the essential information.

---

🔹 11. Trade Monitoring

The indicator also includes an optional monitoring system for fixed trade plans.

You can define a start time, and the indicator can monitor confirmed chart bars for:

- Stop-loss touched

- Take-profit touched

- Both SL and TP touched on the same candle

If both levels are touched within the same candle, the indicator does not assume which happened first because normal OHLC data cannot reliably determine intrabar order.

Alerts are available for these monitoring events.

⚠️ These are chart-level observations, not confirmed exchange fills.

---

🔹 Recommended Workflow

Before every futures trade:

1. Choose Long or Short

2. Define your entry

3. Define your actual invalidation / stop-loss

4. Choose your risk


5. Configure fees, slippage and funding

6. Set leverage and exchange limits

7. Check the calculated position size

8. Review Risk, Margin, Net R:R and Liquidation Buffer

9. Verify the final numbers on your exchange

10. Execute according to your trading plan

---

🔹 The Key Principle

Don't start with:

«“How much do I want to buy?”»

Start with:

«“How much am I willing to lose if this trade is wrong?”»

Then define where the trade is invalidated.

Your position size should be the result of your risk management, not the starting point.

A wider stop generally means a smaller position.

A tighter stop generally allows a larger position for the same risk.

This is how position sizing should work.


---

⚠️ Important

This indicator is a position-sizing and trade-planning tool, not a trading signal.

It does not predict price, provide entries, guarantee profits or place orders.

The model is designed for:

Linear USDT/USDC Futures
Isolated Margin
One Position


It does not model the full behavior of cross/portfolio margin.

Actual exchange execution may differ because of slippage, liquidity, fees, funding, mark price, maintenance margin, risk tiers and exchange-specific rules.

Always verify the final position size, margin, leverage and liquidation information directly on your exchange before trading.

Trade with a plan. Manage your risk. Let the position size follow the mathematics.

Mr. Signal ❤️

Disclaimer

This indicator is provided for educational and informational purposes only and is not financial or investment advice. Cryptocurrency and leveraged futures trading involve substantial risk and can result in significant losses, including loss of capital.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。