MQL4 - automated forex trading   /  

Code Base

Read Financial Magazines in MetaTrader 4 and MetaTrader 5!

Code Base  Indicators  Renko Charts To post a new code, please log in or register

Download MetaTrader 5 and visit MQL5.community Code Base
and Trade on the Go!
and Trade on the Go!
Couldn't find the right code? Order it in the Jobs section

This library is for
MetaTrader 4
Download MT 4 - 455 Kb

and Trade on the Go!

and Trade on the Go!

Name:
Renko Charts [ cn ]
Author: Collector (2006.10.16 12:23)
Downloaded: 27860
Download:
 RENKO_2.mq4 (8.5 Kb) View

The Renko charting method is thought to have acquired its name from "renga" which is the Japanese word for bricks. Renko charts are similar to Three Line Break charts except that in a Renko chart, a line (or "brick" as they're called) is drawn in the direction of the prior move only if prices move by a minimum amount (i.e., the box size). The bricks are always equal in size. For example, in a 5-unit Renko chart, a 20-point rally is displayed as four, 5-unit tall Renko bricks.

Renko charts were first brought to the United States by Steven Nison when he published his book, Beyond Candlesticks.

Basic trend reversals are signaled with the emergence of a new red or blue brick. A new blue brick indicates the beginning of a new up-trend. A new red brick indicates the beginning of a new down-trend. Since the Renko chart is a trend following technique, there are times when Renko charts produce whipsaws, giving signals near the end of short-lived trends. However, the expectation with a trend following technique is that it allows you to ride the major portion of significant trends.

Since a Renko chart isolates the underlying price trend by filtering out the minor price changes, Renko charts can also be very helpful when determining support and resistance levels.

Parameters

Porog - box size






10 comments  To post a new comment, please log in or register

dear forum

i am interested in using renko indicator. but all the indicators which are available here when used open a subchart and not the main chart. so, various other indis like a simple MA cant be attached to it. the moment you attach it, it gets attached to the main chart!

what is the solution? OR is there any renko indicator which opens as main chart?

also, on various portals, e.g. stockcharts.com the renko option is given with ATR settings to determin the brick size. is there any indicator available here which has the same function?

thks in advance

 rahul 

20.03.2013 19:26 rv2810
why cant we attach different indicators to this chart? also, when renko indi is attached, it gives a sub chart and not the main chart! how to get the renko on the main chart?
20.03.2013 18:37 rv2810

The Renko-implementation here suffers the lack of choosing the datasource.

Reasons:

  • The original renko implementation just draws bricks according to the Close()-Bar.
  • This is a bit misleading and leads to stopouts because the stop will occur on the respective High() or Low().

This implementation below allows the choosing of different datasources in addition to the Close()-Bar. The datasource is configurable as an input parameter which defaults to "3" (Close).

The value range of the parameter is: 0=Open 1=High 2=Low 3=Close 4=HL

HL means that High() is used when drawing an UP-Brick and Low() is used when drawing a DOWN-Brick. This is the most useful parameter because it takes care of up- and downpeaks when drawing bricks.


//+------------------------------------------------------------------+
//|                                                    RENKO-2.1.mq4 |
//|                           Copyright � 2005, ����������� �������� |
//|                                   http://www.traderstools.h15.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright � 2005, ����������� ��������"
#property link      "http://www.traderstools.h15.ru"
//----
#property indicator_separate_window
#property indicator_buffers 4
//
// Datasource-Parameters
#define DS_PAR_NULL -1
#define DS_PAR_HIGH 1
#define DS_PAR_LOW 0
//
//---- input parameters
extern string sDatasource="0=Open 1=High 2=Low 3=Close 4=HL";
extern int   iDatasource=3;
extern int   Porog = 50;
extern color ColorOfFon = White;
extern color Color1 = Blue;
extern color Color2 = Red;
//---- buffers
double Lab[];
double HU[];
double HD[];
double Fon[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(4);
   IndicatorShortName("RENKO(" + Porog + "pt, " + DataSourceDesc() + ")");
//---- indicators
   SetIndexStyle(0, DRAW_LINE,EMPTY, 0, ColorOfFon);
   SetIndexBuffer(0, Lab);
   SetIndexLabel(0, "RENKO");
   SetIndexEmptyValue(0,0);
   SetIndexStyle(1, DRAW_HISTOGRAM, EMPTY, 8, Color1);
   SetIndexBuffer(1, HU);
   SetIndexLabel(1, NULL);
   SetIndexEmptyValue(1,0);
   SetIndexStyle(2, DRAW_HISTOGRAM,EMPTY, 8, Color2);
   SetIndexBuffer(2, HD);
   SetIndexLabel(2, NULL);
   SetIndexEmptyValue(2,0);
   SetIndexStyle(3, DRAW_HISTOGRAM,EMPTY, 8, ColorOfFon);
   SetIndexBuffer(3, Fon);
   SetIndexLabel(3, NULL);
   SetIndexEmptyValue(3, 0);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("RENKO-" + Porog);
   return(0);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i, ii, j, RenkoBuffShift = 0;
   double RenkoBuff[];
   double RenkoBuff2[];
   //----
   ArrayResize(RenkoBuff, Bars);
   ArrayResize(RenkoBuff2, Bars);
   RenkoBuff[RenkoBuffShift] = DataSource(DS_PAR_HIGH, Bars-1);
   //----
   double pp=Porog*Point;
   for(i = Bars - 2; i >= 0; i--) {
      if(RenkoBuffShift > ArraySize(RenkoBuff) - 100) {
          ArrayCopy(RenkoBuff2, RenkoBuff);
          ArrayResize(RenkoBuff, ArraySize(RenkoBuff) + Bars);
          ArrayCopy(RenkoBuff, RenkoBuff2, 0, 0, RenkoBuffShift + 1);
          ArrayResize(RenkoBuff2, ArraySize(RenkoBuff2) + Bars);
      }
      //----
      if(RenkoBuffShift == 0) {
          while(DataSource(DS_PAR_HIGH, i) > RenkoBuff[RenkoBuffShift] + pp) {
             RenkoBuffShift++;
             RenkoBuff[RenkoBuffShift] = RenkoBuff[RenkoBuffShift-1] + pp;
          }
          //----
          while(DataSource(DS_PAR_LOW, i)<RenkoBuff[RenkoBuffShift]-pp) {
             RenkoBuffShift++;
             RenkoBuff[RenkoBuffShift]=RenkoBuff[RenkoBuffShift-1]-pp;
          } 
      }
      //----       
      if(RenkoBuff[RenkoBuffShift] > RenkoBuff[RenkoBuffShift-1]) {
          if(DataSource(DS_PAR_HIGH, i) > RenkoBuff[RenkoBuffShift] + pp) { 
              while(DataSource(DS_PAR_HIGH, i) > RenkoBuff[RenkoBuffShift] + pp) {
                  RenkoBuffShift++;
                  RenkoBuff[RenkoBuffShift] = RenkoBuff[RenkoBuffShift-1] + pp;
              }
          }   
          if(DataSource(DS_PAR_LOW, i) < RenkoBuff[RenkoBuffShift] - 2*pp) {
              RenkoBuffShift++;
              RenkoBuff[RenkoBuffShift] = RenkoBuff[RenkoBuffShift-1] - 2*pp;  
              while(DataSource(DS_PAR_LOW, i) < RenkoBuff[RenkoBuffShift] - pp) {
                  RenkoBuffShift++;
                  RenkoBuff[RenkoBuffShift]=RenkoBuff[RenkoBuffShift-1]-pp;
              }
          }   
      }
      //----      
      if(RenkoBuff[RenkoBuffShift] < RenkoBuff[RenkoBuffShift-1]) {
          if(DataSource(DS_PAR_LOW, i) < RenkoBuff[RenkoBuffShift] - pp) {
              while(DataSource(DS_PAR_LOW, i) < RenkoBuff[RenkoBuffShift] - pp) {
                  RenkoBuffShift++;
                  RenkoBuff[RenkoBuffShift] = RenkoBuff[RenkoBuffShift-1] - pp;
              }
          }
          if(DataSource(DS_PAR_HIGH, i) > RenkoBuff[RenkoBuffShift] + 2*pp) {
              RenkoBuffShift++;
              RenkoBuff[RenkoBuffShift] = RenkoBuff[RenkoBuffShift-1] + 2*pp;  
              while(DataSource(DS_PAR_HIGH, i) > RenkoBuff[RenkoBuffShift] + pp) {
                  RenkoBuffShift++;
                  RenkoBuff[RenkoBuffShift] = RenkoBuff[RenkoBuffShift-1] + pp;
              }
          }   
      }            
   }
//---- ������ ������
   ObjectCreate("RENKO-" + Porog, OBJ_RECTANGLE, WindowFind("RENKO(" + Porog + "pt)"), 
                0, 0, 0, 0);
   ObjectSet("RENKO-" + Porog, OBJPROP_TIME2, Time[0]);
   ObjectSet("RENKO-" + Porog, OBJPROP_PRICE2, High[ArrayMaximum(RenkoBuff)]*2);
   ObjectSet("RENKO-" + Porog, OBJPROP_COLOR, ColorOfFon);
   for(i = 0; i < Bars; i++) {
       Lab[i] = 0;
       HU[i] = 0;
       HD[i] = 0;
       Fon[i] = 0;
   }
   if(RenkoBuffShift > Bars - 100) {
       for(i = 0; i <= Bars - 100; i++)
           RenkoBuff[i] = RenkoBuff[i+RenkoBuffShift-(Bars-100)];
       RenkoBuffShift = Bars - 100;
   }  

   for(i = 1; i <= RenkoBuffShift; i++)
       Lab[RenkoBuffShift-i] = RenkoBuff[i];

   for(i = 1; i <= RenkoBuffShift; i++) {
       if(RenkoBuff[i] > RenkoBuff[i-1] && RenkoBuff[i-1] > RenkoBuff[i-2]) {
         HU[RenkoBuffShift-i] = RenkoBuff[i];
         HD[RenkoBuffShift-i] = RenkoBuff[i-1];
         Fon[RenkoBuffShift-i] = RenkoBuff[i-1];
       }
       if(RenkoBuff[i] > RenkoBuff[i-1] && RenkoBuff[i-1] < RenkoBuff[i-2]) {
         HU[RenkoBuffShift-i] = RenkoBuff[i];
         HD[RenkoBuffShift-i] = RenkoBuff[i] - pp;
         Fon[RenkoBuffShift-i] = RenkoBuff[i] - pp;
       }  
       if(RenkoBuff[i] < RenkoBuff[i-1] && RenkoBuff[i-1] < RenkoBuff[i-2]) {
         HD[RenkoBuffShift-i] = RenkoBuff[i-1];
         HU[RenkoBuffShift-i] = RenkoBuff[i];
         Fon[RenkoBuffShift-i] = RenkoBuff[i];
       }   
       if(RenkoBuff[i] < RenkoBuff[i-1] && RenkoBuff[i-1] > RenkoBuff[i-2]) {
         HD[RenkoBuffShift-i] = RenkoBuff[i] + pp;
         HU[RenkoBuffShift-i] = RenkoBuff[i];
         Fon[RenkoBuffShift-i] = RenkoBuff[i];
       }     
   }   
   return(0);
  }
//+------------------------------------------------------------------+

double DataSource(int dir, int i) {
   switch (iDatasource) {
      case 0:
         return(Open[i]);
         break;
      case 1:
         return(High[i]);
         break;
      case 2:
         return(Low[i]);
         break;
      case 3:
         return(Close[i]);
         break;
      case 4:
         switch (dir) {
          case DS_PAR_HIGH:
            return(High[i]);
            break;
          case DS_PAR_LOW:
            return(Low[i]);
            break;
         }
   }
}

string DataSourceDesc() {
   switch (iDatasource) {
      case 0:
         return("O");
         break;
      case 1:
         return("H");
         break;
      case 2:
         return("L");
         break;
      case 3:
         return("C");
         break;
      case 4:
         return("HL");
         break;
   }
}
01.12.2012 02:44 NoTomatoes
can i get 10 seconds time frame ?
12.06.2010 00:16 McGene4xPro
funyoo wrote:

Thanks for sharing this indicator. Here is the Renko expert advisor.


Can anyone advise on how to reference this using iCustom


I get this error written to the journal
RENKO_2 EURUSD,H1: unknown subwindow number -1 for ObjectCreate function

I'm using this as the reference
iCustom(NULL, 0, "RENKO_2",20,1,1);

20.08.2009 03:28 neta1o

Thanks for sharing this indicator. Here is the Renko expert advisor.


25.01.2009 00:23 funyoo
freebooter wrote:
Hi Collector, one thing I'd b very interested to see would be the possibility to draw Range Bars. Sometimes referred to as Constant Range Bars or Nicolellis range bars they basically ignore the time element and will form a new bar after a specific range has been covered low to high or high to low. Below is a brief description of what I mean:

Range Bars are price-driven bars, with each bar having a required minimum high-low range. Once the range requirement is reached, the first tick to break outside that range will begin a new bar (and become the opening price of that new bar). A 0. 75 Range Bar chart of ES with volume can be seen below. Notice that the height/range of each bar is 0.75. Also notice that each bar opens at a price outside of the high/low range of the previous bar. And last, notice that each bar closes at either it's high or it's low. These are the three rules of range bars.

  • Each bar must have a high/low range equal to the range specified. The high/low range of a bar can exceed the range specified in certain situations (gaps) but can never be less that the range specified.
  • Each bar must open outside the high/low range of the previous bar.
  • Each bar must close at either it's high or it's low.

With Range Bars (and Change Bars), new bars will only be formed when price is moving. When prices gets stuck in a tight range for an extended period of time, horizontal screen real estate will not be wasted with multiple bars that would have formed had the periodicity been volume or time driven.

For Range Bars, the high/low range of each bar is essentially held constant, while time and volume are variables.

this is a pretty intresting chart , is there some place where I can download if from ?
01.04.2008 00:34 cucubau22
Michal wrote:

I've developed range bar charts for MT4 for one of my clients. It is a script which is similar to the period_converter.mq4 script. 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. Anyone interested in this product can contact me at www.mqlservice.net


I've set up w shop where you can find Constant Range Bars and Renko Bars scripts. They work real time and you can put any indicator on a chart. It works like period converter, therefore if you input a standard MT4 time then probably it should be possible to use these bars in backtesting (but I haven't try this so I am not 100% sure). CBR are here and Renko here.
09.03.2008 18:36 Michal

I've developed range bar charts for MT4 for one of my clients. It is a script which is similar to the period_converter.mq4 script. 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. Anyone interested in this product can contact me at www.mqlservice.net

27.02.2008 10:52 Michal
Hi Collector, one thing I'd b very interested to see would be the possibility to draw Range Bars. Sometimes referred to as Constant Range Bars or Nicolellis range bars they basically ignore the time element and will form a new bar after a specific range has been covered low to high or high to low. Below is a brief description of what I mean:

Range Bars are price-driven bars, with each bar having a required minimum high-low range. Once the range requirement is reached, the first tick to break outside that range will begin a new bar (and become the opening price of that new bar). A 0. 75 Range Bar chart of ES with volume can be seen below. Notice that the height/range of each bar is 0.75. Also notice that each bar opens at a price outside of the high/low range of the previous bar. And last, notice that each bar closes at either it's high or it's low. These are the three rules of range bars.

  • Each bar must have a high/low range equal to the range specified. The high/low range of a bar can exceed the range specified in certain situations (gaps) but can never be less that the range specified.
  • Each bar must open outside the high/low range of the previous bar.
  • Each bar must close at either it's high or it's low.

With Range Bars (and Change Bars), new bars will only be formed when price is moving. When prices gets stuck in a tight range for an extended period of time, horizontal screen real estate will not be wasted with multiple bars that would have formed had the periodicity been volume or time driven.

For Range Bars, the high/low range of each bar is essentially held constant, while time and volume are variables.

06.11.2006 07:13 freebooter