modifying renko like bars for all symbols

 

Hello All, I am leaning mql4 and trying various stuff.

I was trying to modify this indicator(attached similar to renko).It paints colored bars of x pips height ( negative or positive). I was trying to modify it as follows

1. the x pip height ( which I can choose in the setting )different for different TF. I was able to do this.

2. the x pip height to  adjust'/equal/universal' for all symbols no matter how many digits so they all look and are  drawn x pips for all pair charts. Currently the x pip height looks fine/ normal on say audusd but for  usdtry or gbpmxn they look very small ( even though it should be x pips for all ).I tried to use if digits expression and then multiply the boxsizes with  multiplier(mult) to make it normal for the symbols like gbptry or gbpmxn.It doesnot work as intended. Can you please tell me what I am doing wrong ?


extern double BoxSize = 7.0;
extern double BoxSizeH4 = 20.0;
extern double BoxSizeD1= 50.0;
extern double BoxSizeW1= 100.0;
extern double BoxSizeMN1= 200.0;

double mult;


int OnInit()
  {
  
  {
   
   if(Digits() == 5 || Digits() == 3)
     {
      mult = mult*10 ;
     }
   return(INIT_SUCCEEDED);
  
  
  }
  
  if ( Period()==240)
  {
  BoxSize=BoxSizeH4*mult ;
  }
  
  if (  Period()==1440)
  {
  BoxSize=BoxSizeD1*mult ;
  }
  
   if ( Period()==10080)
  {
  BoxSize=BoxSizeW1*mult ;
  }
  
  if (  Period()==43200)
  {
  BoxSize=BoxSizeMN1*mult ;
  }
  
  

when i look at the whole code below .I can see the original coder already included the lines if (Digits == 5 || Digits == 3) digits = NormalizeDouble(10.0 * BoxSize, Digits);....

But the lines ( x pip height ) don't work like same in all symbols , I should not have to modify 2 above if it was working in the first place. Confusing ! How can i fix this .Thank you so much.


//+------------------------------------------------------------------+
//|                                                    Renko nmc.mq4 |
//+------------------------------------------------------------------+

#property indicator_chart_window
//#property strict 
#property indicator_buffers 2
#property indicator_color1 clrYellow
#property indicator_color2 clrRed
#property indicator_width1 0
#property indicator_width2 0

extern double BoxSize = 7.0;
extern double BoxSizeH4 = 20.0;
extern double BoxSizeD1= 50.0;
extern double BoxSizeW1= 100.0;
extern double BoxSizeMN1= 200.0;
double mult;
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
  
  {
   
   if(Digits() == 5 || Digits() == 3)
     {
      mult = mult*10 ;
     }
   return(INIT_SUCCEEDED);
  
  
  }
  
  if ( Period()==240)
  {
  BoxSize=BoxSizeH4*mult ;
  }
  
  if (  Period()==1440)
  {
  BoxSize=BoxSizeD1*mult ;
  }
  
   if ( Period()==10080)
  {
  BoxSize=BoxSizeW1*mult ;
  }
  
  if (  Period()==43200)
  {
  BoxSize=BoxSizeMN1*mult ;
  }
  
  

//--- indicator buffers mapping
   IndicatorBuffers(4);
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexBuffer(0, Buffer1);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(1, Buffer2);
   SetIndexStyle(2, DRAW_NONE);
   SetIndexBuffer(2, Buffer3);
   SetIndexStyle(3, DRAW_NONE);
   SetIndexBuffer(3, Buffer4);
   SetIndexLabel(0, "Up");
   SetIndexLabel(1, "Dn");
   IndicatorDigits(Digits);
  
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
  double Hi;
   double Lo;
   double result;
   double barsize;
   double digits;
   int  i;
   for(i = MathMax(rates_total-1-prev_calculated,2); i>=0; i--)
  
   Buffer1[Bars] = Close[Bars];
   Buffer2[Bars] = Close[Bars];
   Buffer3[Bars] = Close[Bars];
   Buffer4[Bars] = Close[Bars];
   if (Digits == 5 || Digits == 3) digits = NormalizeDouble(10.0 * BoxSize, Digits); // original coders digit checker
   else digits = NormalizeDouble(BoxSize, Digits);
   double box = NormalizeDouble(Point * digits, Digits);
   int bars = Bars - i;
   for (int k = bars; k >= 0; k--) {
      Hi = NormalizeDouble(High[k] - (Buffer3[k + 1]) - box, Digits);
      Lo = NormalizeDouble(Low[k] - (Buffer4[k + 1]) + box, Digits);
      if (Hi >= 0.0) {
         barsize = NormalizeDouble((High[k] - (Buffer3[k + 1])) / box, Digits);
         result = NormalizeDouble(MathFloor(barsize), Digits);
         Buffer3[k] = Buffer3[k + 1] + box * result;
         Buffer4[k] = Buffer3[k] - box * result;
         Buffer1[k] = Buffer3[k];
         Buffer2[k] = Buffer4[k];
         Buffer4[k] = Buffer3[k] - box;
      } else {
         if (Lo <= 0.0) {
            barsize = NormalizeDouble((Buffer4[k + 1] - Low[k]) / box, Digits);
            result = NormalizeDouble(MathFloor(barsize), Digits);
            Buffer4[k] = Buffer4[k + 1] - box * result;
            Buffer3[k] = Buffer4[k] + box * result;
            Buffer2[k] = Buffer3[k];
            Buffer1[k] = Buffer4[k];
            Buffer3[k] = Buffer4[k] + box;
         } else {
            Buffer3[k] = Buffer3[k + 1];
            Buffer4[k] = Buffer4[k + 1];
            if (Buffer1[k + 1] > Buffer2[k + 1]) {
               Buffer1[k] = Buffer1[k + 1];
               Buffer2[k] = Buffer1[k] - box;
            }
            if (Buffer2[k + 1] > Buffer1[k + 1]) {
               Buffer1[k] = Buffer1[k + 1];
               Buffer2[k] = Buffer1[k] + box;
            }
         }
      }
   }
   return(rates_total);
  }
//+------------------------------------------------------------------+

THANK YOU EVERYONE!

Files:
 
anyone please?
 

The downloaded program was completely broken.

I fixed it, but is this correct one which you wanted?

Files: