Hope someone can help me here.
I've got a formula that prints the day's high/low after the first 30mins.
However, it also prints the highs or lows leading up to this point. See attached chart.
Is there a way to stop this please.
Here's the formula:
function preMain() {
setPriceStudy(true);
setStudyTitle("First X mins HL ");
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.blue, 1);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setPlotType(PLOTTYPE_FLATLINES, 0);
setPlotType(PLOTTYPE_FLATLINES, 1);
setShowCursorLabel(false);
var fp1 = new FunctionParameter("nMin", FunctionParameter.NUMBER);
fp1.setName("Number of Minutes");
fp1.setLowerLimit(1);
fp1.setDefault(35);
var fp2 = new FunctionParameter("nThickness", FunctionParameter.NUMBER);
fp2.setName("Line Thickness");
fp2.setLowerLimit(1);
fp2.setDefault(1);
var fp3 = new FunctionParameter("cColor", FunctionParameter.COLOR);
fp3.setName("Line Color");
fp3.setDefault(Color.blue);
}
var bEdit = true;
var bActive = true;
var nDayCntr = 0;
var vStartTime = null;
var vHigh = null;
var vLow = null;
var FirstBar = null;
function main(nMin, nThickness, cColor) {
if (nMin == null) nMin = 35;
if (bEdit == true) {
nMin = Math.round(nMin);
setCursorLabelName(nMin + "min H", 0);
setCursorLabelName(nMin + "min L", 1);
setDefaultBarThickness(nThickness, 0);
setDefaultBarThickness(nThickness, 0);
setDefaultBarFgColor(cColor, 0);
setDefaultBarFgColor(cColor, 1);
bEdit = false;
}
if (getDay() != getDay(-1) || vHigh == null || vLow == null) {
bActive = true;
nDayCntr += 1;
vStartTime = getValue("Time");
vHigh = high();
vLow = low();
}
FirstBar = getFirstBarIndexOfDay(vStartTime);
var vTime = getValue("Time");
// 3,600,000 milliseconds = 1 hour
// 60,000 milliseconds = 1 minute
if ((vTime - vStartTime)/60000 < nMin) {
vHigh = Math.max(high(), vHigh);
vLow = Math.min(low(), vLow);
} else {
bActive = false;
}
if (FirstBar != null) {
drawLineRelative( FirstBar, vHigh, 0, vHigh, PS_SOLID, nThickness,
cColor, "Hline");
drawLineRelative( FirstBar, vLow, 0, vLow, PS_SOLID, nThickness,
cColor, "Lline")
}
return new Array(vHigh, vLow);
return null;
}
I've got a formula that prints the day's high/low after the first 30mins.
However, it also prints the highs or lows leading up to this point. See attached chart.
Is there a way to stop this please.
Here's the formula:
function preMain() {
setPriceStudy(true);
setStudyTitle("First X mins HL ");
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.blue, 1);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setPlotType(PLOTTYPE_FLATLINES, 0);
setPlotType(PLOTTYPE_FLATLINES, 1);
setShowCursorLabel(false);
var fp1 = new FunctionParameter("nMin", FunctionParameter.NUMBER);
fp1.setName("Number of Minutes");
fp1.setLowerLimit(1);
fp1.setDefault(35);
var fp2 = new FunctionParameter("nThickness", FunctionParameter.NUMBER);
fp2.setName("Line Thickness");
fp2.setLowerLimit(1);
fp2.setDefault(1);
var fp3 = new FunctionParameter("cColor", FunctionParameter.COLOR);
fp3.setName("Line Color");
fp3.setDefault(Color.blue);
}
var bEdit = true;
var bActive = true;
var nDayCntr = 0;
var vStartTime = null;
var vHigh = null;
var vLow = null;
var FirstBar = null;
function main(nMin, nThickness, cColor) {
if (nMin == null) nMin = 35;
if (bEdit == true) {
nMin = Math.round(nMin);
setCursorLabelName(nMin + "min H", 0);
setCursorLabelName(nMin + "min L", 1);
setDefaultBarThickness(nThickness, 0);
setDefaultBarThickness(nThickness, 0);
setDefaultBarFgColor(cColor, 0);
setDefaultBarFgColor(cColor, 1);
bEdit = false;
}
if (getDay() != getDay(-1) || vHigh == null || vLow == null) {
bActive = true;
nDayCntr += 1;
vStartTime = getValue("Time");
vHigh = high();
vLow = low();
}
FirstBar = getFirstBarIndexOfDay(vStartTime);
var vTime = getValue("Time");
// 3,600,000 milliseconds = 1 hour
// 60,000 milliseconds = 1 minute
if ((vTime - vStartTime)/60000 < nMin) {
vHigh = Math.max(high(), vHigh);
vLow = Math.min(low(), vLow);
} else {
bActive = false;
}
if (FirstBar != null) {
drawLineRelative( FirstBar, vHigh, 0, vHigh, PS_SOLID, nThickness,
cColor, "Hline");
drawLineRelative( FirstBar, vLow, 0, vLow, PS_SOLID, nThickness,
cColor, "Lline")
}
return new Array(vHigh, vLow);
return null;
}
Comment