Mapping Chart Coordinates to Time and Price Beyond the Visible Area
Summary
The document presents four functions for translating between chart pixel coordinates and market data: horizontal position to time, vertical position to price, and the inverse conversions. The time calculations use bar spacing, the chart’s first visible bar, the instrument’s period, and available bar timestamps. The price calculations map the displayed price range to the chart’s pixel height. The stated motivation is that standard chart conversion functions may fail outside the visible region or behave inconsistently in some cases.
A demonstration script repeatedly generates coordinates, converts them to time and price and back, and reports mismatches. It excludes samples where the chart scale or displayed range changes during conversion. This is a charting implementation note rather than a trading strategy. Its claimed correctness is supported only by the described round-trip check; the document gives no reported test results, performance comparison, or discussion of edge cases such as missing bars and irregular trading sessions.
Key ideas
- The functions convert chart pixels to time and price, including positions beyond the visible chart area.
- Horizontal mapping estimates pixel spacing per bar and accounts for the offset within a bar.
- Vertical mapping linearly scales between the chart’s displayed minimum and maximum prices.
- The demonstration checks round-trip coordinate consistency while discarding samples affected by chart changes.
- The document does not report test outcomes or address irregular time gaps in detail.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.