Current Trade Holding Time (H:M:S) — Strategy by stevenbel23

By stevenbel23

Performance Metrics

Description

Purpose:This TradingView Pine Script strategy tracks your current open trade and displays its holding time in a table on the chart’s bottom-left corner, updating live as each bar forms. It also optionally shows a label above the price with the current holding time in hours, minutes, and seconds.Features:Entry / Exit Logic:Buy Condition: When the 9-period SMA crosses above the 21-period SMA.Sell Condition: When the 9-period SMA crosses below the 21-period SMA.(These are example conditions — you can replace them with your own strategy.)Table Display:Always visible in the bottom-left corner.Columns:Bars: Number of bars the trade has been open.Days: Total days held (decimal).Hours: Total full hours held.Minutes: Remaining minutes.Seconds: Remaining seconds.Updates live while the trade is open.Clears automatically when the trade closes.Optional Chart Label:Shows Hours:Minutes:Seconds above the highest price of the current bar.Can be turned on/off using the Show Labels input.Single Trade Tracking:Only the current open trade is displayed.Past trades are not recorded in the table, keeping it clean.Time Calculation:Uses time, the bar timestamp, for precise elapsed time.Converts milliseconds to seconds, minutes, hours, and days for display.Intended Use:Traders who want to monitor exactly how long their open trade has been held.Useful for scalping or swing trading, where holding time matters.Works on any timeframe chart.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView