What to do when Data window shows different value then the iCustom value?

 

Hi All 

Can someone please give me some pointers/advice on what to do when the data window shows different value then the iCustom value ?


Example : Buffer 0 and buffer 1 are showing correct values but buffer 3 and buffer 2 are showing wrong values 

Screentsho


Code:

#property version       "1.10"
#property strict

int handle;

//+------------------------------------------------------------------+
//| Initialization function of the expert                            |
//+------------------------------------------------------------------+
int OnInit()
{
   handle=iCustom(_Symbol, 0, "LTD by KDMfx");
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Deinitialization function of the expert                          |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   IndicatorRelease(handle);
}


void OnTick()
{
   double LTDindicator1[],
          LTDindicator2[],
          LTDindicator3[],
          LTDindicator4[];
                           
   ArraySetAsSeries(LTDindicator1, true);   
   ArraySetAsSeries(LTDindicator2, true);   
   ArraySetAsSeries(LTDindicator3, true);   
   ArraySetAsSeries(LTDindicator4, true);
            
   CopyBuffer(handle, 0, 0, 75, LTDindicator1);
   CopyBuffer(handle, 1, 0, 75, LTDindicator2);
   CopyBuffer(handle, 2, 0, 75, LTDindicator3);
   CopyBuffer(handle, 3, 0, 75, LTDindicator4);
   
   double val1= LTDindicator1[5] ;
   double val2= LTDindicator2[5] ;
   double val3= LTDindicator3[5] ;
   double val4= LTDindicator4[5] ;
   
   Comment(
   
   "\nBuffer 0: " , val1,
      "\nBuffer 1: " , val2,
         "\nBuffer 2: " , val3,
            "\nBuffer 3: " , val4      
            
            );
return;
}


Not looking for Exact code , just some advice to solve this issue ?

 
Arad_1:

Hi All 

Can someone please give me some pointers/advice on what to do when the data window shows different value then the iCustom value ?


Example :


Code:

Not looking for Exact code , just some advice to solve this issue ?

Fix your code, you have to figure out the count of the candles

 
amando:

Fix your code, you have to figure out the count of the candles

Hi amando thank you for your response , i thought thought  [5] is supposed to be the candle count ? is that incorrect ?


double val3= LTDindicator3[5] ;
this indicator does not draw for last 5 candles and only draws candle 6 and backwards so i was trying to get the indicator value for 5th candle or 6th no matter what candle i use i always get wrong value 
 
  1. In the comment Buffer 2 might show some residuals
  2. At 16:17 both are 0.0 but/and (by default?) zero values are not shown and left empty in the Data Window
    See: https://www.mql5.com/en/docs/constants/indicatorconstants/drawstyles#enum_plot_property_double

    PLOT_EMPTY_VALUE

    An empty value for plotting, for which there is no drawing

    double


  3. To normalize the many decimals in Comment() use DoubleToString().
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
  • www.mql5.com
Drawing Styles - Indicator Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Carl Sch@Carl Schreiber reiber:
  1. In the comment Buffer 2 might show some residuals
  2. At 16:17 both are 0.0 but/and (by default?) zero values are not shown and left empty in the Data Window
  3. To normalize the many decimals in Comment() use DoubleToString().

 @Carl Schreiber thanks for you comment , residuals and normalizing isnt a big problem , but the main issue is the with the Buffer 2 and buffer 3  if you take a look at the screenshot Buffer2 shows 1.0 where as the data window shows nothing /0  
so if data window is correct then iCustom should also show 0 for Buffer2 , correct ?

 
Arad_1:

 @Carl Schreiber thanks for you comment , residuals and normalizing isnt a big problem , but the main issue is the with the Buffer 2 and buffer 3  if you take a look at the screenshot Buffer2 shows 1.0 where as the data window shows nothing /0  
so if data window is correct then iCustom should also show 0 for Buffer2 , correct ?

I assume that the Indicator does not show buffer 2 & 3
 

I don't know the indicator so I'm guessing, but that looks like a color buffer to me (that's why it shows 1, which would be the color index of the buffer 2 in this case). Those buffers are not visible in the data window. An easy way to check if there is any is in the indicator colors tab (in its settings) and see if there is more than one color in any row.

If that's the case you should check buffer 3 and 4, instead of 2 and 3 (and the value that returns CopyBuffer, if 4 is a valid buffer it will be greater than 0).

Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
  • www.mql5.com
CopyBuffer - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: