Fix RSI bands visibility and line width

1. Added band creation:
   - Create horizontal price lines for RSI overbought/oversold bands
   - Use createPriceLine() on the RSI series after it's created
   - Create lines at indicator.params.overbought and indicator.params.oversold levels
   - Store band references to prevent creating duplicate lines

2. Fixed line width priority:
   - Changed from 'indicator.params._lineWidth || plot.width || lineWidth'
   - To 'plot.width || indicator.params._lineWidth || lineWidth'
   - This ensures RSI bands use fixed 1px width from plot.width metadata
   - User can still adjust line width for other indicators

Result: RSI bands now visible as dashed lines at 70/30 levels
This commit is contained in:
DiTus
2026-02-25 23:29:24 +01:00
parent 7539830524
commit 9d3612cd9a

View File

@ -697,7 +697,7 @@ function renderIndicatorOnPane(indicator, meta, instance, candles, paneIndex, li
topFillColor2: '#00000000',
bottomFillColor1: '#00000000',
bottomColor: plot.bottomColor || '#00000000',
lineWidth: indicator.params._lineWidth || plot.width || lineWidth,
lineWidth: plot.width || indicator.params._lineWidth || lineWidth,
lineStyle: plotLineStyle,
title: plot.title || '',
priceLineVisible: false,
@ -706,7 +706,7 @@ function renderIndicatorOnPane(indicator, meta, instance, candles, paneIndex, li
} else {
series = window.dashboard.chart.addSeries(LightweightCharts.LineSeries, {
color: plotColor,
lineWidth: indicator.params._lineWidth || plot.width || lineWidth,
lineWidth: plot.width || indicator.params._lineWidth || lineWidth,
lineStyle: plotLineStyle,
title: plot.title || '',
priceLineVisible: false,
@ -716,6 +716,41 @@ function renderIndicatorOnPane(indicator, meta, instance, candles, paneIndex, li
series.setData(data);
indicator.series.push(series);
// Create horizontal band lines for RSI
if (meta.name === 'RSI' && indicator.series.length > 0) {
const mainSeries = indicator.series[0];
const overbought = indicator.params.overbought || 70;
const oversold = indicator.params.oversold || 30;
// Remove existing price lines first
while (indicator.bands && indicator.bands.length > 0) {
try {
indicator.bands.pop();
} catch(e) {}
}
indicator.bands = indicator.bands || [];
// Create overbought band line
indicator.bands.push(mainSeries.createPriceLine({
price: overbought,
color: '#787B86',
lineWidth: 1,
lineStyle: LightweightCharts.LineStyle.Dashed,
axisLabelVisible: false,
title: ''
}));
// Create oversold band line
indicator.bands.push(mainSeries.createPriceLine({
price: oversold,
color: '#787B86',
lineWidth: 1,
lineStyle: LightweightCharts.LineStyle.Dashed,
axisLabelVisible: false,
title: ''
}));
}
});
}