Hello;
Is there a way to comment out the MA's in the efs? I just want the chart to change colors and not show the moving averages.
Enclosed is the efs.
Thanks for your time..Greg
var vMA1 = null;
var vMA2 = null;
function preMain() {
setPriceStudy(true);
setStudyTitle("MAx2");
setCursorLabelName("MA1", 0);
setCursorLabelName("MA2", 1);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
checkVersion(1,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/basicMAx2.efs"); //Comment this line out if modifying the code
var fp1 = new FunctionParameter("MA1Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(9); //Edit this value to set a new default
var fp2 = new FunctionParameter("MA1Offset", FunctionParameter.NUMBER);
fp2.setDefault(0); //Edit this value to set a new default
var fp3 = new FunctionParameter("MA1Source", FunctionParameter.STRING);
fp3.setName("MA1Source");
fp3.addOption("Close");
fp3.addOption("High");
fp3.addOption("Low");
fp3.addOption("Open");
fp3.addOption("HL/2");
fp3.addOption("HLC/3");
fp3.addOption("OHLC/4");
fp3.setDefault("Close"); //Edit this value to set a new default
var fp4 = new FunctionParameter("MA1Type", FunctionParameter.STRING);
fp4.setName("MA1Type");
fp4.addOption("MAStudy.SIMPLE");
fp4.addOption("MAStudy.EXPONENTIAL");
fp4.addOption("MAStudy.WEIGHTED");
fp4.addOption("MAStudy.VOLUMEWEIGHTED");
fp4.setDefault("MAStudy.SIMPLE"); //Edit this value to set a new default
var fp5 = new FunctionParameter("MA2Length", FunctionParameter.NUMBER);
fp5.setLowerLimit(1);
fp5.setDefault(18); //Edit this value to set a new default
var fp6 = new FunctionParameter("MA2Offset", FunctionParameter.NUMBER);
fp6.setDefault(0); //Edit this value to set a new default
var fp7 = new FunctionParameter("MA2Source", FunctionParameter.STRING);
fp7.setName("MA1Source");
fp7.addOption("Close");
fp7.addOption("High");
fp7.addOption("Low");
fp7.addOption("Open");
fp7.addOption("HL/2");
fp7.addOption("HLC/3");
fp7.addOption("OHLC/4");
fp7.setDefault("Close"); //Edit this value to set a new default
var fp8 = new FunctionParameter("MA2Type", FunctionParameter.STRING);
fp8.setName("MA2Type");
fp8.addOption("MAStudy.SIMPLE");
fp8.addOption("MAStudy.EXPONENTIAL");
fp8.addOption("MAStudy.WEIGHTED");
fp8.addOption("MAStudy.VOLUMEWEIGHTED");
fp8.setDefault("MAStudy.SIMPLE"); //Edit this value to set a new default
var fp9 = new FunctionParameter("vColor1", FunctionParameter.COLOR);
fp9.setName("Color1");
fp9.setDefault(Color.blue); //Edit this value to set a new default
var fp10 = new FunctionParameter("vColor2", FunctionParameter.COLOR);
fp10.setName("Color2");
fp10.setDefault(Color.white); //Edit this value to set a new default
var fp11 = new FunctionParameter("vOption", FunctionParameter.STRING);
fp11.setName("Apply Color to:");
fp11.addOption("Chart");
fp11.addOption("Bar");
fp11.setDefault("Chart"); //Edit this value to set a new default
}
function main(MA1Length,MA1Offset,MA1Source,MA1Type,MA2Leng th,MA2Offset,MA2Source,MA2Type,vColor1,vColor2,vOp tion) {
if (vMA1 == null) vMA1 = new MAStudy(MA1Length, MA1Offset, MA1Source, eval(MA1Type));
if (vMA2 == null) vMA2 = new MAStudy(MA2Length, MA2Offset, MA2Source, eval(MA2Type));
/*****************************************
Insert your code following this text block
Use vMA1.getValue(MAStudy.MA) and
vMA2.getValue(MAStudy.MA) for your code
******************************************/
if(vOption=="Chart"){
if(vMA1.getValue(MAStudy.MA)>vMA2.getValue(MAStudy .MA)){
setChartBG(vColor1);
}
if(vMA1.getValue(MAStudy.MA)<vMA2.getValue(MAStudy .MA)){
setChartBG(vColor2);
}
}
if(vOption=="Bar"){
if(vMA1.getValue(MAStudy.MA)>vMA2.getValue(MAStudy .MA)){
setBarBgColor(vColor1);
}
if(vMA1.getValue(MAStudy.MA)<vMA2.getValue(MAStudy .MA)){
setBarBgColor(vColor2);
}
}
return new Array (vMA1.getValue(MAStudy.MA),vMA2.getValue(MAStudy.M A));
}
Is there a way to comment out the MA's in the efs? I just want the chart to change colors and not show the moving averages.
Enclosed is the efs.
Thanks for your time..Greg
var vMA1 = null;
var vMA2 = null;
function preMain() {
setPriceStudy(true);
setStudyTitle("MAx2");
setCursorLabelName("MA1", 0);
setCursorLabelName("MA2", 1);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
checkVersion(1,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/basicMAx2.efs"); //Comment this line out if modifying the code
var fp1 = new FunctionParameter("MA1Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(9); //Edit this value to set a new default
var fp2 = new FunctionParameter("MA1Offset", FunctionParameter.NUMBER);
fp2.setDefault(0); //Edit this value to set a new default
var fp3 = new FunctionParameter("MA1Source", FunctionParameter.STRING);
fp3.setName("MA1Source");
fp3.addOption("Close");
fp3.addOption("High");
fp3.addOption("Low");
fp3.addOption("Open");
fp3.addOption("HL/2");
fp3.addOption("HLC/3");
fp3.addOption("OHLC/4");
fp3.setDefault("Close"); //Edit this value to set a new default
var fp4 = new FunctionParameter("MA1Type", FunctionParameter.STRING);
fp4.setName("MA1Type");
fp4.addOption("MAStudy.SIMPLE");
fp4.addOption("MAStudy.EXPONENTIAL");
fp4.addOption("MAStudy.WEIGHTED");
fp4.addOption("MAStudy.VOLUMEWEIGHTED");
fp4.setDefault("MAStudy.SIMPLE"); //Edit this value to set a new default
var fp5 = new FunctionParameter("MA2Length", FunctionParameter.NUMBER);
fp5.setLowerLimit(1);
fp5.setDefault(18); //Edit this value to set a new default
var fp6 = new FunctionParameter("MA2Offset", FunctionParameter.NUMBER);
fp6.setDefault(0); //Edit this value to set a new default
var fp7 = new FunctionParameter("MA2Source", FunctionParameter.STRING);
fp7.setName("MA1Source");
fp7.addOption("Close");
fp7.addOption("High");
fp7.addOption("Low");
fp7.addOption("Open");
fp7.addOption("HL/2");
fp7.addOption("HLC/3");
fp7.addOption("OHLC/4");
fp7.setDefault("Close"); //Edit this value to set a new default
var fp8 = new FunctionParameter("MA2Type", FunctionParameter.STRING);
fp8.setName("MA2Type");
fp8.addOption("MAStudy.SIMPLE");
fp8.addOption("MAStudy.EXPONENTIAL");
fp8.addOption("MAStudy.WEIGHTED");
fp8.addOption("MAStudy.VOLUMEWEIGHTED");
fp8.setDefault("MAStudy.SIMPLE"); //Edit this value to set a new default
var fp9 = new FunctionParameter("vColor1", FunctionParameter.COLOR);
fp9.setName("Color1");
fp9.setDefault(Color.blue); //Edit this value to set a new default
var fp10 = new FunctionParameter("vColor2", FunctionParameter.COLOR);
fp10.setName("Color2");
fp10.setDefault(Color.white); //Edit this value to set a new default
var fp11 = new FunctionParameter("vOption", FunctionParameter.STRING);
fp11.setName("Apply Color to:");
fp11.addOption("Chart");
fp11.addOption("Bar");
fp11.setDefault("Chart"); //Edit this value to set a new default
}
function main(MA1Length,MA1Offset,MA1Source,MA1Type,MA2Leng th,MA2Offset,MA2Source,MA2Type,vColor1,vColor2,vOp tion) {
if (vMA1 == null) vMA1 = new MAStudy(MA1Length, MA1Offset, MA1Source, eval(MA1Type));
if (vMA2 == null) vMA2 = new MAStudy(MA2Length, MA2Offset, MA2Source, eval(MA2Type));
/*****************************************
Insert your code following this text block
Use vMA1.getValue(MAStudy.MA) and
vMA2.getValue(MAStudy.MA) for your code
******************************************/
if(vOption=="Chart"){
if(vMA1.getValue(MAStudy.MA)>vMA2.getValue(MAStudy .MA)){
setChartBG(vColor1);
}
if(vMA1.getValue(MAStudy.MA)<vMA2.getValue(MAStudy .MA)){
setChartBG(vColor2);
}
}
if(vOption=="Bar"){
if(vMA1.getValue(MAStudy.MA)>vMA2.getValue(MAStudy .MA)){
setBarBgColor(vColor1);
}
if(vMA1.getValue(MAStudy.MA)<vMA2.getValue(MAStudy .MA)){
setBarBgColor(vColor2);
}
}
return new Array (vMA1.getValue(MAStudy.MA),vMA2.getValue(MAStudy.M A));
}
Comment