Bug report for MQL Build 509

 

Where can I find the bug report items for Build 509?

SetIndexDrawBegin used along with SetIndexStyle does not seem to limit the indi line displayed beyond the max no of bars

specified, e.g., SetIndexDrawBegin (i, maxBars) where maxBars= 20 and i is 0 to 7 for currency buffers.

Strangely SetIndexEmptyValue (i, 0.0) makes the plot disappear except a zigzag line !

 

SetIndexDrawBegin counts from the other end of the chart.

I believe if you SetIndexEmptyValue to 0.0 any parts of the line which have not been assigned a value will be set to 0.0

I'm not entirely convinced SetIndexEmptyValue works properly if it is supposed to be a non drawing value. It does work if you set it to EMPTY_VALUE (the default value) or -EMPTY_VALUE but other values always seem to draw the line at that value.

 
SDC:

SetIndexDrawBegin counts from the other end of the chart.

I believe if you SetIndexEmptyValue to 0.0 any parts of the line which have not been assigned a value will be set to 0.0

I'm not entirely convinced SetIndexEmptyValue works properly if it is supposed to be a non drawing value. It does work if you set it to EMPTY_VALUE (the default value) or -EMPTY_VALUE but other values always seem to draw the line at that value.


In theory what you say is what the doc also says :)

My SetIndexDrawBegin starts drawing at 20 bars (from left) down to zero (current bar), but then the old bars

keep displaying so the indi line display keeps expanding to the left.

To counter, I tried SetIndexEmptyValue as above using 0.0 for EMPTY_VALUE, but merely introducing it without even defining while (i > maxBars) { arrUSD[i] = 0... arrNZD[i] =0} gives me a zero-vertical-max zigzag line for the first currency, USD.

Taking out either or both these operators results in the same line expanding to left.

 
The line is not expanding to the left. The line is expanding to the right as new bars are added to the right. DrawBegin doesn't change that. Set Empty Value just specifies what value is not displayed - irrelevant.
 
WHRoeder:
The line is not expanding to the left. The line is expanding to the right as new bars are added to the right. DrawBegin doesn't change that. Set Empty Value just specifies what value is not displayed - irrelevant.


You are right :) The MQL4 doc is pretty lousy, still, and I confused the left vs right expand.

So what do you suggest as remedy?

 
atharmian: So what do you suggest as remedy?
If you coded the for loop correctly there is no problem to remedy. You scroll the chart back and it shows the old values.
 
WHRoeder:
If you coded the for loop correctly there is no problem to remedy. You scroll the chart back and it shows the old values.

So where did I go wrong here? This seems to me a straightforward loop... is ArrayCopy the problem?

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int limit;
   int counted_bars = IndicatorCounted();

   if (counted_bars < 0)  return(-1);
   if (counted_bars > 0)  counted_bars --;

   limit = Bars - counted_bars;

  
   if(limit>maxBars)
      limit=maxBars;
      

 
  //----- chart style and bars limit
 for (int i = 0; i < CURRENCYCOUNT; i++ )
   {
      SetIndexStyle( i, DRAW_LINE, STYLE_SOLID, 2, currencyColors[i] );
     
   }
   
  RefreshRates();
 
   
   for ( i = limit; i >= 0; i-- )
   {
      int index;
      double diff = 0.0;  //adds currency diff values to currencies.
      
      ArrayInitialize(currencyValues, 0.0);

      // Calc Slope into currencyValues[]  
      calcCSS( userTimeFrame, i );

      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "USD" ) != -1 ) ) || ( !showOnlySymbolOnChart && USD ) )        
      {
         arrUSD[i] = currencyValues[0];
         if ( diff == 0 ) diff += currencyValues[0]; else diff -= currencyValues[0];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "EUR" ) != -1 ) ) || ( !showOnlySymbolOnChart && EUR ) )        
      {
         arrEUR[i] = currencyValues[1];
         if ( diff == 0 ) diff += currencyValues[1]; else diff -= currencyValues[1];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "GBP" ) != -1 ) ) || ( !showOnlySymbolOnChart && GBP ) )        
      {
         arrGBP[i] = currencyValues[2];
         if ( diff == 0 ) diff += currencyValues[2]; else diff -= currencyValues[2];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "CHF" ) != -1 ) ) || ( !showOnlySymbolOnChart && CHF ) )        
      {
         arrCHF[i] = currencyValues[3];
         if ( diff == 0 ) diff += currencyValues[3]; else diff -= currencyValues[3];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "JPY" ) != -1 ) ) || ( !showOnlySymbolOnChart && JPY ) )        
      {
         arrJPY[i] = currencyValues[4];
         if ( diff == 0 ) diff += currencyValues[4]; else diff -= currencyValues[4];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "AUD" ) != -1 ) ) || ( !showOnlySymbolOnChart && AUD ) )        
      {
         arrAUD[i] = currencyValues[5];
         if ( diff == 0 ) diff += currencyValues[5]; else diff -= currencyValues[5];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "CAD" ) != -1 ) ) || ( !showOnlySymbolOnChart && CAD ) )        
      {
         arrCAD[i] = currencyValues[6];
         if ( diff == 0 ) diff += currencyValues[6]; else diff -= currencyValues[6];
      }
      if ( ( showOnlySymbolOnChart && ( StringFind ( Symbol(), "NZD" ) != -1 ) ) || ( !showOnlySymbolOnChart && NZD ) )        
      {
         arrNZD[i] = currencyValues[7];
         if ( diff == 0 ) diff += currencyValues[7]; else diff -= currencyValues[7];
      }
      
      
      if ( i == 1 )
      {
         ArrayCopy(currencyValuesPrior, currencyValues);
      }
      if ( i == 0 )
      {
         // Show ordered table
         ShowCurrencyTable( userTimeFrame );
      }
      ..... return(0);
 
WHRoeder:
If you coded the for loop correctly there is no problem to remedy. You scroll the chart back and it shows the old values.


WHRoeder,

I now figured out the real problem and am surprised no guru with all that long coding experience could !

Do you know if the SetIndexStyle lines can be deleted (apparently not)? What I am trying to do is to limit the currency lines display to the most recent maxBars= 20, but the display simply adds new points.


I have tried all sorts of stuff including SetIndexDrawBegin, SetIndexEmptyValue, tried arrUSD=0 for i > MaxBars, but no luck. MQL4 doc is really poor, and ObjectCreate may not be the answer: it seems to draw specific objects only?

 

if you don't want the line history to get longer than maxbars as new bars are added to the chart dont let it get longer,

LineBuffer[maxbars] = EMPTY_VALUE;

The docs cannot possibly tell you how to code for every scenario unless you expect the docs to be a 20 volume encyclopedia.

 
SDC:

if you don't want the line history to get longer than maxbars as new bars are added to the chart dont let it get longer,

LineBuffer[maxbars] = EMPTY_VALUE;

The docs cannot possibly tell you how to code for every scenario unless you expect the docs to be a 20 volume encyclopedia.


SDC,

Thanks for the reply. Actually I did try your suggestion which is the same I got from another source.

But it doesn't work- don't know why. I am also attaching the original mq4.

See code snippet below. In this form, there is no difference in display.

(On top of mq4 there are declarations like SetIndexBuffer (0, arrUSD[]);)

Playing around a bit, e.g., taking the SetIndexEmptyValue code out of the while loop and placing on the while loop top, or declared before the Start(), results in a single Z line for the first currency (USD)- top, diagonal, bottom, no other display.


Also, WHRoeder said above will not help- maybe it is because SetIndexEmptyValue actually doesn't delete older values, but simply misses any new values set to zero to be plotted?

I don't see any problem with the for loop.


I am stumped ...


Athar.


Inserted following code in the for ( i = limit; i >= 0; i-- ) loop towards the end, in Start().

while (i > maxBars)
      {
      
       SetIndexEmptyValue (0, 0.0);
    SetIndexEmptyValue (1, 0.0);
    SetIndexEmptyValue (2, 0.0);
    SetIndexEmptyValue (3, 0.0);
    SetIndexEmptyValue (4, 0.0);
    SetIndexEmptyValue (5, 0.0);
    SetIndexEmptyValue (6, 0.0);
    SetIndexEmptyValue (7, 0.0);
     
      arrUSD= 0;
      arrEUR= 0;
      arrGBP= 0;
      arrJPY= 0;
      arrCHF= 0;
      arrAUD= 0;
      arrNZD= 0;
      arrCAD= 0; 
      }

Files:
 

Don't SetIndexEmptyValue to zero. Delete all that. Empty value already has a default special value called EMPTY_VALUE, there are reasons for changing it (rarely) and they do not apply in your case.

You have already limited your history to max bars, all you need to do to prevent it getting longer than that is do

linebuffer[maxbars] = EMPTY_VALUE;

here look at this

#property indicator_chart_window
#property indicator_color1 Red
//--buffers
double LineBuffer[];
//-----------------------------------------------------------
int init()
  {
   SetIndexBuffer(0,LineBuffer);
   return(0);
  }
//-----------------------------------------------------------
int start()
  {
   int counted_bars=IndicatorCounted();
   int maxbars = 20;
   int i = Bars - 1 - counted_bars;
   if( i > maxbars) i = maxbars; 
   while(i >= 0)
   {
    LineBuffer[i] = High[i];
    i--;
   }
   LineBuffer[maxbars] = EMPTY_VALUE;
   return(0);
  }

If you had a lot of lines to limit you could make it more efficient by only writing the empty value to their buffers when a new bar begins.

Reason: