I am having problems getting the following efs to work properly. As it is now, when the button is clicked, the colors are not defined. If the button function is moved within the main function, then the button function is not defined. Thank you in advance. Charley
PHP Code:
var nButtonPressed = false;
function preMain() {
setPriceStudy(true);
setStudyTitle("Line");
setShowCursorLabel(false);
var fp1 = new FunctionParameter("nMin", FunctionParameter.NUMBER);
fp1.setName("Number of Minutes");
fp1.setLowerLimit(1);
fp1.setDefault(15);
var fp2 = new FunctionParameter("nFont", FunctionParameter.STRING);
fp2.setName("Font");
fp2.setDefault("Arial");
var fp3 = new FunctionParameter("nFontSize", FunctionParameter.NUMBER);
fp3.setName("Font Size")
fp3.setLowerLimit(6);
fp3.setDefault(12);
var fp4 = new FunctionParameter("aColor", FunctionParameter.COLOR);
fp4.setName("Color");
fp4.setDefault(Color.RGB(0,225,0));
var fp5 = new FunctionParameter("bColor", FunctionParameter.COLOR);
fp5.setName("Color");
fp5.setDefault(Color.RGB(225,0,0));
var fp6 = new FunctionParameter("BuColor", FunctionParameter.COLOR);
fp6.setName("Button Color");
fp6.setDefault(Color.RGB(35,35,35));
}
var vStartTime = null;
var vHigh = null;
var vLow = null;
var vOpen = null;
var vClose = null;
var FirstBar = null;
function main(nMin, nFont, nFontSize, aColor, bColor, BuColor) {
if (getDay() != getDay(-1) || vHigh == null || vLow == null || vOpen == null || vClose == null) {
vStartTime = getValue("Time");
vHigh = high();
vLow = low();
vOpen = open();
vClose = close();
}
FirstBar = getFirstBarIndexOfDay(vStartTime);
var vTime = getValue("Time");
if ((vTime - vStartTime) / 60000 < nMin) { // 3,600,000 milliseconds = 1 hour
vHigh = Math.max(high(), vHigh); // 60,000 milliseconds = 1 minute
vLow = Math.min(low(), vLow);
}
drawTextPixel(80, 0, "Reverse" + "@URL=EFS:Button1", aColor, BuColor, Text.RELATIVETOLEFT | Text.RELATIVETOBOTTOM | Text.CENTER | Text.VCENTER, nFont, nFontSize, "Bu1", 80, 24);
if (FirstBar != null) {
if (vOpen < vClose) {
drawLineRelative(FirstBar, vHigh, 0, vHigh, PS_SOLID, 1, aColor, "High");
drawLineRelative(FirstBar, vLow, 0, vLow, PS_SOLID, 1, bColor, "Low");
}
if (vOpen > vClose) {
drawLineRelative(FirstBar, vHigh, 0, vHigh, PS_SOLID, 1, bColor, "High");
drawLineRelative(FirstBar, vLow, 0, vLow, PS_SOLID, 1, aColor, "Low")
}
}
}
function Button1(nButtonPressed) {
if (getButtonPressed(nButtonPressed) == 1) {
drawLineRelative(FirstBar, vHigh, 0, vHigh, PS_SOLID, 1, bColor, "High");
drawLineRelative(FirstBar, vLow, 0, vLow, PS_SOLID, 1, aColor, "Low")
}
}
function getButtonPressed(nButtonPressed) {
if (nButtonPressed == BUTTON_LEFT) {
return(1);
}
else {
return(0);
}
}
Comment