Mathieu2301 / TradingView-API

📈 Get real-time stocks from TradingView
1.31k stars 307 forks source link

Support source as an input value type #241

Open conkolas opened 1 month ago

conkolas commented 1 month ago

I have a strategy builder that takes in multiple different inputs as a source from other indicators and executes actions according to the conditions.

image

In order to test this indicator it would require passing other indicator output references as an input value but currently, these are the supported input types:

const types = {
  bool: 'Boolean',
  integer: 'Number',
  float: 'Number',
  text: 'String',
};

Also, the study holds only one indicator instance so it loses reference when the new indicator is added. https://github.com/Mathieu2301/TradingView-API/blob/693f205282c716ed71b340b20b9c5e3e7398ed97/src/chart/study.js#L382

So for all this to work the study would need to handle and track multiple indicators and set PineIndicator inputs as a source from a different indicator.

While debugging TV ws messages I noticed that it sends input.source value as an indicator id in the study with the output id prefix like st4$4 where st4 is id and $4 is an output id prefix.

image

Is that something that would be possible to implement? That would be a game changer!