//+------------------------------------------------------------------+
//|                                                    at_Itp(t).mq4 |
//|                      Copyright � 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright � 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red

extern int hours=4;
extern int s=10;
extern int cb=1000;

double ci[];
//================================================
int init()
  {
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ci);
   return(0);
  }
//================================================
int start()
  {
//   int    counted_bars=IndicatorCounted();
int i,x,m,pt,aa,bb,cc;
//----------------------------
pt=hours*60/Period();
//-----------------------
for (m=0; m<=s; m++)
{
i=0;
while (i<=cb)
{
if (m==0) { ci[cb+pt]=Close[cb+pt]; ci[i]=Close[i]; ci[cb+2*pt]=Close[cb+2*pt];}
if (m!=0 & m!=s) { ci[i+pt]=0.5*(ci[i]+ci[i+2*pt]); ci[0]=0.5*(ci[0]+ci[pt]);  ci[cb+2*pt]=0.5*(ci[cb+2*pt]+ci[cb+pt]); } 
if (m==s) { aa=i; bb=i+pt; cc=i+2*pt;
for (x=i; x<=i+pt-1; x++)  {ci[x]=ci[aa]*((x-bb)*(x-cc))/((aa-bb)*(aa-cc))+ci[bb]*((x-aa)*(x-cc))/((bb-aa)*(bb-cc))+ci[cc]*((x-aa)*(x-bb))/((cc-aa)*(cc-bb));}
}

i=i+pt;
}
}
   return(0);
  }
//+------------------------------------------------------------------+