Good Morning,
The attached code is a demonstartion of computing a 1 minute, 3 period, end centered moving average 4 diferent ways. It was applied to a tick chart and produced 4 different results. Could you please explain how each value is calculated?
Best Regards,
Alan
The attached code is a demonstartion of computing a 1 minute, 3 period, end centered moving average 4 diferent ways. It was applied to a tick chart and produced 4 different results. Could you please explain how each value is calculated?
Best Regards,
Alan
PHP Code:
function preMain() {
setStudyTitle("InTest");
setCursorLabelName("MA1", 0);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarStyle(PS_SOLID, 2);
setDefaultBarStyle(PS_SOLID, 3);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarFgColor(Color.blue, 1);
setDefaultBarFgColor(Color.green, 2);
setDefaultBarFgColor(Color.yellow, 3);
setDefaultBarThickness(3, 0);
setDefaultBarThickness(3, 1);
setDefaultBarThickness(3, 2);
setDefaultBarThickness(3, 3);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
setPlotType(PLOTTYPE_LINE, 2);
setPlotType(PLOTTYPE_LINE, 3);
Symbol1 = "$playback";
Interval1 = "1M";
Interval2 = "60S";
}
function main() {
var vSymbol1 = Symbol1+","+Interval1;
pMA1 = offsetSeries(eval(sma)(3,eval(low)(sym(vSymbol1))),0);
var jMA1 = pMA1.getValue(0);
var vSymbol2 = Symbol1+","+Interval2;
pMA2 = offsetSeries(eval(sma)(3,eval(low)(sym(vSymbol2))),0);
var jMA2 = pMA2.getValue(0);
if(getBarStateInterval("1")==BARSTATE_NEWBAR){
var vSymbol3 = Symbol1+","+Interval1;
pMA3 = offsetSeries(eval(sma)(3,eval(low)(sym(vSymbol3))),0);
var jMA3 = pMA3.getValue(0);
var vSymbol4 = Symbol1+","+Interval2;
pMA4 = offsetSeries(eval(sma)(3,eval(low)(sym(vSymbol4))),0);
var jMA4 = pMA4.getValue(0);
}
return new Array (jMA1, jMA2, jMA3, jMA4);
}
Comment