Hello,
i just set up a code for two exponential moving averages by using loop
function. I want to find out where these two EMA´s (15 and 150 days of
length) intersect:
ExpLag150[0]=Close[0];
ExpLag15[0]=Close[0];
for( i = 1; i < BarCount; i++ )
{ ExpLag150[i]=ExpLag150[i-1]+(Close[i]-ExpLag150[i-1])/150;
ExpLag15[i]=ExpLag15[i-1]+(Close[i]-ExpLag15[i-1])/15;
}
Plot(ExpLag150, "My expon. Lag 150", colorGreen, styleLine);
Plot(ExpLag15, "My expon. Lag 15", colorRed, styleLine);
Plot (Close, "Bar Chart", colorBlue, styleBar);
But when I scroll thru the chart the intersecting points change place
as if AB calculated the two expon. MA´s with each new bar appearing on
the screen anew.
When I use regular MA´s (by using the array-based MA function thru AFL
command), this doesn´t happen - the intersecting point stay always at
the same spot?
Why is that and how can I get rid of this?
Incidentally, i was told that AB retrieves differeing values from an
array-based expon. MA and a loop-based MA as i used it above. This is
why I used the loops...
Thanks many times for clarifying this to a rookie!
Markus