How can I add more horizontal lines to this study which would be x ticks above/below the H & L lines. The purpose is to show the A & C lines of the ACD system? Was unable to open the study with the Wizard. Thanks, Andrew.
Announcement
Collapse
No announcement yet.
FirstXminsHL.efs
Collapse
X
-
Andrew
In lines 83 and 88 of the following image you can see what you need to insert in the formula to draw two more lines one above the High line and one below the Low line.
In those commands replace every instance of your_value with the point value which needs to be added/subtracted.
If you want the values to show in the Cursor Window you will also need to modify the return statement as shown in the following image.
Also in this case replace your_value with the desired point value
Note that you will not be able to modufy this formula using the Formula Wizard as that tool can only read formulas that were written using the Formula Wizard which this efs is not.
Alex
-
Get syntax error line 97 nTicksA not defined
.
PHP Code:function preMain() {
setPriceStudy(true);
setStudyTitle("ACD System");
setCursorLabelName("30m H", 0);
setCursorLabelName("30m L", 1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.blue, 1);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setPlotType(PLOTTYPE_FLATLINES, 0);
setPlotType(PLOTTYPE_FLATLINES, 1);
var fp1 = new FunctionParameter("nMin", FunctionParameter.NUMBER);
fp1.setName("Number of Minutes");
fp1.setLowerLimit(1);
fp1.setDefault(60);
var fp2 = new FunctionParameter("nThickness", FunctionParameter.NUMBER);
fp2.setName("Line Thickness");
fp2.setLowerLimit(1);
fp2.setDefault(1);
var fp3 = new FunctionParameter("cColorH", FunctionParameter.COLOR);
fp3.setName("High Color");
fp3.setDefault(Color.blue);
var fp4 = new FunctionParameter("cColorL", FunctionParameter.COLOR);
fp4.setName("Low Color");
fp4.setDefault(Color.red);
var fp5 = new FunctionParameter("nTicksA", FunctionParameter.NUMBER);
fp5.setName("Ticks for A");
fp5.setLowerLimit(1);
fp5.setDefault(1)
var fp6 = new FunctionParameter("nTicksC", FunctionParameter.NUMBER);
fp6.setName("Ticks for C");
fp6.setLowerLimit(1);
fp6.setDefault(1)
}
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, cColorH, cColorL) {
if (nMin == null) nMin = 60;
if (bEdit == true) {
nMin = Math.round(nMin);
setCursorLabelName(nMin + "min H", 0);
setCursorLabelName(nMin + "min L", 1);
setDefaultBarThickness(nThickness, 0);
setDefaultBarThickness(nThickness, 0);
setDefaultBarFgColor(cColorH, 0);
setDefaultBarFgColor(cColorL, 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,
cColorH, "Hline");
drawLineRelative( FirstBar, vHigh+nTicksA, 0,vHigh+nTicksA, PS_SOLID, nThickness, cColor, "Hline2");
drawLineRelative( FirstBar, vHigh+nTicksA, 0,vHigh+nTicksC, PS_SOLID, nThickness, cColor, "Hline3");
drawTextRelative( 2, vHigh, vHigh.toFixed(2), cColorH, null,
Text.VCENTER|Text.BOLD, null, 10, "High");
drawLineRelative( FirstBar, vLow, 0, vLow, PS_SOLID, nThickness,
cColorL, "Lline")
drawLineRelative( FirstBar, vLow+nTicksA, 0,vLow-nTicksA, PS_SOLID, nThickness, cColor, "Lline2");
drawLineRelative( FirstBar, vLow+nTicksA, 0,vLow-nTicksA, PS_SOLID, nThickness, cColor, "Lline3");
drawTextRelative( 2, vLow, vLow.toFixed(2), cColorL, null,
Text.VCENTER|Text.BOLD, null, 10, "Low");
}
if (bActive == false) {
return new Array((vHigh+nTicksA).toFixed(2),(vHigh+nTicksC).toFixed(2),vHigh.toFixed(2), vLow.toFixed(2),(vLow-nTicksA).toFixed(2),(vLow-nTicksC).toFixed(2));
}
return null;
Comment
-
Exact message when I try to run in chart
Downloads\ACD System.efs, line 97:
ReferenceError: cColor is not defined
Downloads\ACD System.efs, line 97:
ReferenceError: cColor is not defined
No Syntax Errors
Downloads\ACD System.efs, line 97:
ReferenceError: nTicksA is not defined
No Syntax Errors
Downloads\ACD System.efs, line 97:
ReferenceError: nTicksA is not defined
No Syntax Errors
No Syntax Errors
No Syntax Errors
Downloads\ACD System.efs, line 97:
ReferenceError: nTicksA is not defined
No Syntax Errors
No SyntaxErrors
Downloads\ACD System.efs, line 97:
ReferenceError: nTicksA is not defined
No Syntax Errors
Downloads\ACD System.efs, line 97:
ReferenceError: nTicksA is not defined
No Syntax Errors
No Syntax Errors
No Syntax Errors
Comment
-
astanton
Although it refers to the same line the message is actually different as it is telling you that cColor is not defined..
You replaced the original cColor FunctionParameter with two new FunctionParameters ie cColorH and cColorL.
You now need to replace every instance of cColor with either cColorH or cColorL
Alex
Comment
-
Last hurdle
Thanks for all your help. The following does exactly what I want with one small problem that I cannot resolve. In the cursor window the H value shows up as CUp, L as AUp, CUp as L, and AUp as H. Your help is greatly appreciated, Andrew.
function preMain() {
setPriceStudy(true);
setStudyTitle("ACD System");
setCursorLabelName("30m H", 0);
setCursorLabelName("30m L", 1);
setCursorLabelName("CUp", 2);
setCursorLabelName("AUp", 3);
setCursorLabelName("ADown", 4);
setCursorLabelName("CDown", 5);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.blue, 1);
setDefaultBarFgColor(Color.blue, 2);
setDefaultBarFgColor(Color.blue, 3);
setDefaultBarFgColor(Color.blue, 4);
setDefaultBarFgColor(Color.blue, 5);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setDefaultBarThickness(1, 2);
setDefaultBarThickness(1, 3);
setDefaultBarThickness(1, 4);
setDefaultBarThickness(1, 5);
setPlotType(PLOTTYPE_FLATLINES, 0);
setPlotType(PLOTTYPE_FLATLINES, 1);
setPlotType(PLOTTYPE_FLATLINES, 2);
setPlotType(PLOTTYPE_FLATLINES, 3);
setPlotType(PLOTTYPE_FLATLINES, 4);
setPlotType(PLOTTYPE_FLATLINES, 5);
var fp1 = new FunctionParameter("nMin", FunctionParameter.NUMBER);
fp1.setName("Number of Minutes");
fp1.setLowerLimit(1);
fp1.setDefault(60);
var fp2 = new FunctionParameter("nThickness", FunctionParameter.NUMBER);
fp2.setName("Line Thickness");
fp2.setLowerLimit(1);
fp2.setDefault(1);
var fp3 = new FunctionParameter("cColorH", FunctionParameter.COLOR);
fp3.setName("High Color");
fp3.setDefault(Color.blue);
var fp4 = new FunctionParameter("cColorL", FunctionParameter.COLOR);
fp4.setName("Low Color");
fp4.setDefault(Color.red);
var fp5 = new FunctionParameter("nTicksA", FunctionParameter.NUMBER);
fp5.setName("Ticks for A");
fp5.setLowerLimit(.01);
fp5.setDefault(1)
var fp6 = new FunctionParameter("nTicksC", FunctionParameter.NUMBER);
fp6.setName("Ticks for C");
fp6.setLowerLimit(.01);
fp6.setDefault(1)
var fp7 = new FunctionParameter("cColorCUp", FunctionParameter.COLOR);
fp7.setName("C Up Color");
fp7.setDefault(Color.blue);
var fp8 = new FunctionParameter("cColorAUp", FunctionParameter.COLOR);
fp8.setName("A Up Color");
fp8.setDefault(Color.blue);
var fp9 = new FunctionParameter("cColorADown", FunctionParameter.COLOR);
fp9.setName("A Down Color");
fp9.setDefault(Color.red);
var fp10 = new FunctionParameter("cColorCDown", FunctionParameter.COLOR);
fp10.setName("C Down Color");
fp10.setDefault(Color.red);
}
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, cColorH, cColorL, cColorCUp, cColorAUp, cColorADown, cColorCDown, nTicksA, nTicksC) {
if (nMin == null) nMin = 60;
if (bEdit == true) {
nMin = Math.round(nMin);
setCursorLabelName(nMin + "min H", 0);
setCursorLabelName(nMin + "min L", 1);
setDefaultBarThickness(nThickness, 0);
setDefaultBarThickness(nThickness, 0);
setDefaultBarFgColor(cColorH, 0);
setDefaultBarFgColor(cColorL, 1);
setDefaultBarFgColor(cColorCUp, 2);
setDefaultBarFgColor(cColorAUp, 3);
setDefaultBarFgColor(cColorADown, 4);
setDefaultBarFgColor(cColorCDown, 5);
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,cColorH, "Hline");
drawLineRelative( FirstBar, vHigh+nTicksC, 0,vHigh+nTicksC, PS_SOLID, nThickness, cColorCUp, "CUp");
drawLineRelative( FirstBar, vHigh+nTicksA, 0,vHigh+nTicksA, PS_SOLID, nThickness, cColorAUp, "AUp");
drawTextRelative( 2, vHigh, vHigh.toFixed(2), cColorH, null, Text.VCENTER|Text.BOLD, null, 10, "High");
drawLineRelative( FirstBar, vLow, 0, vLow, PS_SOLID, nThickness, cColorL, "Lline")
drawLineRelative( FirstBar, vLow-nTicksA, 0,vLow-nTicksA, PS_SOLID, nThickness, cColorADown, "ADown");
drawLineRelative( FirstBar, vLow-nTicksC, 0,vLow-nTicksC, PS_SOLID, nThickness, cColorCDown, "CDown");
drawTextRelative( 2, vLow, vLow.toFixed(2), cColorL, null, Text.VCENTER|Text.BOLD, null, 10, "Low");
}
if (bActive == false) {
return new Array((vHigh+nTicksA).toFixed(2),(vHigh+nTicksC).t oFixed(2),vHigh.toFixed(2), vLow.toFixed(2),
(vLow-nTicksA).toFixed(2),(vLow-nTicksC).toFixed(2));
}
return null;
}
Comment
Comment