Wae v2 [shk}

Is it possible for someone to bring in this indicator? The current WAE available in Tradovate is missing the dead zone indicator and doesn’t allow customization of colors.

You have both the Dead Zone and the change of colors.
const predef = require(‘./tools/predef’);
const meta = require(‘./tools/meta’);
const EMA = require(‘./tools/EMA’);
const StdDev = require(“./tools/StdDev”);
const p = require(“./tools/plotting”);

class tikiWAE2 {
init() {
this.fastEMA = EMA(this.props.fastLength) ;
this.slowEMA = EMA(this.props.slowLength) ;
this.stdDev = StdDev(this.props.bbLength);
this.priorMacd = 0;
this.priorMacdROC = 0;
}
map(d, i, history) {
const price = d.close();

    // Bollinger band range
    const stdev = this.stdDev(price);
    const avg = this.stdDev.avg();
    const halfWidth = stdev * this.props.deviation;
    const upperBb = avg + halfWidth;
    const lowerBb = avg - halfWidth;
    const bbRange = upperBb - lowerBb;
   
    // MACD ROC (rate of change)
    const fastEMA = this.fastEMA(price);
    const slowEMA = this.slowEMA(price);
    const macd = fastEMA - slowEMA;
    const sensitivity = this.props.sensitivity;
    const macdROC = (macd - this.priorMacd) * sensitivity;
    const isUp = macdROC >= 0;
    const isMacdUp = macdROC > this.priorMacdROC ;
    // const deadZone = 20 ;
    this.priorMacdROC = macdROC;
    this.priorBbRange = bbRange;
    this.priorMacd = macd;

        const {
        upColor,
        downColor
        } = this.props;

    return {
        bbRange,
        deadZone:20,
        value: Math.abs(macdROC),
        style: {
            value: {
                color: isUp
                    ? (isMacdUp ? upColor : "white") 
                    : (isMacdUp ? "orange" : downColor)
            }
        }
    };
}

}

module.exports = {
name: ‘tikiWAE2’,
description: ‘KK Tiki WAE 2’,
calculator: tikiWAE2,
inputType: meta.InputType.BARS,
plotter: [
predef.plotters.histogram,
predef.plotters.singleline(“bbRange”),
predef.plotters.singleline(“deadZone”),

],
areaChoice: meta.AreaChoice.NEW,
tags: ['Tiki Tools'],
params: {
    sensitivity: predef.paramSpecs.period(150),
    fastLength: predef.paramSpecs.period(20),
    slowLength: predef.paramSpecs.period(40),
    bbLength: predef.paramSpecs.period(20),
    deviation: predef.paramSpecs.number(2, 0.01, 0.01),
    deadZone: predef.paramSpecs.period(20),
    upColor: predef.paramSpecs.color("lime"),
    downColor: predef.paramSpecs.color("red"),
},

schemeStyles: {
    dark: {
       value: {color: "white"},
       bbRange: {color: "yellow"},
                   deadZone: predef.styles.plot({
        color: "white",
        lineStyle: 3
}),

}

}
};

Were you able to get this code to work? If not let me know and I will add a different version of the code that I modified for my own use.

Yes, got it to work. Thank you. But I’ve problem plotting the 10-period SMA on Cumulative Delta. If you can please help. Below my attempt:

const predef = require(“./tools/predef”);
const meta = require(“./tools/meta”);
const SMA = require(“./tools/SMA”);
const {px, du, op, min, max} = require(“./tools/graphics”);
const medianPrice = require(“./tools/medianPrice”);
const p = require(“./tools/plotting”);

class cumulativeDelta1 {
init() {
this.last = 0;
this.sma = SMA(this.props.periodCVD);
}

map(d, i, history) {
    const strongUpDown = this.props.strongUpDown;
    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
    };

    const upDown = (strong) => {
        if (strong) {
            return {
                up: d.close() > prevd.high(),
                down: d.close() < prevd.low()
            };
        }
        return {
            up: d.close() > d.open(),
            down: d.close() < d.open()
        };
    };

    // UpDown Coloring
    const ud = upDown(strongUpDown);
    if (ud.down) {
        // DOWN
        result.up = false;
        result.down_open = open;
        result.down_close = close;
    }
    else if (ud.up) {
        // UP
        result.up = true;
        result.up_open = open;
        result.up_close = close;
    }
    else {
        result.neutral_open = open;
        result.neutral_close = close;
    }

    this.last = close;
    
    const SMACVD = i > 0 ? this.sma(close) : null;

    return{
        result,
        SMACVD,
    } ;
}
}

module.exports = {
name: “cumulativeDelta1”,
title: “Cumulative Delta1”,
description: “KK Cumulative Delta1”,
calculator: cumulativeDelta1,
params: {
strongUpDown: predef.paramSpecs.bool(true),
periodCVD: predef.paramSpecs.period(10)
},
inputType: meta.InputType.BARS,
areaChoice: meta.AreaChoice.NEW,
scaler: predef.scalers.multiPath([“open”, “close”]),
plotter: predef.plotters.cumulative,
plots: {
delta: “Delta”,
close,
SMACVD: { title: ‘SMA’ }
},
tags: [“01 My Indicators”],
schemeStyles: predef.styles.solidLine(“delta”, {
color: “#7e838c”,
lineWidth: 3
})

};