Setting Inside & Outside Bar Colours

 

Hi Guys.

I have usually been able to see inside and outside bars easily on most charting programs

and would like to do the same with mt4, but cant find any option to set this.

Is it possible and how could I do this, hopefully without an indicator as I have a few already

loaded on each chart, so guessing things will slow down the more indicators I have as have

15+ charts open at once.

Eitherway much appreciated

Tekmann

 
Tekmann:

Hi Guys.

I have usually been able to see inside and outside bars easily on most charting programs

and would like to do the same with mt4, but cant find any option to set this.

Is it possible and how could I do this, hopefully without an indicator as I have a few already

loaded on each chart,

I don't think you can set anything to do this.

It requires an indicator with two histograms, where the coloured bar is the difference between the two histogram levels. It is a bit complicated for a beginner so I have written and tested the code for you; it is posted further down in this thread.

 
I did it so it can't be that hard ;-)
 
dabbler:

How long have you been coding in MQL4, 4 years+ ?

I rest my case.

Making Indicator code work in an EA by handling it's bufferers manually is a touch complicated . . . 4 buffers and a couple of histograms isn't . . . but it's all relative I guess.
 

This should get you going (not guaranteed to be exactly what you want, but it should be obvious what bits to tweak to make what you want) ...

#property indicator_chart_window
#property indicator_buffers 2

#property indicator_width1 3     // change width to suit chart zoom
#property indicator_width2 3

#property indicator_color1 Aqua  // change colours to suit
#property indicator_color2 DeepPink

double inside[];
double outside[];

//+------------------------------------------------------------------------------------------------------------+
int init(){
   SetIndexBuffer(0, inside);
   SetIndexBuffer(1, outside);
   
   SetIndexStyle (0, DRAW_HISTOGRAM);
   SetIndexStyle (1, DRAW_HISTOGRAM);
   
   SetIndexLabel (0,"inside");  
   SetIndexLabel (1,"outside");
   
   IndicatorDigits(Digits);
   
   return(0);
}
//+------------------------------------------------------------------------------------------------------------+
int start(){
   int limit = Bars - IndicatorCounted() -2; // we need to look 1 bar ahead of the position so Bar-1 is too large 
   
   if( limit < 1 )
       limit = 1;
   
   // note that we never draw the ZERO bar as it will almost always be an inside bar initially
   for( int n=limit; n>0; n-- ){
      if( (High[n]<High[n+1]) && (Low[n]>Low[n+1]) ){       // this is an INSIDE bar
         inside[n] = High[n];    // inside is higher so it sets the colour
         outside[n]= Low[n];
      }
      else if( (High[n]>High[n+1]) && (Low[n]<Low[n+1]) ){  // this is an OUTSIDE bar
         outside[n]= High[n];    // outside is higher so it sets the colour
         inside[n] = Low[n];
      }
      else{                                                 // it is not anything useful so don't draw it
         inside[n] = EMPTY_VALUE;
         outside[n]= EMPTY_VALUE;
      }
   }

   return(0);
}

Don't worry about the extra computational power required. It only has to draw 1 bar per tick usually so it requires negligible computational effort.

The coloured bars are easier to see on a Bar Chart than a Candle Stick Chart.

 

Thanks for the responses guys, but I'm not a coder, just a humble button pusher ;)

So I'm guessing it isnt a feature with mt4 or mt5.? that unusual as its in most other apps.

Bugger, back to the drawing board ;(

Tekmann

 
Tekmann:

Thanks for the responses guys, but I'm not a coder, just a humble button pusher ;)

So I'm guessing it isnt a feature with mt4 or mt5.? that unusual as its in most other apps.

Nope, you need an Indicator to show the IBs and OBs
 
Tekmann:

Thanks for the responses guys, but I'm not a coder, just a humble button pusher ;)

That's why I wrote it for you and posted it above !


Reason: