Anyone can help with my code please ?
Completedconst predef = require("./tools/predef");
const meta = require('./tools/meta');
class customPriceChnell {
init() {
this.lineHigh = null;
this.lineLow = null;
this.trend = 0;
}
map(d, i, history) {
const prior = history.prior();
const step = this.props.multiplier;
const dev = 8*step;
const high = d.high();
const low = d.low();
const upper = high + dev;
const lower = low - dev;
let lineHigh = upper;
let lineLow = lower;
const currhigh = d.high();
const currlow = d.low();
const priorlineHigh = this.lineHigh;
const priorlineLow = this.lineLow;
if ( (currhigh < lineHigh) && ( currlow > lineLow ))
{
lineHigh = priorlineHigh;
lineLow = prioplineLow;
trend = 0;
}
if (currlow < priorlineLow)
{
lineLow = currlow;
lineHigh = currlow+dev;
trend = -1;
}
if (currhigh > priorlineHigh)
{
lineHigh = currhigh;
lineLow = currhigh-dev;
trend = -1;
}
return {
plotlinehigh: lineHigh,
plotlinelow: lineLow,
};
}
}
module.exports = {
name: "customPriceChnell",
description: "customPriceChnell",
calculator: customPriceChnell,
params: {
multiplier: predef.paramSpecs.number(1.5, 0.05, 0.001),
},
inputType: meta.InputType.BARS,
plots: {
plotlinehigh : {title: "plotHigh"},
plotlinelow : {title: "plotLow"},
},
tags: ['My Indicators'],
schemeStyles: {
dark: {
plotlinehigh: predef.styles.plot({ color: "#C0C0C0", lineStyle: 1 }),
plotlinelow: predef.styles.plot({ color: "#C0C0C0", lineStyle: 1 })
}
}
};
It doesn't plot anything .... :(
-
You had some typos in your code and forgot to define the `trend` variable. Make sure your "Console Output" is enabled so you can view these errors.

Updated code:
const predef = require("./tools/predef");
const meta = require('./tools/meta');class customPriceChnell {
init() {
this.lineHigh = null;
this.lineLow = null;
this.trend = 0;
}map(d, i, history) {
const prior = history.prior();
const step = this.props.multiplier;
const dev = 8 * step;const high = d.high();
const low = d.low();
const upper = high + dev;
const lower = low - dev;let lineHigh = upper;
let lineLow = lower;const currhigh = d.high();
const currlow = d.low();
const priorlineHigh = this.lineHigh;
const priorlineLow = this.lineLow;
let trend;
if ((currhigh < lineHigh) && (currlow > lineLow)) {
lineHigh = priorlineHigh;
lineLow = priorlineLow;
trend = 0;
}if (currlow < priorlineLow) {
lineLow = currlow;
lineHigh = currlow + dev;
trend = -1;
}if (currhigh > priorlineHigh) {
lineHigh = currhigh;
lineLow = currhigh - dev;
trend = -1;
}return {
plotlinehigh: lineHigh,
plotlinelow: lineLow
};
}
}module.exports = {
name: "customPriceChnell",
description: "customPriceChnell",
calculator: customPriceChnell,
params: {
multiplier: predef.paramSpecs.number(1.5, 0.05, 0.001),
},
inputType: meta.InputType.BARS,
plots: {
plotlinehigh: {
title: "plotHigh"
},
plotlinelow: {
title: "plotLow"
}
},
tags: ['My Indicators'],
schemeStyles: {
dark: {
plotlinehigh: predef.styles.plot({
color: "#C0C0C0",
lineStyle: 1
}),
plotlinelow: predef.styles.plot({
color: "#C0C0C0",
lineStyle: 1
})
}
}};
-
As far as I know, there is not a way to do this; when you share your indicator it is made available to everyone on the platform (however they will still need to install it).
Maybe someone from the Tradovate team can comment on this as I'm sure it's been requested by other indicator vendors.
Please sign in to leave a comment.
Comments
5 comments