Volume weighted colors

A custom indicator created by Random Guy #15 on TrendSpider. You can import this script into your TrendSpider account. Don't have TrendSpider? Create an account first, then import the script.

Chart featuring the Volume weighted colors indicator

This indicator colors candles depending on how prominent their volume was, compared to highest and lowest volume for the previous 30 candles. Red candles stand for higher volume, blue candles stand for lower volume.

Source code

This indicator had been implemented by Random Guy #15 in JavaScript on TrendSpider. Check out the developer documentation to learn more about JS on TrendSpider.

describe_indicator('Volume weighted colors');

const maxVolume = highest(volume, 30);
const minVolume = lowest(volume, 30);
const volumeRange = sub(maxVolume, minVolume);

const candleColor = (open, close, volume, volumeRange) => {
    const volumeWeight = volume / volumeRange;
    const proportionalFactor = 100 + volumeWeight * 155;
    const inverselyProportionalFactor = 255 - volumeWeight * 255;

    return `rgb(${proportionalFactor},${inverselyProportionalFactor},${inverselyProportionalFactor})`;

const color = for_every(open, close, volume, volumeRange, candleColor);