Download MetaTrader 5

[CopyBuffer] Requested data not found ERR 4806

To add comments, please log in or register
Arturo Lopez Perez
168337
Arturo Lopez Perez  

Good afternoon,

I am having trouble copying information from one buffer to an EA, having a recurrent 4806 error, which stands for requested data not found. The value on the buffer is correctly assigned during the indicator execution, however I don't seem to be able to read it from the EA. The handle is created without problems, but the copybuffer function call only seems to read data fromvisible buffers. The buffer number I am trying to read is buffer 4. Buffer 0, 1, 2 and 3 are readable. Only buffer 4 and above fails to be read. The following is the code. Could you be kind enough enlighten me about which my dumb mistake is? Thanks!

//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_minimum 0

//---- plotting settings
#property indicator_plots   4
#property indicator_type1   DRAW_HISTOGRAM
#property indicator_type2   DRAW_HISTOGRAM
#property indicator_type3   DRAW_HISTOGRAM
#property indicator_type4   DRAW_LINE
#property indicator_color1  clrSilver
#property indicator_color2  clrDodgerBlue
#property indicator_color3  clrRed
#property indicator_color4  clrTeal
#property indicator_width1  4
#property indicator_width2  4
#property indicator_width3  4
#property indicator_width4  1
#property indicator_style4  STYLE_DOT

//---- indicator buffers
double ValueBuffer[];
double UpBuffer[];
double DownBuffer[];
double AverageBuffer[];
double SignalBuffer[];
double DFU[], RFU[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
    //--
    //-- Buffers 
    //--

    // Indicator buffers
    SetIndexBuffer(0, ValueBuffer); 
    SetIndexBuffer(1, UpBuffer); 
    SetIndexBuffer(2, DownBuffer); 
    SetIndexBuffer(3, AverageBuffer);                             
    SetIndexBuffer(4, SignalBuffer, INDICATOR_DATA);   // This buffer holds information but is not readable. Why?
    SetIndexBuffer(5, DFU, INDICATOR_CALCULATIONS);     
    SetIndexBuffer(6, RFU, INDICATOR_CALCULATIONS);                                                           

    // Buffers
    ArraySetAsSeries(ValueBuffer, true);
    ArraySetAsSeries(UpBuffer, true);
    ArraySetAsSeries(DownBuffer, true);
    ArraySetAsSeries(AverageBuffer, true);
    ArraySetAsSeries(SignalBuffer, true);
    ArraySetAsSeries(DFU, true);
    ArraySetAsSeries(RFU, true);
    
    // Initialze
    ArrayInitialize(ValueBuffer, 0);
    ArrayInitialize(UpBuffer, 0);
    ArrayInitialize(DownBuffer, 0);
    ArrayInitialize(AverageBuffer, EMPTY_VALUE);
    ArrayInitialize(SignalBuffer, EMPTY_VALUE);
    ArrayInitialize(DFU, 0);
    ArrayInitialize(RFU, 0);
    
    //--- Digits
    IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
    
    // Delete Objects 
    DeleteObjects();
    
    // Set nice name
    IndicatorSetString(INDICATOR_SHORTNAME, ShortName + " ("+ (string) AveragePeriod +","+ DoubleToString(TradeSignal,1) +")");

    // Ok!
    return(INIT_SUCCEEDED);
}
Alain Verleyen
Moderator
33334
Alain Verleyen  
PzTrading:

Good afternoon,

I am having trouble copying information from one buffer to an EA, having a recurrent 4806 error, which stands for requested data not found. The value on the buffer is correctly assigned during the indicator execution, however I don't seem to be able to read it from the EA. The handle is created without problems, but the copybuffer function call only seems to read data fromvisible buffers. The buffer number I am trying to read is buffer 4. Buffer 0, 1, 2 and 3 are readable. Only buffer 4 and above fails to be read. The following is the code. Could you be kind enough enlighten me about which my dumb mistake is? Thanks!

If this indicator isn't used for drawing you have to declare it as INDICATOR_CALCULATIONS.

data_type

[in] Type of data stored in the indicator array. By default it is INDICATOR_DATA (values of the calculated indicator). It may also take the value of INDICATOR_COLOR_INDEX; in this case this buffer is used for storing color indexes for the previous indicator buffer. You can specify up to 64 colors in the #property indicator_colorN line. The INDICATOR_CALCULATIONS value means that the buffer is used in intermediate calculations of the indicator and is not intended for drawing.

Arturo Lopez Perez
168337
Arturo Lopez Perez  
angevoyageur:

If this indicator isn't used for drawing you have to declare it as INDICATOR_CALCULATIONS.

Thanks!
To add comments, please log in or register