All
Two questions...
1. Is it possible to add a round-up and round-down element into the code?
For example (using the E-mini market), if the upper channel reads 871.92 can the EFS round up to the nearest .25 increment and read 872.00?
Same thing for the lower channel but rounded down i.e., 871.92 would read 871.75
----------------------------------------------
2. Along with the above rounding is it possible to also add a preset increase to the upper channel and a preset decrease to the lower channel?
Example, if the upper channel is supposed to read 872.00 could there be a place in the code I could adjust an "Add .25 or .75" so the display would read 872.25 or 872.75, respectively?
Same for the lower channel except subtracting the preset amount.
In volatile markets this preset could be ratcheted up.
------------------------------------------------
/************************************************** *******
Alexis C. Montenegro © July 2003
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
************************************************** ********/
var vMA = null;
vUpper = null;
vLower = null;
function preMain() {
setPriceStudy(true);
setStudyTitle("PointsChannel");
setCursorLabelName("Short", 0);
setCursorLabelName("MA", 1);
setCursorLabelName("Long", 2);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarFgColor(Color.black, 1);
setDefaultBarFgColor(Color.lime, 2);
setPlotType(PLOTTYPE_LINE,0);
setPlotType(PLOTTYPE_LINE,1);
setPlotType(PLOTTYPE_LINE,2);
setDefaultBarThickness(1,0);
setDefaultBarThickness(1,1);
setDefaultBarThickness(1,2);
checkVersion(1,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/basicMA&Channel.efs"); //Comment this line out if modifying the code
var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(1); //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("HL/2"); //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.SIMPLE"); //Edit this value to set a new default
var fp5 = new FunctionParameter("Value", FunctionParameter.STRING);
fp5.setName("Value");
fp5.addOption("Points");
fp5.addOption("Percent");
fp5.setDefault("Points");
var fp6 = new FunctionParameter("Points", FunctionParameter.NUMBER);
fp6.setName("Points");
fp6.setLowerLimit(-2);
fp6.setDefault(.5);
var fp7 = new FunctionParameter("RangeLength", FunctionParameter.NUMBER);
fp7.setLowerLimit(1);
fp7.setDefault(3); //Edit this value to set a new default
}
function main(Length,Offset,Source,Type,Value,Points,RangeL ength) {
if (vMA == null) vMA = new MAStudy(Length, Offset, Source, eval(Type));
var PointsEFS = efsExternal("maofhlrange.efs", RangeLength);
/*****************************************
Insert your code following this text block
Use vMA.getValue(MAStudy.MA) for your code
******************************************/
if(Value=="Points"){
var vUpper = vMA.getValue(MAStudy.MA)+PointsEFS.getValue(-1);
var vLower = vMA.getValue(MAStudy.MA)-PointsEFS.getValue(-1);
}
else if(Value == "Percent"){
var vUpper = vMA.getValue(MAStudy.MA)*(1+(PointsEFS.getValue(-1)/100));
var vLower = vMA.getValue(MAStudy.MA)*(1-(PointsEFS.getValue(-0)/100));
}
return new Array (vUpper,vMA.getValue(MAStudy.MA),vLower);
}
Two questions...
1. Is it possible to add a round-up and round-down element into the code?
For example (using the E-mini market), if the upper channel reads 871.92 can the EFS round up to the nearest .25 increment and read 872.00?
Same thing for the lower channel but rounded down i.e., 871.92 would read 871.75
----------------------------------------------
2. Along with the above rounding is it possible to also add a preset increase to the upper channel and a preset decrease to the lower channel?
Example, if the upper channel is supposed to read 872.00 could there be a place in the code I could adjust an "Add .25 or .75" so the display would read 872.25 or 872.75, respectively?
Same for the lower channel except subtracting the preset amount.
In volatile markets this preset could be ratcheted up.
------------------------------------------------
/************************************************** *******
Alexis C. Montenegro © July 2003
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
************************************************** ********/
var vMA = null;
vUpper = null;
vLower = null;
function preMain() {
setPriceStudy(true);
setStudyTitle("PointsChannel");
setCursorLabelName("Short", 0);
setCursorLabelName("MA", 1);
setCursorLabelName("Long", 2);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarFgColor(Color.black, 1);
setDefaultBarFgColor(Color.lime, 2);
setPlotType(PLOTTYPE_LINE,0);
setPlotType(PLOTTYPE_LINE,1);
setPlotType(PLOTTYPE_LINE,2);
setDefaultBarThickness(1,0);
setDefaultBarThickness(1,1);
setDefaultBarThickness(1,2);
checkVersion(1,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/basicMA&Channel.efs"); //Comment this line out if modifying the code
var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(1); //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("HL/2"); //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.SIMPLE"); //Edit this value to set a new default
var fp5 = new FunctionParameter("Value", FunctionParameter.STRING);
fp5.setName("Value");
fp5.addOption("Points");
fp5.addOption("Percent");
fp5.setDefault("Points");
var fp6 = new FunctionParameter("Points", FunctionParameter.NUMBER);
fp6.setName("Points");
fp6.setLowerLimit(-2);
fp6.setDefault(.5);
var fp7 = new FunctionParameter("RangeLength", FunctionParameter.NUMBER);
fp7.setLowerLimit(1);
fp7.setDefault(3); //Edit this value to set a new default
}
function main(Length,Offset,Source,Type,Value,Points,RangeL ength) {
if (vMA == null) vMA = new MAStudy(Length, Offset, Source, eval(Type));
var PointsEFS = efsExternal("maofhlrange.efs", RangeLength);
/*****************************************
Insert your code following this text block
Use vMA.getValue(MAStudy.MA) for your code
******************************************/
if(Value=="Points"){
var vUpper = vMA.getValue(MAStudy.MA)+PointsEFS.getValue(-1);
var vLower = vMA.getValue(MAStudy.MA)-PointsEFS.getValue(-1);
}
else if(Value == "Percent"){
var vUpper = vMA.getValue(MAStudy.MA)*(1+(PointsEFS.getValue(-1)/100));
var vLower = vMA.getValue(MAStudy.MA)*(1-(PointsEFS.getValue(-0)/100));
}
return new Array (vUpper,vMA.getValue(MAStudy.MA),vLower);
}
Comment