trabajando en mi primer indicador javascript para Tradovate. Hasta ahora todo parece funcionar muy bien sin errores. Dicho esto, me gustaría hacer dos cambios:
Esto significaría inherentemente que algunas secciones del histograma no se trazarían (es decir, el valor de 0).
Cualquier ayuda sobre cómo editar el script para reflejar estos cambios sería muy apreciada.
const predef = require("./tools/predef"); const meta = require("./tools/meta"); const SMA = require("./tools/SMA"); const EMA = require("./tools/EMA"); const WMA = require("./tools/WMA"); class TEMP { init() { switch(this.props.period1type) { case "Simple": this.period1Avg = SMA(this.props.period1); break; case "Exponential": this.period1Avg = EMA(this.props.period1); break; case "Weighted": this.period1Avg = WMA(this.props.period1); break; default: this.period1Avg = SMA(this.props.period1); } switch(this.props.period2type) { case "Simple": this.period2Avg = SMA(this.props.period2); break; case "Exponential": this.period2Avg = EMA(this.props.period2); break; case "Weighted": this.period2Avg = WMA(this.props.period2); break; default: this.period2Avg = SMA(this.props.period2); } } map(d) { const value = d.value(); const diff = this.period1Avg(value) - this.period2Avg(value); const plotColor = { color: diff > 0 ? "green" : "red" }; return { value: diff, style: { value: plotColor } }; } } module.exports = { name: "TEMP", description: "TEMP", calculator: TEMP, params: { period1: predef.paramSpecs.period(8), period1type: predef.paramSpecs.enum({value1: "Simple", value2: "Exponential", value3: "Weighted"}), period2: predef.paramSpecs.period(34), period2type: predef.paramSpecs.enum({value1: "Simple", value2: "Exponential", value3: "Weighted"}) }, tags: [predef.tags.MovingAverage], inputType: meta.InputType.BARS, areaChoice: meta.AreaChoice.NEW, plots: { value: { displayOnly: true } }, plotter: predef.plotters.histogram };