Not use ArraySetAsSeries(Buffer,true); how to access buffer correctly?

 

In my indicator I'm using ArraySetAsSeries(Buffer,true); for series access.

If I access the buffer from my EA with iCustom how can I access the series order correctly?‌

Thanks.‌

 

How do I access the latest 500 values?

 
paulgriffiths: If I access the buffer from my EA with iCustom how can I access the series order correctly?‌
  1. You posted in the Root / MT5 EA section so you don't "access the buffer" with iCustom, you use CopyBuffer
  2. If you meant to post the the MT4 section The shift is as series.
 
whroeder1:
  1. You posted in the Root / MT5 EA section so you don't "access the buffer" with iCustom, you use CopyBuffer
  2. If you meant to post the the MT4 section The shift is as series.


Thanks with the copyBuffer. How do I know it' size when it comes to reading it? The link you suggested for copyBuffer is from indicator to indicator, an EA has no rates_total or prev_calculated.

The example shown is:

MA_handle=iCustom(NULL,0,"Examples\\Custom Moving Average",
                     MA_Period,
                     MA_Shift,
                     MA_Method,
                     PRICE_CLOSE // using the close prices
                     );
   Print("MA_handle = ",MA_handle,"  error = ",GetLastError());

...

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//--- Copy the values of the indicator Custom Moving Average to our indicator buffer
   int copy=CopyBuffer(MA_handle,0,0,rates_total,Label1Buffer);
   Print("copy = ",copy,"    rates_total = ",rates_total);
//--- If our attempt has failed - Report this
   if(copy<=0)
      Print("An attempt to get the values if Custom Moving Average has failed");
//--- return value of prev_calculated for next call
   return(rates_total);
  }

I have in my indicator:

SetIndexBuffer(1,HighsBuffer,INDICATOR_DATA);

This is the buffer I wish to copy into my EA. ‌

 
paulgriffiths:


Thanks with the copyBuffer. How do I know it' size when it comes to reading it? The link you suggested for copyBuffer is from indicator to indicator, an EA has no rates_total or prev_calculated.

The example shown is:

MA_handle=iCustom(NULL,0,"Examples\\Custom Moving Average",
                     MA_Period,
                     MA_Shift,
                     MA_Method,
                     PRICE_CLOSE // using the close prices
                     );
   Print("MA_handle = ",MA_handle,"  error = ",GetLastError());

...

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//--- Copy the values of the indicator Custom Moving Average to our indicator buffer
   int copy=CopyBuffer(MA_handle,0,0,rates_total,Label1Buffer);
   Print("copy = ",copy,"    rates_total = ",rates_total);
//--- If our attempt has failed - Report this
   if(copy<=0)
      Print("An attempt to get the values if Custom Moving Average has failed");
//--- return value of prev_calculated for next call
   return(rates_total);
  }

I have in my indicator:

SetIndexBuffer(1,HighsBuffer,INDICATOR_DATA);

This is the buffer I wish to copy into my EA. ‌

Why do you want to copy ALL data of a buffer in an EA ? Copy just what you need :

int copy=CopyBuffer(MA_handle,0,0,COUNT_VALUES_I_NEED,Label1Buffer);
 
Alain Verleyen:

Why do you want to copy ALL data of a buffer in an EA ? Copy just what you need :

int copy=CopyBuffer(MA_handle,0,0,COUNT_VALUES_I_NEED,Label1Buffer);

I see, thanks.
Reason: