OPEN-SOURCE SCRIPT
Live Position Tracker Leverage Calculator

Live Position Tracker Leverage Calculator
A leverage and position calculator that lives on your chart. Set your entry candle, entry price, take profit, and stop loss with a few clicks and get an instant visual breakdown of the trade — risk, reward, liquidation distance, breakeven, and live PnL — all anchored to the actual candle you entered on.
Unlike static calculator widgets, this tool tracks your trade from entry to exit. It records the best and worst points your position reached, counts how many bars you've held, and freezes everything when the trade closes so you have a clean snapshot of how it played out.
WHAT GETS PLOTTED ON THE CHART
· Entry, Take Profit, and Stop Loss lines anchored from your entry candle forward
· Liquidation price line (calculated from your leverage and maintenance margin)
· Breakeven line (entry adjusted for fees)
· Filled zones between entry/TP (green) and entry/SL (red)
· Best Point and Worst Point markers showing the maximum favorable and adverse excursion the trade reached
· Live PnL label that updates with current price
WHAT'S IN THE INFO PANEL
· Position: capital, notional, quantity, maintenance margin, fee rate
· Outcomes: live PnL, projected PnL at TP, projected loss at SL, risk-to-reward ratio
· Liquidation: liquidation price, distance to liquidation, round-trip fees
· Trade history: bars in trade, best point reached, worst point reached
· Status: pending entry, active, target hit, stop hit, or liquidated
KEY FEATURES
· Click-to-set workflow: TradingView prompts you to click the entry candle, entry price, TP, and SL when you add the indicator
· Auto direction detection from your TP and SL placement (or manually force Long/Short)
· Liquidation calculator with adjustable maintenance margin (works for any exchange — set the value from your exchange's tier table)
· Sanity warnings: flags when stop loss is past the liquidation price, or when TP/SL are on the wrong side of entry
· Trade tracking freezes the moment any exit (TP/SL/liquidation) is hit, giving you a clean post-trade snapshot
· Three independent color systems: on-chart tag colors, Live PnL label colors, and panel theme — each customizable without affecting the others
· Customizable line widths, label colors, font color, and panel theme (dark, light, or fully custom)
· Adjustable label offsets and stagger so the chart never gets cluttered regardless of timeframe or symbol
· Alerts for TP, SL, liquidation, and breakeven crossings
MAINTENANCE MARGIN REFERENCE
Maintenance margin (MMR) is the minimum equity percentage required to keep your leveraged position open. The default 0.5% is roughly accurate for BTC/ETH on major exchanges, but real values vary:
· BTC/ETH majors: 0.4 – 0.5%
· Top 20 alts: 0.5 – 1.0%
· Mid-cap alts: 1.0 – 2.5%
· Low-cap and meme coins: 2.5%+
For accurate liquidation calculations, find your exchange's exact MMR for your symbol and position size.
NOTES
The liquidation price is a simplified isolated-margin approximation and does not account for tiered margin requirements at different position sizes. Always verify against your exchange's actual liquidation calculator before sizing real positions.
This tool calculates risk-to-reward as the gross price-distance ratio (matching TradingView's built-in long/short position tool). The fee-adjusted dollar amounts are shown separately in the "If TP Hit" and "If SL Hit" rows.
A leverage and position calculator that lives on your chart. Set your entry candle, entry price, take profit, and stop loss with a few clicks and get an instant visual breakdown of the trade — risk, reward, liquidation distance, breakeven, and live PnL — all anchored to the actual candle you entered on.
Unlike static calculator widgets, this tool tracks your trade from entry to exit. It records the best and worst points your position reached, counts how many bars you've held, and freezes everything when the trade closes so you have a clean snapshot of how it played out.
WHAT GETS PLOTTED ON THE CHART
· Entry, Take Profit, and Stop Loss lines anchored from your entry candle forward
· Liquidation price line (calculated from your leverage and maintenance margin)
· Breakeven line (entry adjusted for fees)
· Filled zones between entry/TP (green) and entry/SL (red)
· Best Point and Worst Point markers showing the maximum favorable and adverse excursion the trade reached
· Live PnL label that updates with current price
WHAT'S IN THE INFO PANEL
· Position: capital, notional, quantity, maintenance margin, fee rate
· Outcomes: live PnL, projected PnL at TP, projected loss at SL, risk-to-reward ratio
· Liquidation: liquidation price, distance to liquidation, round-trip fees
· Trade history: bars in trade, best point reached, worst point reached
· Status: pending entry, active, target hit, stop hit, or liquidated
KEY FEATURES
· Click-to-set workflow: TradingView prompts you to click the entry candle, entry price, TP, and SL when you add the indicator
· Auto direction detection from your TP and SL placement (or manually force Long/Short)
· Liquidation calculator with adjustable maintenance margin (works for any exchange — set the value from your exchange's tier table)
· Sanity warnings: flags when stop loss is past the liquidation price, or when TP/SL are on the wrong side of entry
· Trade tracking freezes the moment any exit (TP/SL/liquidation) is hit, giving you a clean post-trade snapshot
· Three independent color systems: on-chart tag colors, Live PnL label colors, and panel theme — each customizable without affecting the others
· Customizable line widths, label colors, font color, and panel theme (dark, light, or fully custom)
· Adjustable label offsets and stagger so the chart never gets cluttered regardless of timeframe or symbol
· Alerts for TP, SL, liquidation, and breakeven crossings
MAINTENANCE MARGIN REFERENCE
Maintenance margin (MMR) is the minimum equity percentage required to keep your leveraged position open. The default 0.5% is roughly accurate for BTC/ETH on major exchanges, but real values vary:
· BTC/ETH majors: 0.4 – 0.5%
· Top 20 alts: 0.5 – 1.0%
· Mid-cap alts: 1.0 – 2.5%
· Low-cap and meme coins: 2.5%+
For accurate liquidation calculations, find your exchange's exact MMR for your symbol and position size.
NOTES
The liquidation price is a simplified isolated-margin approximation and does not account for tiered margin requirements at different position sizes. Always verify against your exchange's actual liquidation calculator before sizing real positions.
This tool calculates risk-to-reward as the gross price-distance ratio (matching TradingView's built-in long/short position tool). The fee-adjusted dollar amounts are shown separately in the "If TP Hit" and "If SL Hit" rows.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.