Hello,
I hopefully have a simple request, I have found the following efs which represents the EMS(8) either going up(in green) or down(in red). This efs works great on any chart with any timeframe. I am trying to see if I can display multiple timeframes on one chart e.g. 1minute, 2minute, 3minute of the ema(8). Here is the existing efs I have found, any guidence or assistance is appreciated.
var vMA = null;
function preMain() {
setPriceStudy(true);
setStudyTitle("EMA");
setCursorLabelName("EMA", 0);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarThickness(3,0);
var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(8); //Edit this value to set a new default
var fp2 = new FunctionParameter("Offset", FunctionParameter.NUMBER);
fp2.setDefault(0); //Edit this value to set a new default
var fp3 = new FunctionParameter("Source", FunctionParameter.STRING);
fp3.setName("Source");
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("Type", FunctionParameter.STRING);
fp4.setName("Type");
fp4.addOption("MAStudy.SIMPLE");
fp4.addOption("MAStudy.EXPONENTIAL");
fp4.addOption("MAStudy.WEIGHTED");
fp4.addOption("MAStudy.VOLUMEWEIGHTED");
fp4.setDefault("MAStudy.EXPONENTIAL"); //Edit this value to set a new default
}
function main(Length,Offset,Source,Type) {
if (vMA == null) vMA = new MAStudy(Length, Offset, Source, eval(Type));
/*****************************************
Insert your code following this text block
Use vMA.getValue(MAStudy.MA) for your code
******************************************/
if (vMA.getValue(MAStudy.MA,0) > vMA.getValue(MAStudy.MA,-1) ) {
setBarFgColor(Color.green);
} else {
setBarFgColor(Color.red);
}
return vMA.getValue(MAStudy.MA);
}
I hopefully have a simple request, I have found the following efs which represents the EMS(8) either going up(in green) or down(in red). This efs works great on any chart with any timeframe. I am trying to see if I can display multiple timeframes on one chart e.g. 1minute, 2minute, 3minute of the ema(8). Here is the existing efs I have found, any guidence or assistance is appreciated.
var vMA = null;
function preMain() {
setPriceStudy(true);
setStudyTitle("EMA");
setCursorLabelName("EMA", 0);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarThickness(3,0);
var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(8); //Edit this value to set a new default
var fp2 = new FunctionParameter("Offset", FunctionParameter.NUMBER);
fp2.setDefault(0); //Edit this value to set a new default
var fp3 = new FunctionParameter("Source", FunctionParameter.STRING);
fp3.setName("Source");
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("Type", FunctionParameter.STRING);
fp4.setName("Type");
fp4.addOption("MAStudy.SIMPLE");
fp4.addOption("MAStudy.EXPONENTIAL");
fp4.addOption("MAStudy.WEIGHTED");
fp4.addOption("MAStudy.VOLUMEWEIGHTED");
fp4.setDefault("MAStudy.EXPONENTIAL"); //Edit this value to set a new default
}
function main(Length,Offset,Source,Type) {
if (vMA == null) vMA = new MAStudy(Length, Offset, Source, eval(Type));
/*****************************************
Insert your code following this text block
Use vMA.getValue(MAStudy.MA) for your code
******************************************/
if (vMA.getValue(MAStudy.MA,0) > vMA.getValue(MAStudy.MA,-1) ) {
setBarFgColor(Color.green);
} else {
setBarFgColor(Color.red);
}
return vMA.getValue(MAStudy.MA);
}
Comment