I'm trying to figure out how to find the difference between two moving averages, at different time scales. I'm just playing with a simple MVA indicator. I have this code, but if I try to create out3, it won't run.
-- calculate the value
function Update(period)
if (period >= first) then
out[period] = mathex.avg(instance.source, period - n + 1, period);
out2[period] = mathex.avg(instance.source, period - n2 + 1, period);
-- out3[period] =mathex.avg(instance.source, period - n + 1, period) - mathex.avg(instance.source, period - n2 + 1, period);
end
end
I don't understand why it can plot two nice lines on the screen, but I can't apply a simply subtraction to get the difference between them.
Any help is appreciated. Thanks!