Good Morning,
The following codes differ by the getSeries and getValues commands. I was under the impression the getValues command would return values for the longer period moving average on each tick of the shorter period on the chart. I have tested this and find both codes return the same results. Is there an error in the code?
Best Regards,
Alan
/************************************************** *******
Code1 test of getSeries
************************************************** ********/
function preMain() {
setPriceStudy(false);
setStudyTitle("Code1");
setCursorLabelName("Code1",0);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarThickness(2, 0);
setPlotType(PLOTTYPE_LINE, 0);
Symbol1 = "YM U5";
Interval1 = "80T";
}
function main() {
var vSymbol1 = Symbol1+","+Interval1;
xMA1 = offsetSeries(eval(sma)(5,eval(high)(sym(vSymbol1)) ),0);
return getSeries(xMA1);
}
/************************************************** *******
Code2 test of getSeries
************************************************** ********/
function preMain() {
setPriceStudy(false);
setStudyTitle("Code2");
setCursorLabelName("Code2",0);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarThickness(2, 0);
setPlotType(PLOTTYPE_LINE, 0);
Symbol1 = "YM U5";
Interval1 = "80T";
}
function main() {
var vSymbol1 = Symbol1+","+Interval1;
xMA1 = offsetSeries(eval(sma)(5,eval(high)(sym(vSymbol1)) ),0);
return xMA1.getValue(0);
}
The following codes differ by the getSeries and getValues commands. I was under the impression the getValues command would return values for the longer period moving average on each tick of the shorter period on the chart. I have tested this and find both codes return the same results. Is there an error in the code?
Best Regards,
Alan
/************************************************** *******
Code1 test of getSeries
************************************************** ********/
function preMain() {
setPriceStudy(false);
setStudyTitle("Code1");
setCursorLabelName("Code1",0);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarThickness(2, 0);
setPlotType(PLOTTYPE_LINE, 0);
Symbol1 = "YM U5";
Interval1 = "80T";
}
function main() {
var vSymbol1 = Symbol1+","+Interval1;
xMA1 = offsetSeries(eval(sma)(5,eval(high)(sym(vSymbol1)) ),0);
return getSeries(xMA1);
}
/************************************************** *******
Code2 test of getSeries
************************************************** ********/
function preMain() {
setPriceStudy(false);
setStudyTitle("Code2");
setCursorLabelName("Code2",0);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarThickness(2, 0);
setPlotType(PLOTTYPE_LINE, 0);
Symbol1 = "YM U5";
Interval1 = "80T";
}
function main() {
var vSymbol1 = Symbol1+","+Interval1;
xMA1 = offsetSeries(eval(sma)(5,eval(high)(sym(vSymbol1)) ),0);
return xMA1.getValue(0);
}
Comment