Inverted Price Scale
Invert the Y-axis price scale to display chart values upside down, swapping the top and bottom values.
Introduction
An inverted price scale reverses the Y-axis so that values increase as you scroll down. The highest values are placed at the bottom, and the lowest values are placed at the top of the chart grid.
This is particularly useful for studying currency exchange rates (USDSEK vs SEKUSD comparisons) or viewing commodity spreads from alternative trading perspectives.
Configuration
To invert the price scale on the right border of your chart, apply the following configuration settings:
chart.applyOptions({
rightPriceScale: {
invertScale: true
}
});
If you are using a dual scale layout with both left and right scales, you can invert them independently:
chart.applyOptions({
leftPriceScale: {
invertScale: true
},
rightPriceScale: {
invertScale: false // Keep right scale standard
}
});
Under the Hood: Coordinate Translation
When standard scaling is active, the coordinate mapping maps prices to Y-coordinates where:
const y = chartH - (price - minPrice) / (maxPrice - minPrice) * chartH;
When invertScale: true is applied, Backtestx reverses this mapping formula, translating prices where:
const y = (price - minPrice) / (maxPrice - minPrice) * chartH;
This shifts the lowest values to pixel coordinate zero (the top of the chart) and the highest values to chartH (the bottom of the chart). All custom drawing tools and indicators automatically adjust coordinate plotting calculations based on this active setting.
Common Use Cases
- Short Positions: Visualizing charts from a short seller's perspective, mapping gains as upward visual slopes.
- Exchange Rates: Easily converting Base-to-Quote rates (e.g. EURUSD) to display Quote-to-Base trends (e.g. USDEUR) without altering raw data streams.
- Relative Value Trading: Comparing diverging spread spreads that move in opposite directions.