Tick Charts or Constant Range Bars - page 2

 
thanks again, i copied and pasted the code you provided, but it doesn't seem to attach to the chart for some reason, what could it be?
 
hmmm.. I mistyped

extren int SmoothType=0;
right be such

extern int SmoothType=0;

try again, please.
 
yup that worked, Thanks!
 
I too am looking for a range bar indicator. Range bars are not dependent on time but on depth of price action. Excellent for showing range and TREND

eg. if the user sets the range bar to be 10, then after every 10 pip, a new candlestick bar is created. The length of time taken to create the bar doesnt matter. So if eurusd moved up from 100, to 110 in 1minute, then one candlestick bar would be completed. If eurusd moved up from 100, to 110 in 5 hours, then again only one candlestick bar would be completed.

Explanation of range bars here:
Range Bars

Thanks
Would be very grateful if someone could code this indicator
 

Babelfish translation of Ticks.mq4

//+------------------------------------------------------------------+
//|                                                        Ticks.mq4 |
//|                                                       MetaQuotes |
//|                    http://www.alpari-idc.ru/ru/experts/articles/ |
//+------------------------------------------------------------------+
#property copyright "Rosh"
#property link      "http://www.alpari-idc.ru/ru/experts/articles/"
 
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Navy
//---- buffers
extern int MaxDrawTicks=500;
double ExtMapBuffer1[];
int myBars;
int tickCounter;
int delimeterCounter;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   Print("Reduce ticks to Zero");
   for (int i=Bars-1;i>=0;i--) ExtMapBuffer1[i]=0.0;
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Let us move the massif                                               |
//+------------------------------------------------------------------+
void SetDelimeter()
  {
//----
   string delimeterDate=TimeToStr(Time[0]);
   if (myBars!=0)
      {
      Print("Place the seperator");      
      int handle=WindowFind("Ticks");
      if(!ObjectCreate(delimeterDate,OBJ_VLINE,handle,Time[0],0))
         {
         Alert("Failed attemp at creation of seperator in the window ",
         handle," On the time ",TimeToStr(CurTime()));
         Print("Error No",GetLastError(),", The name of the seperator ",delimeterDate);
         }
      else 
         {
         ObjectSet(delimeterDate,OBJPROP_COLOR,DarkGreen);
         ObjectSet(delimeterDate,OBJPROP_STYLE,STYLE_DASHDOT);
         ObjectsRedraw();
         }
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Let us move the massif                                                  |
//+------------------------------------------------------------------+
void ShiftArray()
  {
//----
   int V_lines;
   string delimeterName;
   datetime firstTime;
   int BarFirstTime;
   
   if (tickCounter>2*MaxDrawTicks)
      {
      for (int i=tickCounter;i>=MaxDrawTicks;i--) ExtMapBuffer1[i]=0.0;
      tickCounter=MaxDrawTicks;
      }
   for(int cnt=tickCounter;cnt>0;cnt--)
      {
      ExtMapBuffer1[cnt]=ExtMapBuffer1[cnt-1];
      }
   V_lines=ObjectsTotal();
   for (int z=0;z<V_lines;z++)
      {
      delimeterName=ObjectName(z); 
      if (ObjectFind(delimeterName)!=-1)
         {
         if (ObjectType(delimeterName)==OBJ_VLINE) 
            {
            firstTime=ObjectGet(delimeterName,OBJPROP_TIME1);
            BarFirstTime=iBarShift(NULL,0,firstTime);
            firstTime=Time[BarFirstTime+1];
            ObjectSet(delimeterName,OBJPROP_TIME1,firstTime); 
            }
         }       
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|The sign of the new bar                                              |
//+------------------------------------------------------------------+
bool isNewBar()
  {
//----
   bool res=false;
   if (myBars!=Bars)
      {
      res=true;
      myBars=Bars;
      }   
//----
   return(res);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   if (isNewBar())
      {
      // To establish the seperator
      tickCounter++;
      SetDelimeter();
      ExtMapBuffer1[0]=Bid;      
      }
   else
      
      {
      tickCounter++;
      ShiftArray();
      ExtMapBuffer1[0]=Bid;      
      }      
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
jb1975:
I too am looking for a range bar indicator. Range bars are not dependent on time but on depth of price action. Excellent for showing range and TREND


Something I like to see as you have mentioned here is LinearPriceBar.mq4

This indicator is quite simple but very powerful to see sentiment without up and down of the chart which is typically noise.

//+------------------------------------------------------------------+
//|                                             Linear Price Bar.mq4 |
//|                                      Copyright © 2006, Keris2112 |
//|                                                             none |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Keris2112"
#property link      "none"
 
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Red
 
 
//---- buffers
 
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_HISTOGRAM,EMPTY,3);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_HISTOGRAM,EMPTY,3);
   SetIndexBuffer(3,ExtMapBuffer4);
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
      
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int i;
   int UpDays, DownDays, NeutralDays;
   double BarH, BarL, BarC;
 
//---- 
   for(i=0; i<Bars; i++)
      {
      BarH = High[i]-Open[i];
      BarL = Low[i]-Open[i];
      BarC = Close[i]-Open[i];
      if(BarC>0) UpDays += 1;
         else if(BarC<0) DownDays +=1;
         else if(BarC==0) NeutralDays +=1;
 
      
      
      ExtMapBuffer1[i] = BarH;
      ExtMapBuffer2[i] = BarL;
//      SortBuffer1[i] = BarH;
//      SortBuffer2[i] = BarL;
      if(Close[i]>Open[i])
         {
         ExtMapBuffer3[i] = BarC;
         ExtMapBuffer4[i] = 0;
         }
         else
         {
         ExtMapBuffer3[i] = 0;
         ExtMapBuffer4[i] = BarC;
         }
         
 
      }
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
jb1975:
I too am looking for a range bar indicator. Range bars are not dependent on time but on depth of price action. Excellent for showing range and TREND

eg. if the user sets the range bar to be 10, then after every 10 pip, a new candlestick bar is created. The length of time taken to create the bar doesnt matter. So if eurusd moved up from 100, to 110 in 1minute, then one candlestick bar would be completed. If eurusd moved up from 100, to 110 in 5 hours, then again only one candlestick bar would be completed.

Explanation of range bars here:
Range Bars

Thanks
Would be very grateful if someone could code this indicator

I've developed range bar charts for MT4 for one of my clients. It is a script which is similar to period_converter. It creates a new chart which can be opened in the offline mode. You can drop any indicator on it and trade on it too. It is updated in a real time and for history it models ticks based on 1M bars. Anywone interested in this product can contact me at www.mqlservice.net
 
 

Looking for Free Reliable Range Indicators ?

See here - Constant Range Detector. Scroll down to - Constant Range Indicators and Range Information

Reason: