I would like to track how long each bar of a tick chart is required to complete. How can I change the code below so that the time shown is the total time of the last completed bar, not the elapsed time of the current bar? This code calcs the ET for the current bar. Thanks in advance for a prompt response.
======================
/************************************************** ***************
Provided By : eSignal. (c) Copyright 2004
modified by Alexis C. Montenegro
************************************************** ****************/
function preMain() {
setPriceStudy(true);
setStudyTitle("ET");
setShowCursorLabel(false);
}
var vTimeStamp = null;
function main() {
if (getCurrentBarIndex() < -1) return;
var nState = getBarState();
var vClockTime = new Date()*1;
if (nState == BARSTATE_NEWBAR) {
vTimeStamp = getValue("Time")*1 ;
}
var vTimeElapse = (vClockTime-vTimeStamp);
if (vTimeElapse < 0) return;
var vMin = 0;
var vSec = 0;
vMin = Math.floor(vTimeElapse/60000);
vTimeElapse -= (vMin*60000);
vSec = Math.floor(vTimeElapse/1000);
vMin<10?vMin=("0"+vMin):vMin=(vMin+"");
vSec<10?vSec=("0"+vSec):vSec=(vSec+"");
vTimeElapse = (" " + vMin + ":" + vSec + " ");
if(vMin+vSec <= 180){
var vColor = "Color.lime";
}
if(vMin+vSec > 180 && vMin+vSec <= 360){
var vColor = "Color.yellow";
}
if(vMin+vSec > 360){
var vColor = "Color.red";
}
drawTextAbsolute(5, 6, vTimeElapse, eval(vColor), Color.black,
Text.BOLD|Text.RIGHT|Text.RELATIVETOTOP|Text.RELAT IVETORIGHT, null, 11, "TR");
return;
}
======================
/************************************************** ***************
Provided By : eSignal. (c) Copyright 2004
modified by Alexis C. Montenegro
************************************************** ****************/
function preMain() {
setPriceStudy(true);
setStudyTitle("ET");
setShowCursorLabel(false);
}
var vTimeStamp = null;
function main() {
if (getCurrentBarIndex() < -1) return;
var nState = getBarState();
var vClockTime = new Date()*1;
if (nState == BARSTATE_NEWBAR) {
vTimeStamp = getValue("Time")*1 ;
}
var vTimeElapse = (vClockTime-vTimeStamp);
if (vTimeElapse < 0) return;
var vMin = 0;
var vSec = 0;
vMin = Math.floor(vTimeElapse/60000);
vTimeElapse -= (vMin*60000);
vSec = Math.floor(vTimeElapse/1000);
vMin<10?vMin=("0"+vMin):vMin=(vMin+"");
vSec<10?vSec=("0"+vSec):vSec=(vSec+"");
vTimeElapse = (" " + vMin + ":" + vSec + " ");
if(vMin+vSec <= 180){
var vColor = "Color.lime";
}
if(vMin+vSec > 180 && vMin+vSec <= 360){
var vColor = "Color.yellow";
}
if(vMin+vSec > 360){
var vColor = "Color.red";
}
drawTextAbsolute(5, 6, vTimeElapse, eval(vColor), Color.black,
Text.BOLD|Text.RIGHT|Text.RELATIVETOTOP|Text.RELAT IVETORIGHT, null, 11, "TR");
return;
}
Comment