Anyone can help with my code please ?

Completed

Comments

5 comments

  • Tiki Dave

    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
    })
    }
    }

    };

    0
    Comment actions Permalink
  • Lyubomir Kratinov

    Ooo....  thank you so mach Dave, you make my day.

    Do you know is there any way to protect (or license ) the indicator on Tradovate platform ?

     

    0
    Comment actions Permalink
  • Tiki Dave

    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.

    0
    Comment actions Permalink
  • Eric Delatorre

    Tiki dave could you make the pso indicator from lazy bear on tradingview. The code is availiable but written in the pine editor??

    0
    Comment actions Permalink
  • Lyubomir Kratinov

    This is a support / resistence level indicator isn't it?

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk