Download MetaTrader 5

MT4 BUG: DRAW_HISTOGRAM with DOT lines changes to SOLID when zoomed in close.

To add comments, please log in or register
pips4life
338
pips4life  

I'm using MT4 4.00 build 509, but this bug has been around for quite some time.

The attached program draws Daily cycle lines using DRAW_HISTOGRAM to draw vertical DOT lines. The desired line style is DOT, which works when zoomed out, but if one zooms in to the 2 closest zoom levels (5th or 6th), the DOT lines change to SOLID! (BUG!)

When zoomed in close to see the chart details, the SOLID lines obscure the candle wicks which makes the use of a histogram useless for this simple program.

// MT4 Histogram DOT lines BUG.mq4   2013-07-31

// Indicator draws Daily lines at 00:00 each day using DRAW_HISTOGRAM.  When Zoomed out, the lines are correctly "STYLE_DOT".
// However when zoomed in the closest (6th) or next closest (5th) zoom level, these same lines appear as STYLE_SOLID!  (MT4 BUG!)
// The lines should always be DOT regardless of zoom in/out.  The SOLID lines obscure the candle wicks which makes this
// indicator useless to me when I zoom in close to see the chart detail!

// Fyi, this is JUST A BUG-DEMONSTRATION PROGRAM.  It may not be fully functional in all
// the ways I would otherwise write a Daily histogram line program.  (In fact, I hacked a more
// functional personal program just to demonstrate this MT4 bug, in hopes of a resolution).

//+------------------------------------------------------------------+
#property copyright "pips4life of forexfactory.com"
#property link      "http://www.forexfactory.com/pips4life"

#property indicator_chart_window

#property indicator_buffers 2         
#property indicator_color1 BlueViolet
#property indicator_style1 2
#property indicator_width1 1
#property indicator_color2 BlueViolet
#property indicator_style2 2
#property indicator_width2 1
//

extern int    HistoryBars=2000; // 0 is ALL bars.
extern color  LineColor=BlueViolet; // BlueViolet for MAIN-WINDOW, DodgerBlue for SUB-WINDOW  (change as desired) (Keep in sync with same color above)
extern string _INFO_Style_Choices          = "0=SOLID, 1=DASH, 2=DOT, 3=DASHDOT, 4=DASHDOTDOT"; // HOWEVER, with Histogram in EITHER-WINDOW, if zoomed-in close,
                                               //  the style appears SOLID regardless of the setting here!! (An MT4 Bug!)
extern int    LineStyle=2;
extern string _INFO_Width_value            = "1-5, but must be 1 if style other than SOLID";
extern int    LineWidth=1;

extern double UpperHistLevel =  500.0; // 300.0 is a level above most FX prices, like in EJ, UJ, etc.  It can be changed if needed.
extern double LowerHistLevel = 0.0001; // Small positive number (0.0001) is necessary for main price window.  For SUB-WINDOWS (-500 deault). User can change if necessary.

extern int    PlaceDailyLinesAt_hour = 0;

string   BaseName;
int      cycle;
int      cyclesec;
datetime shift_sec;
datetime last_Time0;
double   buf1[];
double   buf2[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  { 
    SetIndexStyle(0,DRAW_HISTOGRAM,LineStyle,LineWidth,LineColor);
    SetIndexBuffer(0,buf1);
    SetIndexEmptyValue(0,LowerHistLevel);
    
    
    SetIndexStyle(1,DRAW_HISTOGRAM,LineStyle,LineWidth,LineColor);
    SetIndexBuffer(1,buf2);
    SetIndexEmptyValue(0,-999.0); // Something besides any actually occuring real value.
    
    // These Alerts are in reverse order to improve readability in the popup.
    Alert("... Solid *obscures* the wicks!  I really need DOT lines to work at all zoom levels.");
    Alert("... Histogram correctly shows DOT lines. Zoom IN to 5th/6th closest => lines are SOLID! (MT4 BUG!) ");
    Alert(WindowExpertName(),":  Use an H1 chart. There are 6 normal zoom in/out levels. Zoom all OUT."); 
     
    if (Period() >= PERIOD_D1) Alert("ERROR. Use a timeframe <= H4 (pref H1) to see the Daily histogram lines.");
    
    if (Period() == PERIOD_H4) PlaceDailyLinesAt_hour = MathFloor(PlaceDailyLinesAt_hour/4.0)*4.0;
    return(0);
} // end of init


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   if (Period() >= PERIOD_D1) return(-1); // Preferably use on H1, but definitely <= H4.
   
   int i, limit;
   int Counted_bars=IndicatorCounted();
   static datetime last_Time0;
   
   if (HistoryBars==0) HistoryBars = Bars-1;
   limit=MathMin(Bars-1 - Counted_bars,MathMin(HistoryBars,Bars-1)) - 1;
   
   for (i=limit; i>=0; i--)  
   {
      last_Time0 = Time[0];
      if (TimeHour(Time[i]) == PlaceDailyLinesAt_hour && TimeMinute(Time[i]) == 0) buf1[i] = UpperHistLevel;
      else buf1[i] = LowerHistLevel;
      
      buf2[i] = LowerHistLevel; // buf2 never changes, and is used ONLY for main chart window.
  }
  //----
  return(0);
}
//+------------------------------------------------------------------+

Please fix this bug so that the histogram maintains the DOT style at all levels of zoom.

Simon Gniadkowski
Moderator
18035
Simon Gniadkowski  
pips4life:

I'm using MT4 4.00 build 509, but this bug has been around for quite some time.

The attached program draws Daily cycle lines using DRAW_HISTOGRAM to draw vertical DOT lines. The desired line style is DOT, which works when zoomed out, but if one zooms in to the 2 closest zoom levels (5th or 6th), the DOT lines change to SOLID! (BUG!)

When zoomed in close to see the chart details, the SOLID lines obscure the candle wicks which makes the use of a histogram useless for this simple program.

Please fix this bug so that the histogram maintains the DOT style at all levels of zoom.

Why not just use vertical line Objects ?

If you want to report this as a Bug please use the Service Desk

pips4life
338
pips4life  

RaptorUK, thanks, I did report the issue as a bug on Aug 3. No response yet.

While one can use VLINE objects as a workaround, I would rather have un-selectable histogram lines because too many objects on a chart makes it harder to select exactly the one object I want, plus if I do accidentally select the VLINE objects, it's all too easy to accidentally drag them to the wrong location. Of course the code can constantly reset the TIME1 property but that's a waste of CPU. I also have code that works through "foreach object" loops, and I don't like having a few hundred extra objects to slow things down.

It would just be best if the MT4 bug is fixed so that DRAW_HISTOGRAM lines maintain the DOT pattern regardless of being zoomed far in or out.

To add comments, please log in or register