Need help to this code, I think it should be simple, but cant figure it out
The build in cumulative delta, prints very tiny bars after zoom in or out.
I have removed everything I think is unnecessary from the original code and now it works just fine and remembers the thickness of the bars. The only thing I would like more is that it would print upbars in upColor and downbars in downColor.
Code:
const predef = require("./tools/predef");
const meta = require("./tools/meta");
class MyCD {
init() {
this.last = 0;
}
map(d, i, history) {
const delta = d.offerVolume() - d.bidVolume();
const open = this.last;
const close = open + delta;
const range = Math.abs(open) > Math.abs(close) ? open : close;
const prevd = i > 0 ? history.prior() : d;
const result = {
open,
close,
delta,
value: range
};
this.last = close;
return result;
}
}
module.exports = {
name: “My CD”,
calculator: MyCD,
params: {
upColor: predef.paramSpecs.color(‘lime’),
downColor: predef.paramSpecs.color(‘red’),
},
inputType: meta.InputType.BARS,
areaChoice: meta.AreaChoice.NEW,
scaler: predef.scalers.singlePath,
plotter: predef.plotters.cumulative,
plots: {
delta: “Delta”
},
schemeStyles: predef.styles.solidLine(“delta”, {
color: “#ffffff”,
//color: deltaColor,
lineWidth: 5
})
};