M-Alpha-Liquidation - Liquidation Price and Warning Levels

What it does
M-Alpha-Liquidation draws the liquidation price of a leveraged position directly on the chart, together with two early warning levels. You click on the chart to set the entry, choose long or short, leverage and margin mode, and the script shows entry, warning 1, warning 2 and liquidation as lines with prices. A table shows how much of the way from entry to liquidation the current price has already used and a simple status: OK, Warning 1, Warning 2 or Liquidation price reached.
Example: BTC long at 80,466.6 with 10x isolated margin and a max leverage of 40x gives a liquidation price of 73,336.6 (-8.86 %), warning 1 (50 % of the way) at 76,901.6 and warning 2 (75 %) at 75,119.1.
How it works
1. Liquidation price: liq = entry - side * margin_available / size / (1 - mmr * side), with side = 1 for long and -1 for short. This is the formula published by Hyperliquid.
2. Margin available: isolated = position margin (notional / leverage) minus maintenance margin; cross = account value minus maintenance margin.
3. Maintenance margin: by default half of the initial margin at the asset's max leverage (for example 40x max = 1.25 %), as on Hyperliquid. For other exchanges you can enter the maintenance margin rate manually.
4. Warning levels: placed at a share of the distance between entry and liquidation (default 50 % and 75 %).
5. Way used: (entry - price) / (entry - liquidation), shown in percent on every bar.
6. Alerts: three alert conditions are available, for warning 1, warning 2 and the liquidation price.
How to use it
- Add the script, click on the chart where you entered, then set side, leverage and margin mode in the settings.
- For cross margin, enter the position size and the account value that backs it.
- Set the max leverage of the asset as listed on your exchange, or switch to a manual maintenance margin rate.
- Create alerts on the warning levels to act before the exchange does, for example by adding margin or reducing the position.
What makes it different
- Uses the exact exchange formula instead of the common rough estimate of 100 % divided by leverage.
- Works for isolated and cross margin.
- Shows early warning levels and the share of the way already used, not just a single liquidation line.
Limitations
- Exchanges with tiered maintenance margin can liquidate slightly earlier or later for large positions; set the rate to match your tier.
- Funding payments, fees and later changes to the position or account are not included. Update the inputs when the position changes.
- The liquidation price refers to the exchange's mark price, which can differ from the chart price.
- The script does not generate trading signals and makes no statement about future price movement.
M-Alpha-Liquidation draws the liquidation price of a leveraged position directly on the chart, together with two early warning levels. You click on the chart to set the entry, choose long or short, leverage and margin mode, and the script shows entry, warning 1, warning 2 and liquidation as lines with prices. A table shows how much of the way from entry to liquidation the current price has already used and a simple status: OK, Warning 1, Warning 2 or Liquidation price reached.
Example: BTC long at 80,466.6 with 10x isolated margin and a max leverage of 40x gives a liquidation price of 73,336.6 (-8.86 %), warning 1 (50 % of the way) at 76,901.6 and warning 2 (75 %) at 75,119.1.
How it works
1. Liquidation price: liq = entry - side * margin_available / size / (1 - mmr * side), with side = 1 for long and -1 for short. This is the formula published by Hyperliquid.
2. Margin available: isolated = position margin (notional / leverage) minus maintenance margin; cross = account value minus maintenance margin.
3. Maintenance margin: by default half of the initial margin at the asset's max leverage (for example 40x max = 1.25 %), as on Hyperliquid. For other exchanges you can enter the maintenance margin rate manually.
4. Warning levels: placed at a share of the distance between entry and liquidation (default 50 % and 75 %).
5. Way used: (entry - price) / (entry - liquidation), shown in percent on every bar.
6. Alerts: three alert conditions are available, for warning 1, warning 2 and the liquidation price.
How to use it
- Add the script, click on the chart where you entered, then set side, leverage and margin mode in the settings.
- For cross margin, enter the position size and the account value that backs it.
- Set the max leverage of the asset as listed on your exchange, or switch to a manual maintenance margin rate.
- Create alerts on the warning levels to act before the exchange does, for example by adding margin or reducing the position.
What makes it different
- Uses the exact exchange formula instead of the common rough estimate of 100 % divided by leverage.
- Works for isolated and cross margin.
- Shows early warning levels and the share of the way already used, not just a single liquidation line.
Limitations
- Exchanges with tiered maintenance margin can liquidate slightly earlier or later for large positions; set the rate to match your tier.
- Funding payments, fees and later changes to the position or account are not included. Update the inputs when the position changes.
- The liquidation price refers to the exchange's mark price, which can differ from the chart price.
- The script does not generate trading signals and makes no statement about future price movement.
Tested on unseen data, honest weekly results, no promises. malphacore.com · Shop: t.me/MAlphaCoreShopBot?start=tv
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Tested on unseen data, honest weekly results, no promises. malphacore.com · Shop: t.me/MAlphaCoreShopBot?start=tv
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.