Hiding future bars when looking at historical price

 

I would like to write an indicator to hide price bars after an input date. The purpose of this indicator is for educational, when I look into history, I would like to hide those bars on the right of a historical date I set so that I can analyse the bars on the left of the date without the bars on the right affecting my analysis.

 
williamwong:

I would like to write an indicator to hide price bars after an input date. The purpose of this indicator is for educational, when I look into history, I would like to hide those bars on the right of a historical date I set so that I can analyse the bars on the left of the date without the bars on the right affecting my analysis.

Hiding INDICATOR bars is easy, just set them to EMPTY_VALUE and they are not printed. Price bars on the main chart are a different matter. I would normally expect to run the future off the right side of the chart window, thereby hiding the future. Just turn off the chart auto-update and you can scroll back into history using the left cursor control or the pageup control to move faster. You can scroll as much of the future as you want off the screen.

 
dabbler:

Hiding INDICATOR bars is easy, just set them to EMPTY_VALUE and they are not printed. Price bars on the main chart are a different matter. I would normally expect to run the future off the right side of the chart window, thereby hiding the future. Just turn off the chart auto-update and you can scroll back into history using the left cursor control or the pageup control to move faster. You can scroll as much of the future as you want off the screen.


I would want an indicator to accept 1 date value and for every chart I pull out will only display price bars up to this date not later. This will allow one to actually learn how to trade without looking into future bars.
 

just an idea, cant you draw a box infront of these bars you don't want too se?

from your setdate to TimeCurrent()

havn't tried it at all, but as i see it, it would bee the easiest way.

 
enotrek:

just an idea, cant you draw a box infront of these bars you don't want too se?

from your setdate to TimeCurrent()

havn't tried it at all, but as i see it, it would bee the easiest way.


Box can only be 1 color. If you use candle stick (lime,white for bull and black for bear), it won't work.

Even with bar display (lime) and but if I have fractal (yellow) or other indicator, it won't work.

This is quite frustrating and I don't see this feature in MT5 also.

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

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Red

//---- buffers
double buf1[];
double buf2[];


extern color BackgroundColor=White;
extern datetime HidingDate;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,5,BackgroundColor);
   SetIndexBuffer(0,buf1);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,5,BackgroundColor);
   SetIndexBuffer(1,buf2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   for(int i=MathMin(Bars-counted_bars-1,iBarShift(Symbol(),Period(),HidingDate,false));i>=0;i--){
      buf1[i]=High[i];
      buf2[i]=Low[i];
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

have fun

//z

 

btw, if you want to hide all indicators too, you have to change:

      buf1[i]=High[i];
      buf2[i]=Low[i];

to

      buf1[i]=9999999;
      buf2[i]=0;
Reason: