//+------------------------------------------------------------------+
//|                                                  HPSpeed-T01.mq4 |
//|                          Copyright © 2008, HomeSoft-Tartan Corp. |
//|                                          http://www.fxexperts.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, HomeSoft-Tartan Corp."
#property link      "http://www.fxexperts.ru"
#define pi 3.141592653589793238462643383279502884197169399375105820974944592
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_width1 1
#property indicator_width2 1

extern int mBar = 1000;
extern int per  = 34;

double SLBuff[],SRBuff[],hpone,hpnul,spb;
int    cnt;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,SLBuff);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(1,SRBuff);
   SetIndexStyle(1,DRAW_LINE);   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   for (cnt=mBar;cnt>=0;cnt--)
    {
        hpone=iCustom(NULL,0,"HP",mBar,per,0,cnt+1);
        hpnul=iCustom(NULL,0,"HP",mBar,per,0,cnt);
        spb=NormalizeDouble(((hpnul-hpone)/Point),Digits);
   if (spb>=0) SLBuff[cnt]=spb;
   if (spb<0)  SRBuff[cnt]=spb;
    }
//----
   string HP=DoubleToStr(iCustom(NULL,0,"HP",mBar,per,0,0),Digits);
   string DISTANCE=DoubleToStr((Close[0]-iCustom(NULL,0,"HP",mBar,per,0,0))/Point,0); 
   if(Close[0]-iCustom(NULL,0,"HP",mBar,per,0,0)>0) color profitcolor=Aqua; else profitcolor=Red;
   comment(0,Aqua,"HP            =  ",HP);
   comment(1,profitcolor,"DISTANCE = ",DISTANCE);
//----
   return(0);
  }
//+------------------------------------------------------------------+

void comment(int n,color c,string s0="",string s1="",string s2="",string s3="",string s4="",string s5="",string s6="",string s7="",string s8="",string s9="",
string s10="",string s11="",string s12="",string s13="",string s14="",string s15="",string s16="",string s17="",string s18="",string s19="")
{
IndicatorShortName("HPSpeed-T01");
int WinNum=WindowFind("HPSpeed-T01");
string r=s0+s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12+s13+s14+s15+s16+s17+s18+s19;
string name="comment_"+n;
int y=15+n*15;
int x=2;
if(ObjectFind(name)<0) ObjectCreate(name,OBJ_LABEL,WinNum,0,0);
ObjectSet(name,OBJPROP_XDISTANCE,x);
ObjectSet(name,OBJPROP_YDISTANCE,y);
ObjectSetText(name,r,8,"",c);
}