OPEN-SOURCE SCRIPT
Updated

Risk Awareness

374
Risk Awareness - Liquidation Level Indicator

A clean, professional tool for displaying liquidation prices on leveraged positions. Designed for traders who need instant visibility of their risk levels without chart clutter.

KEY FEATURES

Real-time liquidation price calculation for long and short positions
Adjustable leverage from 1x to 200x
Fire engine red (long) and lime green (short) color-coded levels
Two label modes: Compact (minimal) and Detailed (full info)
Horizontal lines extending left from current price
Optional P&L tracking and display
Background alerts when approaching liquidation
Customizable maintenance margin and liquidation fee parameters

HOW IT WORKS

The indicator calculates liquidation prices using the standard formula:

Long Liquidation = Entry Price x (1 - 1/Leverage - Liquidation Fee + Maintenance Margin)
Short Liquidation = Entry Price x (1 + 1/Leverage + Liquidation Fee - Maintenance Margin)

Default parameters (0.5% maintenance margin, 0.5% liquidation fee) are calibrated for major crypto futures exchanges like Binance, Bybit, and OKX.

DISPLAY MODES

Compact Mode: Shows only leverage and price (e.g., "40x: 48750.00")
Detailed Mode: Shows full information including percentage distance and optional P&L

CUSTOMIZATION OPTIONS

Position Settings: Adjust leverage, toggle long/short, select entry price source
Custom Parameters: Fine-tune maintenance margin and liquidation fee for your specific exchange
Visual Settings: Colors, line width, label size, historical bands, disclaimer display
Alert Settings: Set distance threshold for liquidation warnings
Risk Management: Track unrealized P&L based on position size

ALERTS

Built-in alert conditions for:
Price crossing liquidation levels
Approaching liquidation threshold
Critical loss levels (50%+)

IMPORTANT DISCLAIMER

This indicator provides ESTIMATED liquidation levels for Tier 1 positions (small to medium size). Actual liquidation prices may vary due to:

- Position size tiers (larger positions = higher maintenance margins)
- Accumulated funding rates
- Market volatility and order book depth
- Cross margin vs isolated margin mode
- Exchange-specific liquidation engines

Always verify liquidation prices on your exchange platform before trading. This tool is for educational and risk awareness purposes only.

IDEAL FOR

Crypto futures traders on Binance, Bybit, OKX, and similar platforms
Day traders managing leveraged positions
Swing traders monitoring overnight risk
Anyone trading with leverage who needs clear visual risk management

PRO TIPS

Use Compact mode with Tiny/Small label size for minimal chart clutter
Enable the Info Table for detailed metrics when needed
Set Alert Distance to 1-2% for advance warning before liquidation
Toggle "Show Historical Bands" OFF (default) for cleaner charts
Adjust Custom Parameters if trading on exchanges with different fee structures

Stay aware. Trade smart. Manage your risk.
Release Notes
Risk Awareness - Market Structure Based Liquidation Calculator
Overview
Risk Awareness is an educational indicator designed to help traders understand their liquidation risk when using leverage. This tool calculates estimated liquidation levels based on market structure extremes from your selected timeframe, providing visual reference lines and leverage calculations.

Key Features
Two Operating Modes:

Auto Mode: Automatically calculates optimal leverage based on market structure extremes. The indicator finds the highest high and lowest low within your specified lookback period and calculates the exact leverage needed to place liquidation at those levels.
Manual Mode: Use your preferred fixed leverage setting while visualizing where your liquidation levels would be.
Liquidation Protection:

Optional safety buffer system that adjusts calculations to provide breathing room before actual liquidation
Auto Mode: Reduces leverage to place true liquidation further away from your target stop-loss level
Manual Mode: Shows an early warning line closer to entry price, alerting you before reaching actual liquidation
Adjustable buffer from 0.01% to 25%, default 0.05% for tight protection
Market Structure Analysis:

Analyzes any timeframe (1H, 4H, Daily, Weekly, Monthly, etc.)
Finds absolute price extremes within configurable lookback period (10-500 bars)
Dynamic leverage calculation based on actual distance from entry to structure level
Visual Display:

Clean horizontal lines showing liquidation levels
Compact labels displaying leverage and price
Separate toggle for long and short positions
Protection mode indicated by distinct label styling (black background with bright red/green text)
Adjustable label distance from current bar
How It Works
Leverage Calculation Formula: The indicator uses standard futures liquidation formulas to calculate leverage:

For Long Positions:

Leverage = 1 / (1 - (Target Price / Entry Price) - Liquidation Fee + Maintenance Margin)
For Short Positions:

Leverage = 1 / ((Target Price / Entry Price) - 1 - Liquidation Fee + Maintenance Margin)
Example:

Entry: $50,000
Weekly Low (target): $45,000 (10% below entry)
Calculated Leverage: Approximately 9-10x
Result: Liquidation occurs at $45,000
Customization Options
Position Settings:

Leverage Mode (Auto/Manual)
Manual Leverage (1-200x)
Timeframe for Structure Analysis
Max Lookback Bars (10-500)
Entry Price Source
Liquidation Protection toggle
Protection Buffer percentage
Custom Parameters:

Maintenance Margin (default 0.5%)
Liquidation Fee (default 0.5%)
Adjust these to match your specific exchange
Visual Settings:

Line colors for long/short
Show/hide lines and labels
Label distance adjustment
Disclaimer toggle
Use Cases
Swing Trading:

Set timeframe to Weekly or Monthly
Find major support/resistance levels
Calculate safe leverage for long-term holds
Day Trading:

Set timeframe to 4H or Daily
Identify recent swing highs/lows
Adjust position size based on structure
Risk Management:

Visualize exact liquidation points before entering trades
Compare different leverage scenarios
Use protection mode to build in safety margins
Important Disclaimers
This indicator is for EDUCATIONAL PURPOSES ONLY:

Does NOT provide trading signals or entry/exit recommendations
Does NOT constitute financial advice
Calculations are ESTIMATES based on standard formulas
Actual liquidation prices may vary due to:

Position size tiers and leverage limits per exchange
Funding rates and accumulated fees
Market volatility and slippage
Exchange-specific margin calculation methods
Cross margin vs isolated margin mode differences
Mark price vs last price calculations
Always verify liquidation levels directly on your exchange before trading.

Best Practices
Verify Settings: Ensure maintenance margin and liquidation fee match your exchange
Check Multiple Timeframes: Compare structure across different timeframes for confluence
Use Protection Mode: Enable buffer for additional safety margin
Test First: Paper trade or use small positions to verify calculations match your exchange
Stay Informed: Market conditions change - recalculate regularly
Technical Specifications
Pine Script Version 5
Works on all instruments and timeframes
Maximum 500 lines on chart
No repainting - uses confirmed historical data
Compatible with both light and dark themes
Credits
Developed for traders who want to understand and visualize their leverage risk using objective market structure rather than arbitrary percentages or emotions.

Remember: High leverage amplifies both gains and losses. This tool helps you understand the risk, but YOU are responsible for your trading decisions. Trade responsibly.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.