Salut à tous ;
Y aurait-il des personnes sachant traduire les codes tradovate/ninja en Pro real time ?
C’est une TIKI cumulative delta.
Merci à vous
const predef = require(“./tools/predef”);
const meta = require(“./tools/meta”);
function number(defValue, step, min) {
return {
type: meta.ParamType.NUMBER,
def: defValue,
restrictions: {
step: step || 1,
min: min > 0 ? min : 0
}
};
}
class tikiCumulativeDeltaLine {
init() {
this.last = 0;
this.tradeDate = 0;
}
map(d, i, history) {
const bidVolume = d.bidVolume()
const askVolume = d.offerVolume()
const delta = askVolume – 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 type = this.props.type;
const tradeDate = d.tradeDate();
this.last = close;
if (type === ‘chart’) {
if (tradeDate !== this.tradeDate) {
this.last = 0;
this.tradeDate = tradeDate;
}
} else if (type === ‘session’) {
const timestamp = d.timestamp();
const hour = timestamp.getHours();
const minute = timestamp.getMinutes();
const startHour = this.props.startHour;
const startMinute = this.props.startMinute;
if (history.prior()) {
const priorTimestamp = history.prior().timestamp();
const priorHour = priorTimestamp.getHours();
const priorMinute = priorTimestamp.getMinutes();
// Hacky way to help tick charts work.
const startTime = +(” + startHour + (startMinute < 10 ? ‘0’ : ”) + startMinute)
const priorTime = +(” + priorHour + (priorMinute < 10 ? ‘0’ : ”) + priorMinute)
const time = +(” + hour + (minute < 10 ? ‘0’ : ”) + minute)
if (priorTime < startTime && time >= startTime) {
this.last = 0;
this.tradeDate = tradeDate;
}
}
}
return {
delta: this.last,
zero: 0
}
// return {
// open,
// close,
// delta: this.last,
// value: range
// };
}
}
module.exports = {
name: “tikiCumulativeDeltaLine”,
description: “Tiki Cumulative Delta Line”,
calculator: tikiCumulativeDeltaLine,
params: {
type: predef.paramSpecs.enum({
chart: ‘Chart’,
session: ‘Session’
}, ‘chart’),
startHour: number(9, 1, 0),
startMinute: number(30, 1, 0)
},
plots: {
delta: { title: ‘Delta’ },
zero: { title: ‘Zero’ }
},
inputType: meta.InputType.BARS,
areaChoice: meta.AreaChoice.NEW,
// plotter: predef.plotters.histogram,
tags: [‘Tiki Tools’],
schemeStyles: {
dark: {
delta: predef.styles.plot({
color: “red”
}),
zero: predef.styles.plot({
color: “yellow”
})
}
}
};