Orderblock and FVG Indicators

Does Tradovate have order block/FVG indicators? I’m currently paper trading using Order blocks and FVGS. I’m actually beginning to see clearly how price reacts to them and am quite excited that this might be the “edge” I have been trying to find, and hope that I don’t need to find another strategy for a long time. The only issue is that Tradovate doesn’t have any of those indicators and I have to manually draw them, and edit them after they are taken out etc. TradingView has many ICT/SMC based institutional footprint indicators and Tradovate has none. Any coders out there who could do this? TIA.

1 Like
const SMA = require("./tools/SMA");
const EMA = require('./tools/EMA');
const WMA = require('./tools/WMA');
const MMA = require('./tools/MMA');

const predef = require("./tools/predef");
const meta = require('./tools/meta');
const medianPrice = require("./tools/medianPrice");
const typicalPrice = require("./tools/typicalPrice");
const trueRange = require("./tools/trueRange");
const p = require("./tools/plotting");

const { ParamType } = meta;



class FairValueGap {
    
    
    
    
    init() {
        
    }
    
    map(d, i, history) {
        
        const prior = history.prior();
        if (!prior) {
            return;
        }
        

        const high = d.high();
        const low = d.low();
        const close = d.close();
        return {
            high,
            low,
            i,
            close,
        };
    }
    
    filter(d) {
        return d.high !== undefined;
    }
}


  
function fvgPlotter(canvas, indicatorInstance, history) {
    console.log("FVG Plotter");

    let i =3;
    let gap = indicatorInstance.props.fvgGap;
    for(i=3;i<history.size()-1;i++){
        
        let pCandle = history.get(i-1);
        let cCandle = history.get(i);
        let nCandle = history.get(i+1);
        
        
        //console.log("pCandle " + Object.keys(pCandle));
        //console.log("cCandle " + Object.keys(cCandle));
        //console.log("nCandle " + Object.keys(nCandle));
        
        
        
        isBullishFVG = pCandle.high < nCandle.low && (nCandle.low - pCandle.high >= gap);
        isBearishFVG = pCandle.low > nCandle.high && (pCandle.low - nCandle.high  >= gap);
        
        let isBullishMitigated = false;
        let isBearishMitigated = false;
        
        
         
        
        if(isBullishFVG ){
            for (let k = i; k < history.size(); k++) {
                let fCandle = history.get(k);
                if(fCandle.low < cCandle.low ){
                    isBullishMitigated = true;
                    break;
                }
            }
        }
        
        
        if(isBearishFVG ){
            for (let k = i; k < history.size(); k++) {
                let fCandle = history.get(k);
                
                if(fCandle.high > cCandle.high ){
                    isBearishMitigated = true;
                    break;
                }
            }
        }
        
        
        if(isBullishFVG && !isBullishMitigated){
            
           
            const x = p.x.get(cCandle);
            const last = p.x.get(history.get(history.size()-1))
            console.log("Drawing Bullish FVG " + x + " " + cCandle.close);    
            
            
            canvas.drawLine(
            p.offset(x, (cCandle.high + cCandle.low )/2 ),
            p.offset(last, (cCandle.high + cCandle.low )/2),
                {
                  color: indicatorInstance.props.bullishFVGColor,
                  width: indicatorInstance.props.lineWeight,
                  opacity: 70
                } 
             );
            
        }
         
        if(isBearishFVG && !isBearishMitigated){
              console.log("Drawing Bearish FVG");    
              const x = p.x.get(cCandle);
              const last = p.x.get(history.get(history.size()-1))
              canvas.drawLine(
              p.offset(x, (cCandle.low + cCandle.high) /2 ),
              p.offset(last, (cCandle.low + cCandle.high) /2),
                {
                  color: indicatorInstance.props.bearishFVGColor,
                  width: indicatorInstance.props.lineWeight,
                  opacity: 70
                } 
              );
        }
        
        
        
    }
    
    

}

module.exports = {
    name: "FairValueGap",
    description: "Vinay-FairValueGap",
    calculator: FairValueGap,
    params: {
        
        bearishFVGColor: predef.paramSpecs.color("#fcba03"),
        bullishFVGColor: predef.paramSpecs.color("#03fcf8"),
        lineWeight: predef.paramSpecs.number(2, 1, 1, 5),
        fvgGap:predef.paramSpecs.number(1.0, .1, 0.00001),
    },
    tags: ['vinay'],
    inputType: meta.InputType.BARS,
    plotter: [
        predef.plotters.custom(fvgPlotter),
    ],
};

the above indicator is very basic one

It very cool that you provided the logic for this indicator. I have 1 question: When I change the FVG Gap I don’t see more or fewer indications unless I increase the number dramatically then they all disappear. What exactly is the FVG GAP number supposed to control?

Thanks again

Better Version

const SMA = require(“./tools/SMA”);
const EMA = require(‘./tools/EMA’);
const WMA = require(‘./tools/WMA’);
const MMA = require(‘./tools/MMA’);

const predef = require(“./tools/predef”);
const meta = require(‘./tools/meta’);
const medianPrice = require(“./tools/medianPrice”);
const typicalPrice = require(“./tools/typicalPrice”);
const trueRange = require(“./tools/trueRange”);
const p = require(“./tools/plotting”);

const { ParamType } = meta;

class FairValueGap {

init() {
 
}

map(d, i, history) {
    
    const prior = history.prior();
    if (!prior) {
        return;
    }

    const high = d.high();
    const low = d.low();
    const close = d.close();
    

    return {
        high,
        low,
        i,
        close,
    };
}

filter(d) {
    return d.high !== undefined;
}

}

function fvgPlotter(canvas, indicatorInstance, history) {

let i =3;
let gap = indicatorInstance.props.fvgGap;
for(i=3;i<history.size()-1;i++){
    
    let pCandle = history.get(i-1);
    let cCandle = history.get(i);
    let nCandle = history.get(i+1);
    
    

    
    
    isBullishFVG = pCandle.high < nCandle.low && (nCandle.low - pCandle.high) >= gap && (nCandle.low - pCandle.high) <  indicatorInstance.props.maxfvgGap;
    isBearishFVG = pCandle.low > nCandle.high && (pCandle.low - nCandle.high ) >= gap && (pCandle.low - nCandle.high)  <  indicatorInstance.props.maxfvgGap;
    
    let isBullishMitigated = false;
    let isBearishMitigated = false;
    
    
     
    
    if(isBullishFVG ){
        for (let k = i+1; k < history.size(); k++) {
            let fCandle = history.get(k);
            if(fCandle.low < pCandle.high ){
                isBullishMitigated = true;
                break;
            }
        }
    }
    
    
    if(isBearishFVG ){
        for (let k = i+1; k < history.size(); k++) {
            let fCandle = history.get(k);
            
            if(fCandle.high > pCandle.low ){
                isBearishMitigated = true;
                break;
            }
        }
    }


  
    
    
    if(isBullishFVG && !isBullishMitigated ){
        
       
        const x = p.x.get(pCandle);
        const last = p.x.get(history.get(history.size()-1))
        
        
        canvas.drawLine(
        p.offset(x, pCandle.high ),
        p.offset(last, pCandle.high ),
            {
              color: indicatorInstance.props.bullishFVGColor,
              width: indicatorInstance.props.lineWeight,
              opacity: 70
            } 
         );
        
         canvas.drawLine(
            p.offset(x , nCandle.low ),
            p.offset(last, nCandle.low ),
                {
                  color: indicatorInstance.props.bullishFVGColor,
                  width: indicatorInstance.props.lineWeight,
                  opacity: 70
                } 
        );


        
    }
     
    if(isBearishFVG && !isBearishMitigated ){
          const x = p.x.get(pCandle);
          const last = p.x.get(history.get(history.size()-1))
          canvas.drawLine(
            p.offset(x, pCandle.low ),
            p.offset(last, pCandle.low ),
                {
                  color: indicatorInstance.props.bearishFVGColor,
                  width: indicatorInstance.props.lineWeight,
                  opacity: 70
                } 
             );
            
             canvas.drawLine(
                p.offset(x , nCandle.high ),
                p.offset(last, nCandle.high ),
                    {
                      color: indicatorInstance.props.bearishFVGColor,
                      width: indicatorInstance.props.lineWeight,
                      opacity: 70
                    } 
            );

    }
    
    
    
}

}

module.exports = {
name: “FairValueGap”,
description: “Vinay-FairValueGap”,
calculator: FairValueGap,
params: {

    bearishFVGColor: predef.paramSpecs.color("#34bdeb"),
    bullishFVGColor: predef.paramSpecs.color("#e5eb34"),
    lineWeight: predef.paramSpecs.number(0.5, .1, 1.0, 1.0),
    fvgGap:predef.paramSpecs.number(2.0, 0.1,0.1),
    maxfvgGap:predef.paramSpecs.number(15.0, 0.1, 0.1),
  
},
tags: ['vinay'],
inputType: meta.InputType.BARS,
plotter: [
    predef.plotters.custom(fvgPlotter),
],

};

I’ll give the new one a try. Thanks

1 Like

would be happy to help if anyone needs custom coding: timmfain@gmail.com