Volume-weighted Ichimoku Cloud

//@version=3
study(“Volume Weighted Ichimoku”,shorttitle = “VW-CLOUD”, overlay = true)
displacement_A = input(26, minval = 1)
displacement_B = input(26, minval = 1)
conversion_len = input(9, minval = 1)
base_line_len = input(26, minval = 1)
senkou_B_len = input(51, minval = 1)

f(x) =>
total_volume = sum(volume, x)
volume_weighted_high = sum(highvolume, x)/total_volume
volume_weighted_low = sum(low
volume, x)/total_volume
(volume_weighted_high + volume_weighted_low)/2

conversion_line = f(conversion_len)
base_line = f(base_line_len)
senkou_A = (conversion_line + base_line)/2
senkou_B = f(senkou_B_len)

p1 = plot(senkou_A, offset = displacement_A, color = green, title = “Senkou A”, linewidth = 2, transp = 100)
p2 = plot(senkou_B, offset = displacement_B, color = red, title = “Senkou B”, linewidth = 2, transp = 100)
plot(base_line, color = #991515, title = “Base Line”, linewidth = 2 )
plot(conversion_line, color = #0496ff, title = “Conversion Line”, linewidth = 2 )
fill(p1, p2 , color = senkou_A > senkou_B ? green : red)

\\\\\\\\\\\\\\\\

I’d like to convert this pine script Volume-weighted Ichimoku Cloud for use in Tradovate, but simply do not have the skills required to do so. I was hoping to convert this and add a chikou line. I considered trying to integrate this into traf’s Ichimoku Cloud code on Tradovate’s community public indicators, but it’s way too complicated for me. This is that code…

// Ichimoku Clouds
// ver 1.1
// (twitter: trad_ES)
// (discord: traf93)
// (@trader9319 at gmail.com)

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

class trafsIchimoku {
init() {

    this.sphighest = new MovingHigh(this.props.Tenkan_period);
    this.splowest = new MovingLow(this.props.Tenkan_period);
    this.lphighest = new MovingHigh(this.props.Kijun_period);
    this.lplowest = new MovingLow(this.props.Kijun_period);
    
    this.APavglphighest = new MovingHigh(2 * this.props.Kijun_period);
    this.SPavglplowest = new MovingLow(2 * this.props.Kijun_period);
    
    this.pSR = [];
    this.pLR = [];
}

map(d,i,history) {
    

    const lPeriod = this.props.Kijun_period;

   if (i < this.props.Kijun_period  ) return;
   
    const l = d.low();
    const c = d.close();
    const h = d.high();
    let pTenkan = (this.sphighest(h) + this.splowest(l)) / 2;
    let pKijun =  (this.lphighest(h) + this.lplowest(l)) / 2;
    
   
    this.pSR.push(pTenkan);
    this.pLR.push(pKijun); 
    
   if (i < lPeriod +1 ) return;
   
   const psRLen= this.pSR.length;
   const pLRLen= this.pLR.length;
    
   const    pSpan_A = (this.pSR[psRLen - lPeriod] + this.pLR[pLRLen-lPeriod] ) / 2; 
    
    
    let priorHighLP =(history.back(lPeriod)
            ).high();
    let priorLowLP = history.back(lPeriod)
            .low();   
    
    const Span_B = ( this.APavglphighest(priorHighLP) + this.SPavglplowest(priorLowLP) ) / 2;
    
    
    let pChikou = //history.back(lPeriod)
            d.close(); 
  
    return  {
        Tenkan: pTenkan,
        Kijun: pKijun,
        Span_A: pSpan_A,
        Span_B,
        Chikou:pChikou,
        pChikou,
        pTenkan,
        pKijun
        
    };
    
}

}

function IchimokuPlotter(canvas, indicatorInstance, history) {
for(let i=0; i<history.data.length; ++i) {
if (i> 1 ){
const item = history.get(i);
const x = p.x.get(item);

    let itemoffset = indicatorInstance.props.Kijun_period;
    
           const itemp = history.get(i-1);
           const xp = p.x.get(itemp);
    
    
        //cloud
        if ( item.Span_A !== undefined && item.Span_B !== undefined) {
         canvas.drawLine(
            p.offset(x, item.Span_A),
            p.offset(x, item.Span_B),
            {
                color: item.Span_A  > item.Span_B  ? indicatorInstance.props.IchmokuCloudUP : indicatorInstance.props.IchmokuCloudDOWN ,
                relativeWidth: 1,
                opacity: indicatorInstance.props.CloudOpacity//0.152
            });
        }
        
     //Span_A
      if ( item.Span_A !== undefined ) {
         canvas.drawLine(
            p.offset(x, item.Span_A),
            p.offset(xp, itemp.Span_A),
            {
                color: indicatorInstance.props.Span_AColor,
                width: indicatorInstance.props.Span_lineWidths,
                opacity: 1
            });
        }
        
     
     //Span_A
      if ( item.Span_B !== undefined ) {
         canvas.drawLine(
            p.offset(x, item.Span_B),
            p.offset(xp, itemp.Span_B),
            {
                color: indicatorInstance.props.Span_BColor,
                width: indicatorInstance.props.Span_lineWidths,
                opacity: 1
            });
        }
        
     
               //Chikou
               if( (i + itemoffset  ) < history.data.length  ) {     
                const item1 = history.get(i + itemoffset);
                const item2 = history.get(i + itemoffset-1);
                
                canvas.drawLine(
                    p.offset(x, item1.pChikou),
                    p.offset(xp, item2.pChikou),
                    {
                        color:  indicatorInstance.props.ChikouColor,
                        width: indicatorInstance.props.Chikou_lineWidths,
                        opacity: 1
                    });
                    
               }
               
    }
    
     
}

}

module.exports = {
name: “trafs_Ichimoku”,
description: “trafs_Ichimoku”,
calculator: trafsIchimoku,
params: {
Tenkan_period: predef.paramSpecs.period(9),
Kijun_period: predef.paramSpecs.period(26),
Span_AColor: predef.paramSpecs.color("#B5B5B5"),
Span_BColor: predef.paramSpecs.color("#E7BE00"),
Span_lineWidths: predef.paramSpecs.number(2),
IchmokuCloudUP: predef.paramSpecs.color( “#FFFF00”),
IchmokuCloudDOWN: predef.paramSpecs.color("#FF0000"),
CloudOpacity: predef.paramSpecs.percent(0.15, .05,0,1),
ChikouColor: predef.paramSpecs.color("#FF5F5F"),
Chikou_lineWidths: predef.paramSpecs.number(2)
},
tags: [‘Trafs Tools’],
inputType: meta.InputType.BARS,
plots: {
Tenkan: { title: “Tenkan” },
Kijun: { title: “Kijun” }/,
Span_A: { title: “Span_A” },
Span_B: { title: “Span_B” }
/
},
plotter: [
predef.plotters.singleline(“Tenkan”),
predef.plotters.singleline(“Kijun”),/* work around for screen paiting issues on zoomin
predef.plotters.singleline(“Span_A”),
predef.plotters.singleline(“Span_B”),*/
predef.plotters.custom(IchimokuPlotter)
],
schemeStyles: {
dark: {
Tenkan: predef.styles.plot({
color: “cyan”,
lineWidth: 2
}),
Kijun: predef.styles.plot({
color: “#FF7E9C”,
lineWidth: 2
})
},

    light: {
        Tenkan: predef.styles.plot({
            color: "cyan",
            lineWidth: 2
        }),
        Kijun: predef.styles.plot({
            color: "#FF7E9C",
            lineWidth: 2
        })
    }
}

};

If anybody has experience making volume weighted indicators and is willing to help, I’d appreciate it.

If this make a difference, I’m willing to pay up front to have this script translated for use in tradovate. I’m sure not everyone has enough free time to do this for no reason.