Problem
Updating one non-color input on a Pine indicator can rewrite its untouched color inputs with incompatible values. Subsequent input readback then returns an empty list.
Observed with TVControl 2.5.2 and TradingView Desktop 3.4.0 on Windows. The affected code is still present in src/core/indicators.js on main at a8d3dfc97621e22b8b7c71e617b134c5e35882ee.
Reproduction
- Add a saved Pine indicator containing color inputs and another editable input, such as a timeframe or boolean.
- Read its inputs with
indicator_get_inputs.
- Change only the non-color input using
indicator_set_inputs.
- Read the inputs again.
Expected: the requested input changes, other values remain untouched, and input readback continues to work.
Observed: the update is reported as unverified and subsequent reads return an empty input list. In the reproduced case, all 176 inputs were readable before the update. The requested timeframe did change, but an untouched color property became the number 4283477836.
Cause
setInputs() reads every value from getInputValues(), updates the requested entries, then passes the entire array to setInputValues().
On this Desktop version, the getter serializes Pine colors as packed integers, while the setter writes directly to underlying properties that expect color strings. Preparing the resulting numeric color throws:
TypeError: e.toLowerCase is not a function
TradingView catches the preparation error and returns empty input data. The empty readback does not mean the saved script source was deleted.
Suggested fix
Collect only explicitly requested, matching input IDs and pass that subset to the setter:
var changedInputs = [];
for (var i = 0; i < currentInputs.length; i++) {
availableIds.push(currentInputs[i].id);
if (overrides.hasOwnProperty(currentInputs[i].id)) {
changedInputs.push({ id: currentInputs[i].id, value: overrides[currentInputs[i].id] });
updatedKeys[currentInputs[i].id] = overrides[currentInputs[i].id];
}
}
if (changedInputs.length > 0) study.setInputValues(changedInputs);
Existing ID matching and per-key readback reporting can remain unchanged.
Local verification
With this change, updating a timeframe input from 1W to 1M kept all 176 inputs readable. All 175 other raw values remained identical, and color properties remained strings. The expected chart output rendered; toggling labels off/on preserved the curves and restored the labels. Updates also worked through the reloaded MCP connection.
This verification covers preservation of untouched colors during non-color edits, not direct color-input conversion.
Problem
Updating one non-color input on a Pine indicator can rewrite its untouched color inputs with incompatible values. Subsequent input readback then returns an empty list.
Observed with TVControl 2.5.2 and TradingView Desktop 3.4.0 on Windows. The affected code is still present in
src/core/indicators.json main ata8d3dfc97621e22b8b7c71e617b134c5e35882ee.Reproduction
indicator_get_inputs.indicator_set_inputs.Expected: the requested input changes, other values remain untouched, and input readback continues to work.
Observed: the update is reported as unverified and subsequent reads return an empty input list. In the reproduced case, all 176 inputs were readable before the update. The requested timeframe did change, but an untouched color property became the number
4283477836.Cause
setInputs()reads every value fromgetInputValues(), updates the requested entries, then passes the entire array tosetInputValues().On this Desktop version, the getter serializes Pine colors as packed integers, while the setter writes directly to underlying properties that expect color strings. Preparing the resulting numeric color throws:
TradingView catches the preparation error and returns empty input data. The empty readback does not mean the saved script source was deleted.
Suggested fix
Collect only explicitly requested, matching input IDs and pass that subset to the setter:
Existing ID matching and per-key readback reporting can remain unchanged.
Local verification
With this change, updating a timeframe input from
1Wto1Mkept all 176 inputs readable. All 175 other raw values remained identical, and color properties remained strings. The expected chart output rendered; toggling labels off/on preserved the curves and restored the labels. Updates also worked through the reloaded MCP connection.This verification covers preservation of untouched colors during non-color edits, not direct color-input conversion.