HitTestThreshold property solves.
The HitTestThreshold is an invisible buffer zone around a price line. It tells the charting engine: "If the cursor is within X pixels of this line, treat it as a click." Visually, your chart stays clean and thin. Functionally, it becomes actually clickable.
About this guide: I'm Lawrence, the writer behind supa.is. Between February and May 2026 I've published 150+ articles on supa.is across crypto and brokerage tooling โ including 20+ TradingView-specific guides (recent examples: TradingView Price Scale Range Limit Settings, TradingView Custom Session Extended Hours Settings, TradingView Keyboard Shortcuts: Order Panel & Drawing). The most-repeated reader question across that TradingView archive is exactly how to improve chart interaction and price line clickability, which is why I'm publishing this standardized guide instead of answering one-off.
What is HitTestThreshold in TradingView?
In web development, "hit testing" is the math that determines which element a user clicked. When you draw a line on a chart, it might only be 1 or 2 pixels wide. Trying to click a 1-pixel line with a mouse is frustrating, especially on high-resolution screens or when users are in a hurry.
The HitTestThreshold property solves this by expanding the clickable area of the price line. If a price line has a HitTestThreshold of 5 pixels, the charting engine will register a click if the cursor is anywhere within 5 pixels of the line. Visually, the line remains thin and clean. Functionally, it becomes much easier to interact with.
This feature is particularly relevant for developers using the TradingView Lightweight Charts library, an open-source, high-performance charting library designed for financial data. As discussed in the community, there is a known need to adjust this threshold to improve the user experience when dealing with custom price lines or indicators.
Why Adjusting HitTestThreshold Matters
If you are building a trading dashboard, a custom indicator viewer, or a backtesting interface, the default hit-test area might not be enough. Here is why tweaking it matters:
1. Thin lines are hard to click. By default, price lines and custom series have a narrow hit-test area. Traders trying to click a specific level to set an order or trigger an alert will miss it. Increasing the threshold ensures the user's intent is captured. 2. Mobile needs a bigger target. A finger is much larger than a cursor. If the threshold is too low, tapping a specific price level on a phone will likely miss. A higher threshold acts as a forgiving buffer. 3. Tooltips snap better. When hovering, the crosshair should snap to the nearest line. If the threshold is too small, the tooltip skips over lines entirely. Adjusting it makes the tooltip behavior smoother.How to Change the HitTestThreshold
The HitTestThreshold is configured when you create or update a price line or a custom series in the Lightweight Charts API. While the exact implementation can vary depending on the version of the library you are using, the core concept involves passing a threshold value (usually in pixels) to the line's configuration object.
Here is a conceptual breakdown of how this is handled in the Lightweight Charts API:
Setting the Threshold for Price Lines
When you add a price line to a chart, you can specify theHitTestThreshold alongside other properties like color, line width, and price level.
// Conceptual example of adding a price line with a custom HitTestThreshold
const priceLine = {
price: 45000.00, // The price level
color: '#ff0000', // Red line
lineWidth: 2, // Visually thin
lineStyle: LineStyle.Solid,
axisLabelVisible: true,
// The HitTestThreshold property expands the clickable area
hitTestThreshold: 10
};
chart.applyPriceLine(priceLine);
In this example, the line is visually only 2 pixels wide, but the user can click anywhere within 10 pixels of the line and the chart will register it as a click on the price line.
Like what you're reading? Try it yourself โ this link supports ChartedTrader at no cost to you.
Try TradingView โAdjusting for Custom Indicators
If you are drawing custom indicators (like a moving average or a custom support/resistance level) using the Lightweight Charts API, you can also apply aHitTestThreshold to those series. This is crucial if your indicator is drawn as a thin line but needs to be clickable to trigger events (like opening a modal or fetching data).
Note: The exact property name and implementation may vary slightly across different versions of the Lightweight Charts library. If you are encountering issues with price line clickability, refer to the official Lightweight Charts documentation or community issues like GitHub Issue #1610 for the most up-to-date API references.
Best Practices for HitTestThreshold
But setting it too high introduces new problems. Keep these rules in mind:
1. Don't exceed visual proximity. If you have two lines close together (e.g., support at $45,000 and resistance at $45,050), a high threshold (like 50 pixels) will cause the chart to register clicks on the wrong line. Keep the threshold proportional to the distance between lines. 5 to 15 pixels is usually a safe sweet spot. 2. Balance performance and UX. Every interactive element requires the browser to calculate hit tests. If you have dozens of custom lines with extremely high thresholds, it could slightly impact rendering performance on lower-end devices. 3. Test on actual devices. A threshold of 10 pixels might feel perfect on a 4K monitor, but on a high-DPI mobile screen, 10 pixels is tiny. Always test on the actual devices your users will be using.TradingView Lightweight Charts vs. Standard TradingView
Note the difference between the TradingView Lightweight Charts library and the standard TradingView web application.
The standard platform has its own internal settings for chart interaction, which are not adjustable via HitTestThreshold. If you are a standard user finding it hard to click lines on the main TradingView website, you are limited to the default UI behavior.
If you are a developer building a custom app, you have full control over the API. This is why this guide focuses on the developer perspective.
If you are looking for a robust, out-of-the-box charting experience without the need to code, TradingView's standard platform is the best choice. You can Try TradingView to access their premium charting tools, advanced indicators, and broker integrations.
Common Issues and Troubleshooting
Even after adjusting the HitTestThreshold, you might still encounter some interaction issues. Here are a few common problems and how to address them:
The Click Still Doesn't Register
If increasing theHitTestThreshold doesn't solve the clickability issue, check if there are other elements overlapping the price line. For example, a custom tooltip, a crosshair overlay, or another chart series might be blocking the click event. Ensure that the price line is rendered on top of other elements, or adjust the z-index of your custom overlays.
The Tooltip Jumps Around
If the tooltip is flickering or jumping between price lines when you hover, yourHitTestThreshold might be too large, causing the chart to switch which line it thinks you are hovering over. Reduce the threshold incrementally until the tooltip snapping feels smooth.
Mobile Touch Events Are Still Inaccurate
Touch events on mobile browsers sometimes behave differently than mouse clicks. If theHitTestThreshold isn't enough, you might need to implement custom touch event handlers in your application to detect when a user's finger is near a price line and manually trigger the desired action.
Conclusion
The HitTestThreshold is a small but powerful property in the TradingView Lightweight Charts API. By expanding the invisible click area around price lines, you can dramatically improve the usability of your custom charting applications, making them more accessible for both desktop and mobile users.
Paying attention to the HitTestThreshold will save you from frustrating user feedback and ensure a polished, professional experience.
If you are looking to get started with charting or want to explore the full potential of TradingView's ecosystem, Try TradingView today and see how their tools can elevate your trading workflow.
Risk Warning
Risk Warning: Crypto trading involves substantial risk of loss. Never invest more than you can afford to lose. This is not financial advice.
FAQ
What is the default HitTestThreshold in Lightweight Charts?
The defaultHitTestThreshold varies depending on the specific version of the Lightweight Charts library and the type of series being drawn. For standard price lines, it is typically set to a small value to match the visual width of the line.
Can I change the HitTestThreshold on the standard TradingView website?
No. TheHitTestThreshold is a property available in the TradingView Lightweight Charts API for developers. Standard users of the TradingView web application cannot adjust this setting directly.
How does HitTestThreshold affect chart performance?
A higherHitTestThreshold means the charting engine has to process a larger area for click detection. For most modern devices, this is negligible. However, if you have hundreds of custom price lines with very high thresholds, it could slightly impact rendering performance on low-end hardware.
Is HitTestThreshold measured in pixels or points?
In the Lightweight Charts API, theHitTestThreshold is measured in pixels. This means it scales with the screen resolution and the CSS styling of your chart container.