Tick Count

Completed

Comments

1 comment

  • Cameron Osborne

    Nevermind, I see that d.ticks() has been added. I quickly created this indicator today and shared it in the community under "ticks.js"

    const predef = require("./tools/predef");
    const meta = require("./tools/meta");
    const p = require("./tools/plotting");
    const EMA = require("./tools/EMA");

    class ticks {
    init() {
    this.ema = EMA(this.props.period);
    }

    map(d) {
    let tick = this.ema(d.ticks());
    let p = d.ticks() / tick * 100.00;

    return {
    percent: p,
    zero: 0.0,
    middle: 50.0,
    complete: 100.0
    }
    }

    filter(_, i) {
    return i >= this.props.period;
    }
    }

    function percentPlotter(canvas, indicatorInstance, history) {
    for(let i=0; i<history.data.length; ++i) {
    const item = history.get(i);

    if (item.percent !== undefined) {
    const x = p.x.get(item);

    canvas.drawLine(
    p.offset(x, 0),
    p.offset(x, item.percent),
    {
    color: item.percent > 80 ? "#00FF00DD" : item.percent > 60 ? "#00C040DD" : item.percent > 40 ? "#008080DD" : item.percent > 20 ? "#0040C0DD" : "#0000FFDD",
    // color: item.percent < 20 ? "#0000FFDD" : item.percent < 40 ? "#0040C0DD" : item.percent < 60 ? "#008080DD" : item.percent < 80 ? "#00C040DD" : "#00FF00DD",
    relativeWidth: 0.5,
    opacity: 1.0
    });
    }
    }
    }

    module.exports = {
    name: "ticks",
    description: "Ticks",
    calculator: ticks,
    inputType: meta.InputType.BARS,
    areaChoice: meta.AreaChoice.NEW,
    tags: [predef.tags.Volumes],
    params: {
    period: predef.paramSpecs.period(14),
    },
    plots: {
    percent: { title: "Percent" },
    zero: { displayOnly: true },
    middle: { displayOnly: true },
    complete: { displayOnly: true },
    },
    plotter: [
    predef.plotters.custom(percentPlotter),
    predef.plotters.singleline("zero"),
    predef.plotters.singleline("middle"),
    predef.plotters.singleline("complete"),
    ],
    schemeStyles: {
    dark: {
    percent: predef.styles.plot("#ffc270"),
    zero: predef.styles.plot({ color: "00000000", lineStyle: 3 }),
    middle: predef.styles.plot({ color: "#7E838C", lineStyle: 3 }),
    complete: predef.styles.plot({ color: "#5DC74F", lineStyle: 3 }),
    }
    }
    };

     

    1
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk