Tick volume histogram in chart window - page 2

 

Here you go, im feeling generous today. No warranty that it will work 100% and i am still not sure if i understand your idea:

With the external parameter you can adjust the percentage of the screen used to draw the indicator.

If you are feeling generous too you can donate something trough paypal @ zzuegg@gmail.com or to your favorite organisation.

//+------------------------------------------------------------------+
//|                                             TickCountOnChart.mq4 |
//|                                                           zzuegg |
//|                                       when-money-makes-money.com |
//+------------------------------------------------------------------+
#property copyright "zzuegg"
#property link      "when-money-makes-money.com"

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_color4 Red
#property indicator_color5 Red
#property indicator_color6 Red
//---- buffers
double count.up[];
double count.do[];
double ups.high[];
double ups.low[];
double dos.high[];
double dos.low[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_NONE);
   SetIndexBuffer(0,count.up);
   SetIndexStyle(1,DRAW_NONE);
   SetIndexBuffer(1,count.do);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexBuffer(2,ups.high);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexBuffer(3,ups.low);
   SetIndexStyle(4,DRAW_HISTOGRAM);
   SetIndexBuffer(4,dos.high);
   SetIndexStyle(5,DRAW_HISTOGRAM);
   SetIndexBuffer(5,dos.low);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
extern double percentageOfScreen=10;
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   static double lastValue=0;
          double currValue=(Ask+Bid)/2;
   static double currTime=0;
   static int c.up=0;
   static int c.do=0;
   if(Time[0]!=currTime) {
      if(currTime==0){
         for(int j=WindowBarsPerChart();j>=0;j--){
            count.up[j]=0;
            count.do[j]=0;
         }
      }
      count.up[0]=0;
      count.do[0]=0;
      c.up=0;
      c.do=0;
      currTime=Time[0];
   }       
   if(currValue!=lastValue){
      if(lastValue!=0){
         if(currValue>lastValue) c.up++;
         if(currValue<lastValue) c.do++;
      }
      lastValue=currValue;
   }
   count.up[0]=c.up;
   count.do[0]=c.do;
   static double price.max;
   static double price.min;
   static double values.max;
   static double subWindow.center;
   static double ratio;
   Print(MathMax(count.up[ArrayMaximum(count.up,WindowBarsPerChart(),0)],count.do[ArrayMaximum(count.do,WindowBarsPerChart(),0)]));
   if(price.max!=WindowPriceMax() || price.min!=WindowPriceMin() || values.max!=MathMax(count.up[ArrayMaximum(count.up,WindowBarsPerChart(),0)],count.do[ArrayMaximum(count.do,WindowBarsPerChart(),0)])){
      //need to rescale the current chart
      price.max=WindowPriceMax();
      price.min=WindowPriceMin();
      subWindow.center=price.min+(price.max-price.min)/100*(percentageOfScreen/2);
      double valueMax=MathMax(count.up[ArrayMaximum(count.up,WindowBarsPerChart(),0)],count.do[ArrayMaximum(count.do,WindowBarsPerChart(),0)]);
      ratio=(price.max-price.min)/100*(percentageOfScreen/2)/valueMax;
      for(int i=WindowBarsPerChart();i>=0;i--){
         ups.high[i]=subWindow.center+(count.up[i]*ratio);
         ups.low[i]=subWindow.center;
         dos.high[i]=subWindow.center;
         dos.low[i]=subWindow.center-(count.do[i]*ratio);
      }
   }
         ups.high[0]=subWindow.center+(count.up[0]*ratio);
         ups.low[0]=subWindow.center;
         dos.high[0]=subWindow.center;
         dos.low[0]=subWindow.center-(count.do[0]*ratio);   
   Comment("CoS:"+subWindow.center+" ,MaxValue="+values.max);
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
zzuegg:

Here you go, im feeling generous today. No warranty that it will work 100% and i am still not sure if i understand your idea:

With the external parameter you can adjust the percentage of the screen used to draw the indicator.

If you are feeling generous too you can donate something trough paypal @ zzuegg@gmail.com or to your favorite organisation.

Hi zzuegg, I cant thankyou enough for your help, I will compile it and give you some feedback, hopefully it will be something I can work with.
 
there is still a Print() statement in the code which floods the Expert Tap, you can delete that line
 
I was only kidding . . . . it's not finished, it doesn't do the re-scaling.
 

Made a small mod, the TickCount bars were being scaled to the same size regardless of TickCount . . . just testing now.

Looks better . . .

Files:
 
Huch, i have reread most of the thread, Raptor's solution might be more what you are searching for
 
RaptorUK:

Made a small mod, the TickCount bars were being scaled to the same size regardless of TickCount . . . just testing now.

Looks better . . .


Thankyou so much Raptor and zzuegg for all your help, just about to try it out.