hi,
if anyone help me out... trying to create watchlist efs. this watchlist i want long and short text . not giveing me any error but the result is not what i want , Here is the efs code
thanks a lot
vishu
var fpArray = new Array();
var bVersion = null;
function preMain() {
setComputeOnClose();
setCursorLabelName("Trend", 0);
setCursorLabelName("Reversal", 1);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("gPeriod", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Trailing Loss");
setLowerLimit(0);
setUpperLimit(100);
setDefault(.6);
}
fpArray[x] = new FunctionParameter("gViewOption", FunctionParameter.STRING);
with(fpArray[x++]){
setName("View Type");
addOption("Value");
addOption("Text");
addOption("Sign");
addOption("Nothing");
setDefault("Text");
}
fpArray[x] = new FunctionParameter("gColoringOption", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Coloring Type");
addOption("Font");
addOption("Background");
addOption("No coloring");
setDefault("Font");
}
fpArray[x] = new FunctionParameter("gLONGColor", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("LONG");
setDefault(Color.green);
}
fpArray[x] = new FunctionParameter("gSHORTColor", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("SHORT");
setDefault(Color.red);
}
}
var bInit = false;
var bVersion = null;
var nRef = 0;
var xS_R = null;
var vFlag = false;
var servTable = new Array();
var outVal = null;
function main(gViewOption, gPeriod, gColoringOption, gLONGColor, gSHORTColor){
if(getBarState()==BARSTATE_NEWBAR){
vFlag = false;
}
var nClose = close(0);
var nClose1 = close(-1);
var nX_R = 0;
var nX_R1 = 0;
if (bVersion == null) bVersion = verify();
if (bVersion == false) return;
if (!bInit){
xS_R = efsInternal("TrailingStop", gPeriod);
servTable[0] = new Array (gViewOption, gPeriod, gColoringOption, gLONGColor, gSHORTColor);
if (gViewOption == "Text") servTable[1] = new Array("LONG", "SHORT");
if (gViewOption == "Sign") servTable[1] = new Array("+", "-");
bInit=true;
}
if (getCurrentBarIndex() == 0) return;
nX_R = xS_R.getValue(0);
nX_R1 = xS_R.getValue(-1);
if (nX_R1 == null) return;
var cond = 0;
if (nClose1 < nX_R1 && nClose > nX_R) cond = 1;
if (nClose1 > nX_R1 && nClose < nX_R) cond = 2;
if (nClose1 == nX_R1 && nClose == nX_R) cond = 3;
if (gColoringOption == false) return;
return xS_R.getValue(0);
if ( gColoringOption == "Background" ) setBarBgColor(servTable[0][cond+3]);
if ( gColoringOption == "Font" ) setBarFgColor(servTable[0][cond+3]);
if ( gViewOption == "Value" ) outVal = nClose1;
if ( gViewOption == "Text" || gViewOption == "Sign" ) outVal = servTable[1][cond + 3];
return outVal;
}
function TrailingStop(gPeriod){
var Close = close(0);
var loss = Close * gPeriod / 100;
var nRes = 0;
var nRef = ref(-1);
if (nRef == null) nRef = Close;
if (Close > nRef && close(-1) > nRef) {
nRes = Math.max(nRef, Close - loss)
} else {
if (Close < nRef && close(-1) < nRef) {
nRes = Math.min(nRef, Close + loss)
} else {
if (Close > nRef) {
nRes = Close - loss;
} else {
nRes = Close + loss;
}
}
}
return nRes;
}
function verify() {
var b = false;
if (getBuildNumber() < 779) {
drawTextAbsolute(5, 35, "This study requires version 8.0 or later.",
Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOL D|Text.LEFT,
null, 13, "error");
drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp",
Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOL D|Text.LEFT,
null, 13, "upgrade");
return b;
} else {
b = true;
}
return b;
}
if anyone help me out... trying to create watchlist efs. this watchlist i want long and short text . not giveing me any error but the result is not what i want , Here is the efs code
thanks a lot
vishu
var fpArray = new Array();
var bVersion = null;
function preMain() {
setComputeOnClose();
setCursorLabelName("Trend", 0);
setCursorLabelName("Reversal", 1);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("gPeriod", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Trailing Loss");
setLowerLimit(0);
setUpperLimit(100);
setDefault(.6);
}
fpArray[x] = new FunctionParameter("gViewOption", FunctionParameter.STRING);
with(fpArray[x++]){
setName("View Type");
addOption("Value");
addOption("Text");
addOption("Sign");
addOption("Nothing");
setDefault("Text");
}
fpArray[x] = new FunctionParameter("gColoringOption", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Coloring Type");
addOption("Font");
addOption("Background");
addOption("No coloring");
setDefault("Font");
}
fpArray[x] = new FunctionParameter("gLONGColor", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("LONG");
setDefault(Color.green);
}
fpArray[x] = new FunctionParameter("gSHORTColor", FunctionParameter.COLOR);
with(fpArray[x++]){
setName("SHORT");
setDefault(Color.red);
}
}
var bInit = false;
var bVersion = null;
var nRef = 0;
var xS_R = null;
var vFlag = false;
var servTable = new Array();
var outVal = null;
function main(gViewOption, gPeriod, gColoringOption, gLONGColor, gSHORTColor){
if(getBarState()==BARSTATE_NEWBAR){
vFlag = false;
}
var nClose = close(0);
var nClose1 = close(-1);
var nX_R = 0;
var nX_R1 = 0;
if (bVersion == null) bVersion = verify();
if (bVersion == false) return;
if (!bInit){
xS_R = efsInternal("TrailingStop", gPeriod);
servTable[0] = new Array (gViewOption, gPeriod, gColoringOption, gLONGColor, gSHORTColor);
if (gViewOption == "Text") servTable[1] = new Array("LONG", "SHORT");
if (gViewOption == "Sign") servTable[1] = new Array("+", "-");
bInit=true;
}
if (getCurrentBarIndex() == 0) return;
nX_R = xS_R.getValue(0);
nX_R1 = xS_R.getValue(-1);
if (nX_R1 == null) return;
var cond = 0;
if (nClose1 < nX_R1 && nClose > nX_R) cond = 1;
if (nClose1 > nX_R1 && nClose < nX_R) cond = 2;
if (nClose1 == nX_R1 && nClose == nX_R) cond = 3;
if (gColoringOption == false) return;
return xS_R.getValue(0);
if ( gColoringOption == "Background" ) setBarBgColor(servTable[0][cond+3]);
if ( gColoringOption == "Font" ) setBarFgColor(servTable[0][cond+3]);
if ( gViewOption == "Value" ) outVal = nClose1;
if ( gViewOption == "Text" || gViewOption == "Sign" ) outVal = servTable[1][cond + 3];
return outVal;
}
function TrailingStop(gPeriod){
var Close = close(0);
var loss = Close * gPeriod / 100;
var nRes = 0;
var nRef = ref(-1);
if (nRef == null) nRef = Close;
if (Close > nRef && close(-1) > nRef) {
nRes = Math.max(nRef, Close - loss)
} else {
if (Close < nRef && close(-1) < nRef) {
nRes = Math.min(nRef, Close + loss)
} else {
if (Close > nRef) {
nRes = Close - loss;
} else {
nRes = Close + loss;
}
}
}
return nRes;
}
function verify() {
var b = false;
if (getBuildNumber() < 779) {
drawTextAbsolute(5, 35, "This study requires version 8.0 or later.",
Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOL D|Text.LEFT,
null, 13, "error");
drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp",
Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOL D|Text.LEFT,
null, 13, "upgrade");
return b;
} else {
b = true;
}
return b;
}