The following efs code works fine, I am mainly concerned about efficiency. This indicator panel plots four different tickers and it does not use any compute_on_close command. This panel is used under a 3-minute bar chart of an emini (AB or ES).
Will this efs get executed every time any one of the tickers changes value or when Price changes in the main panel or is one of them the 'master'?
Should I remove statements like:
if (vQT == null) return;
A third question: is the *1 on a statement like
var vT = close(0, 1, "$TRIN")*1;
necessary? I do it because it was done in the library example.
Will this efs get executed every time any one of the tickers changes value or when Price changes in the main panel or is one of them the 'master'?
Should I remove statements like:
if (vQT == null) return;
A third question: is the *1 on a statement like
var vT = close(0, 1, "$TRIN")*1;
necessary? I do it because it was done in the library example.
PHP Code:
/*
Larry's breadth panel
four indicators:
NY Tick blue bars
Nasdaq Tick green line
$ADD blue line
NY TRIN purple line (inverted)
some of this code borrowed from TickExtremes.efs in eSignal library
*/
function preMain() {
setPriceStudy(false);
setStudyTitle("BRED4");
// deleted some code here for brevity
// just sets colors,plottype...
setStudyMax(1500);
setStudyMin(-1500);
}
var vColor = Color.RGB(101,150,220);
var vLoaded = false;
var barH = null;
var barL = null;
var vNum = 150; // limits how many bars can be drawn
var BarCntr = 0;
var vSum = 0;
function main() {
if (vLoaded == false) {
addBand( 1000, PS_SOLID, 1, Color.grey, "top");
addBand( 0, PS_SOLID, 1, Color.black, "zero");
addBand(-1000, PS_SOLID, 1, Color.grey, "bottom");
vLoaded = true;
}
var vNT = close(0, 1, "$TICK")*1;
if (vNT == null) return;
if (getBarState() == BARSTATE_NEWBAR) {
if (BarCntr < vNum) {
BarCntr += 1;
} else {
BarCntr = 0;
}
barH = vNT;
barL = vNT;
}
// NY tick is drawn as bars
// the vNT value returned below is for esignal to draw the horizontal tick marks
if (isTick() == true || isRawTick() == true) {
barH = Math.max(barH, vNT);
barL = Math.min(barL, vNT);
} else {
var h = high(0, 1, "$tick")*1;
if (h == null) return;
var l = low(0, 1, "$tick")*1;
if (l == null) return;
barH = Math.max(barH, h, vNT);
barL = Math.min(barL, l, vNT);
}
drawLineRelative(0, barL, 0, barH, PS_SOLID, 2, vColor, "bar" + BarCntr);
var vQT = close(0, 1, "$TICKQ")*1;
if (vQT == null) return;
var vA = close(0, 1, "$ADD")*1;
if (vA == null) return;
var vT = close(0, 1, "$TRIN")*1;
if (vT == null) return;
// invert trin so it sorta fits the same scale
var vR = (1.0 - vT) * 1667;
return new Array(
vNT,
vQT,
vA,
vR
);
}
// END //
Comment