Author: zfs
Miscellaneous
Implements a curve of type %1
1 Views
0 Downloads
0 Favorites
SizeBar
ÿþ//+------------------------------------------------------------------+

//|                                                      SizeBar.mq4 |

//|                                                              zfs |

//|                                                   vasbsm@mail.ru |

//+------------------------------------------------------------------+



#property copyright "zfs"

#property link      "vasbsm@mail.ru"

#property indicator_buffers 1

#property indicator_color1 Maroon

#property indicator_width1 4

#property indicator_separate_window



#property strict



input  int BarsCount = 300;//:>;-2> >B>1@0605<KE 10@>2



double BSize[];



string Indicator_Name;



int init()

  {

   SetIndexStyle(0,DRAW_HISTOGRAM);

   SetIndexBuffer(0,BSize);

   Indicator_Name="SizeBar1.0("+BarsCount+")";     

   IndicatorShortName(Indicator_Name);

   SetIndexLabel(0,Indicator_Name); 

   return(0);

  }



int deinit()

  {

   for (int x=0;x<24;x++){

   ObjectDelete("Cal"+x);}

   return(0);

  }



int start()

  {

   int xx;

   int h[24],nH[24];

   

   int Window=WindowFind(Indicator_Name); 

    

   int counted_bars=IndicatorCounted();



   int limit=BarsCount;

   if(counted_bars>0) limit++;

   double spread=MarketInfo(Symbol(),MODE_SPREAD)*Point;//! 

   double x,y,max,maxmax=0,minmax=9999999999,nak=0;

   for(int i=0; i<limit; i++)

   {

    x=(High[i]-Close[i+1]-spread)/Point;

    y=(Close[i+1]-Low[i]-spread)/Point;

    

    if(x>y)max=x;else max=y;

    if (max<0)max=0;

    BSize[i]=max;

    

    ArrayInitialize(h,0);ArrayInitialize(nH,0);

    for (xx=0;xx<24;xx++){

    if (TimeHour(Time[i])==xx){h[xx]+=BSize[i];nH[xx]++;}

    }

    nak+=BSize[i];

    if (max>maxmax)maxmax=max;

    if (max<minmax)minmax=max;

   }

   nak=nak/BarsCount;

   for (xx=0;x<24;x++){

    if (nH[xx]!=0)h[xx]=h[xx]/nH[xx];

   Label("Cal"+xx,0,10,18+11*xx,DoubleToStr(nH[xx],0),10,FireBrick);   

   }

  Label("Cal",Window,10,18,"MAX="+DoubleToStr(maxmax,0)+" MIN="+DoubleToStr(minmax,0)+" MED="+DoubleToStr(nak,1)+

                           " CUR="+DoubleToStr(BSize[0],0),10,FireBrick);

   return(0);

  }

void Label(string _name,int _window,int _x,int _y,string _text,int _font,color _color)

 {

   ObjectCreate(_name,OBJ_LABEL,_window,0,0);

   ObjectSet(_name,OBJPROP_CORNER,4);

   ObjectSet(_name,OBJPROP_XDISTANCE,_x);

   ObjectSet(_name,OBJPROP_YDISTANCE,_y);

   ObjectSetText(_name,_text,_font,"Arial",_color); 

 }  

Comments