Skip to content

πŸ“ˆ Get real-time stocks from TradingView

Color option bug fix (beta)

Mathieu Colmon81c2e7e7cbfd
diff --git a/src/chart/study.js b/src/chart/study.js
index 0dc9a18..19d3829 100644
--- a/src/chart/study.js
+++ b/src/chart/study.js
@@ -16,11 +16,11 @@ function getInputs(options) {
if (options.pineId) pineInputs.pineId = options.pineId;
if (options.pineVersion) pineInputs.pineVersion = options.pineVersion;
- Object.keys(options.inputs).forEach((inputID) => {
+ Object.keys(options.inputs).forEach((inputID, n) => {
const input = options.inputs[inputID];
pineInputs[inputID] = {
- v: input.value,
+ v: (input.type !== 'color') ? input.value : n,
f: input.isFake,
t: input.type,
};
diff --git a/src/classes/PineIndicator.js b/src/classes/PineIndicator.js
index 1834305..f955163 100644
--- a/src/classes/PineIndicator.js
+++ b/src/classes/PineIndicator.js
@@ -4,7 +4,9 @@
* @property {string} inline Input inline name
* @property {string} [internalID] Input internal ID
* @property {string} [tooltip] Input tooltip
- * @property {'text' | 'source' | 'integer' | 'float' | 'resolution' | 'bool'} type Input type
+ * @property {'text' | 'source' | 'integer'
+ * | 'float' | 'resolution' | 'bool' | 'color'
+ * } type Input type
* @property {string | number | boolean} value Input default value
* @property {boolean} isHidden If the input is hidden
* @property {boolean} isFake If the input is fake
@@ -115,12 +117,8 @@ module.exports = class PineIndicator {
text: 'String',
};
- if (
- (input.type === 'bool' && typeof value !== 'boolean')
- || (input.type === 'integer' && typeof value !== 'number')
- || (input.type === 'float' && typeof value !== 'number')
- || (input.type === 'text' && typeof value !== 'string')
- ) {
+ // eslint-disable-next-line valid-typeof
+ if (types[input.type] && typeof value !== types[input.type].toLowerCase()) {
throw new Error(`Input '${input.name}' (${propI}) must be a ${types[input.type]} !`);
}