//+------------------------------------------------------------------+
//|                                                    Candle_v1.mq4 |
//|                                             Copyright © 2007,Iva |
//|                                              _madeleine_@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007,Iva"
#property link "_madeleine_@mail.ru"
string str="Candle_v1.mq4";
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 White
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Green
#property indicator_level1 0
#property indicator_levelcolor Yellow
//---- input parameters
double MomPeriod=0;
extern bool comment=true;
extern bool BearShadow=true;
extern bool BullShadow=true;
extern bool Body=true;
extern bool Candle=true;
//---- buffers
double MomBuffer[];
double Mom1Buffer[];
double Mom0Buffer[];
double Mom01Buffer[];
double s1;
double s2;
double s3;
double s4;
double s5;
double s6;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  int i=Bars;
  
s1=Open[0]-Close[0];//тип тела свечи
//бычье тело свечи
if (s1<0){
s2=High[0]-Close[0];//размер верхней тени
s3=Open[0]-Low[0];//размер нижней тени
s4=(Close[0]-Open[0]);//размер тела свечи
s5=s4/2;//половина тела свечи
s6=s2+s3;//сумма верхней и нижней теней
}
//медвежье тело свечи
if (s1>0){
s2=High[0]-Open[0];//размер верхней тени
s3=Close[0]-Low[0];//размер нижней тени
s4=(Open[0]-Close[0]);//размер тела свечи
s5=s4/2;//половина тела свечи
s6=s2+s3;//сумма верхней и нижней теней
}
if (comment){
 Comment("верхняя тень: ",s2,"\n","нижняя тень: ",s3,"\n","сумма теней: ",s6,"\n","тело: ",s4,"\n","свеча: ",High[0]-Low[0],"\n","50% теней: ",s6/2,"\n","50% тела: ",s5,"\n","50% свечи: ",(High[0]-Low[0])/2,"\n");
 }
//---- indicator line
if (BearShadow){
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,MomBuffer);
   SetIndexLabel(0,"Bear Shadow");}
if (BullShadow){   
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Mom1Buffer);
   SetIndexLabel(1,"Bull Shadow");}
if (Body){   
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,Mom0Buffer);
   SetIndexLabel(2,"Body");}
if (Candle){   
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,Mom01Buffer);
   SetIndexLabel(3,"Candle");}
//---- name for DataWindow and indicator subwindow label

//----
   SetIndexDrawBegin(0,MomPeriod);
//----

   return(0);
  }
//+------------------------------------------------------------------+
//| Momentum                                                         |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
//----
   if(Bars<=MomPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=MomPeriod;i++) MomBuffer[Bars-i]=0.0;
      for(i=1;i<=MomPeriod;i++) Mom1Buffer[Bars-i]=0.0;
      for(i=1;i<=MomPeriod;i++) Mom0Buffer[Bars-i]=0.0;
      for(i=1;i<=MomPeriod;i++) Mom01Buffer[Bars-i]=0.0;
//----
   i=Bars-MomPeriod-1;
   if(counted_bars>=MomPeriod) i=Bars-counted_bars-1;
   while(i>=0)
     {
      
      if (s1<0){
      MomBuffer[i]=Open[i]-Low[i];
      Mom1Buffer[i]=High[i]-Close[i];
      Mom0Buffer[i]=Close[i]-Open[i];
      Mom01Buffer[i]=High[i]-Low[i];
      }else{
      MomBuffer[i]=Close[i]-Low[i];
      Mom1Buffer[i]=High[i]-Open[i];
      Mom0Buffer[i]=Close[i]-Open[i];
      Mom01Buffer[i]=Low[i]-High[i];   
     }
      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+