You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I got wrong result from "Moving Averages" indicator in some case. (It was happened after recovery from network trouble)
I checked the code of indicator, and I found strange part.
---- Original start -----
void sma()
{
double sum=0;
int i,pos=Bars-ExtCountedBars-1;
//---- initial accumulation
if(pos<MA_Period) pos=MA_Period;
for(i=1;i<MA_Period;i++,pos--)
sum+=Close[pos];
//---- main calculation loop
while(pos>=0)
{
sum+=Close[pos];
ExtMapBuffer[pos]=sum/MA_Period;
sum-=Close[pos+MA_Period-1];
pos--;
}
------ Original End-----
Bolded part should be below, I think.
How do you think?
if(ExtCountedBars<MA_Period) pos=MA_Period;
else pos+= MA_Period;
for(i=1;i<MA_Period;i++,pos--)
sum+=Close[pos];
Kiriri