It appears simple.
It looks like a volume histogram on a time chart but shows a histogram of the time it takes for a bar to complete. Zero to 60 seconds is one color, 60 to 120 seconds is another color, 120 to 180 seconds is yet another color and so on.
The code could be edited to any time intervals you wanted to use based on the size of charts you use.
Its a nice visual indicator to have when using tic, volume or range bars
Thanks
/************************************************** *******
Opstock © September 2005
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
************************************************** ********/
function preMain() {
setPriceStudy(false);
setStudyTitle("Time Histogram for T&V charts")
setShowCursorLabel(true);
setDefaultBarFgColor(Color.magenta,0);
setDefaultBarThickness(5,0);
setPlotType(PLOTTYPE_HISTOGRAM);
setStudyMax(300);
//addBand(120, PS_SOLID, 1, Color.aqua);
}
function main() {
var TimeDiff = rawtime(0)-rawtime(-1);
if(TimeDiff > 0 && TimeDiff <= 60) {
setBar(Bar.FgColor, -1, Color.green);
}
if(TimeDiff > 60 && TimeDiff <= 120) {
setBar(Bar.FgColor, -1, Color.lime);
}
if(TimeDiff > 120 && TimeDiff <= 180) {
setBar(Bar.FgColor, -1, Color.yellow);
}
if(TimeDiff > 180 && TimeDiff <= 240) {
setBar(Bar.FgColor, -1, Color.RGB(255,128,0));
}
if(TimeDiff > 240 && TimeDiff <= 300) {
setBar(Bar.FgColor, -1, Color.red);
}
//return TimeDiff;
setBar(Bar.Value, -1, TimeDiff);
return null;
}
Comment