Range Bar Predictor

Completed

Comments

10 comments

  • Robert Siesser

    I was use this all the time, would be nice if Tradovate would create it.

    1
    Comment actions Permalink
  • Tiki Dave

    Sounds cool, would love to see if I could help -- could you guys post a few screenshots? I'm having trouble visualizing this.

    0
    Comment actions Permalink
  • Brian Holiman

    Here you go.. hope this  helps.

    0
    Comment actions Permalink
  • Permanently deleted user

    Here is a screenshot from Robert: 

    -1
    Comment actions Permalink
  • Permanently deleted user

    Also see below code from Trade Station in Easy Language from Robert:

     

    // Range Bar Countdown
     
    [LegacyColorValue = false]; 

    inputs: TextHalfColor(cyan), TextFinishColor(yellow), decimal(2);

    vars: 
     rangevalue(0),
     rangecount(0),
     rangeleft(0),
     rangehi(0),
     rangelo(0),
     rangeopen(0),
     str(" "),
     ID(-1),
     ID1(-1),
     ID2(-1),
     Textcolor(yellow);

    If barnumber = 2 then rangevalue = range[1];
    rangecount = H - L;
    rangeleft = rangevalue - rangecount;
    rangehi = l + rangevalue;
    rangelo = h - rangevalue;
    rangeopen = o;

     
    //str = "RR: "+numtostr(rangeleft,decimal);
    //if rangecount < .5*rangevalue then TextColor = TextHalfColor;
    //if rangecount > .5*rangevalue then TextColor = TextFinishColor;

    ID = text_new(date,calctime(time,(barinterval*10)),close,str);
        text_SetColor(ID,TextColor);
    If Barstatus(1) <> 1 then
      If ID > 0 then Text_Delete(ID);
    ID1 = text_new(date,calctime(time,(barinterval*10)),rangehi,numtostr(rangehi,decimal));
        text_SetColor(ID1,TextColor);
    If Barstatus(1) <> 1 then
      If ID1 > 0 then Text_Delete(ID1);
    ID2 = text_new(date,

     

    0
    Comment actions Permalink
  • Tiki Dave

    Alrighty, took an initial crack at this one.  It should automatically pick up the range based on the high and low, and when the bar has reached its maximum range, the plot should disappear.

    After installing `Tiki Range Forecast` using Code Explorer, you should find it located in the `Channels` menu. 

    Be sure that either the `Range` or `Momentum Range` chart type is enabled and the chart is fully refreshed or funny things may happen!

    Please let me know of any issues. Cheers!

     

    0
    Comment actions Permalink
  • Permanently deleted user

    Per Robert: 

     

    Tiki Dave

    Looks good, but instead of a colored dots would like the number. Anyway to do that?

    Rob

    0
    Comment actions Permalink
  • Tiki Dave

    Not that I am aware of, but I will check with support to see if there’s a way to handle that.

    0
    Comment actions Permalink
  • Cameron Osborne

    I have modified the code of this to produce two lines that will only appear on the final bar. I noticed that the dots still appear for historical bars. The length and color of the horizontal line can be adjusted and does determine the correct price to produce a next candle depending on if the chart is Range or Momentum Range.

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

    class rangeForecast {
    init() {
    this.tickSize = this.contractInfo.tickSize
    }

    map(d, i, history) {
    if (i > 0) {
    const prior = history.prior();
    const range = prior.high() - prior.low();
    const high = d.high() ;
    const low = d.low();
    const currentRange = high - low;
    const rangeDiff = range - currentRange;

    const isMomentumRange = d.open() == prior.close();

    const upper = isMomentumRange ? high + rangeDiff : high + rangeDiff + this.tickSize;
    const lower = isMomentumRange ? low - rangeDiff : low - rangeDiff - this.tickSize;

    return {
    upper,
    lower,
    upperColor: this.props.upperColor,
    lowerColor: this.props.lowerColor,
    rangeDiff,
    offset: this.props.offset
    };
    }

    return {};
    }
    }

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

    if(i > item.offset && (item.rangeDiff > 0 || i == (history.data.length - 1))) {
    const item1 = history.get(i - item.offset);

    const x = p.x.get(item);
    const x1 = p.x.get(item1);

    canvas.drawLine(
    p.offset(x1, item.upper),
    p.offset(x, item.upper),
    {
    color: item.rangeDiff > 0 ? item.upperColor : "#00000000",
    width: 1,
    opacity: 1
    });

    canvas.drawLine(
    p.offset(x1, item.lower),
    p.offset(x, item.lower),
    {
    color: item.rangeDiff > 0 ? item.lowerColor : "#00000000",
    width: 1,
    opacity: 1
    });
    }
    }
    }

    module.exports = {
    name: "rangeForecast",
    description: "Range Forecast",
    calculator: rangeForecast,
    params: {
    upperColor: predef.paramSpecs.color('forestgreen'),
    lowerColor: predef.paramSpecs.color('firebrick'),
    offset: predef.paramSpecs.period(8),
    },
    inputType: meta.InputType.BARS,
    plots: { },
    plotter: [
    predef.plotters.custom(rangePlotter)
    ],
    tags: ['My Indicators'],
    schemeStyles: {}
    };

    0
    Comment actions Permalink
  • Brian Holiman

    Hi Cameron,

    I like your version much better but every time i click on a different tab in my workspace and leave the chart with the indicator on it, when I click back, the indicator is gone. It still shows in my indicator list for that chart but its not actually on the chart. Any ideas?

     

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk