//gumgum)))
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 OrangeRed
extern int FTMA=10;
extern int PRICE=1;
extern double rank1=2;
extern double rank2=2;
extern double rank3=2;
extern double shift1=1;
extern double shift2=1;
extern double shift3=1;
double ExtMapBuffer1[];
double PM[1000];
int init()
{
SetIndexStyle(0,DRAW_LINE,0,0);
SetIndexBuffer(0, ExtMapBuffer1);
double sum=0;
for(int h=0;h<=FTMA-1;h++)
{
PM[h]=shift1+MathPow(h/(FTMA-1.),rank1)*(1.-shift1);
PM[h]=(shift2+MathPow(1-(h/(FTMA-1.)),rank2)*(1.-shift2))*PM[h];
if((h/(FTMA-1.))<0.5)
{
PM[h]=(shift3+MathPow((1-(h/(FTMA-1.))*2.).,rank3)*(1.-shift3))*PM[h];
}
else
{
PM[h]=(shift3+MathPow((h/(FTMA-1.))*2.-1.,rank3)*(1.-shift3))*PM[h];
}
sum+=PM[h];
}
double sum1=0;
for(h=0;h<=FTMA-1;h++)
{
PM[h]=PM[h]/sum;
sum1+=PM[h];
}
return(0);
}
int deinit()
{
return(0);
}
int start()
{
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars < 0)
return(-1);
if(counted_bars > 0)
counted_bars--;
limit=Bars - counted_bars;
for(int i=0; i<limit; i++)
{
double sum1=0;
for(int h=0;h<=FTMA-1;h++)
{
if(PRICE<1||PRICE>7)
{
sum1+=Open[i+h]*PM[h];
}
else if(PRICE==1)
{
sum1+=Close[i+h]*PM[h];
}
else if(PRICE==2)
{
sum1+=High[i+h]*PM[h];
}
else if(PRICE==3)
{
sum1+=Low[i+h]*PM[h];
}
else if(PRICE==4)
{
sum1+=((High[i+h]+Low[i+h])/2.)*PM[h];
}
else if(PRICE==5)
{
sum1+=((High[i+h]+Low[i+h]+Open[i+h])/3.)*PM[h];
}
else if(PRICE==6)
{
sum1+=((High[i+h]+Low[i+h]+Close[i+h])/3.)*PM[h];
}
else if(PRICE==7)
{
sum1+=((High[i+h]+Low[i+h]+Close[i+h]+Open[i+h])/4.)*PM[h];
}
}
ExtMapBuffer1[i]=sum1;
}
return(0);
}
Comments