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.
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);
color_candles(color);