CopyBuffer Limitation!

 

hi guys


i tried to make system to back test my theory however when i try CoppyBuffer seems Maximum number it work is 35!

so wondering if there is any workaround this limitation?! since i want whole year buffer eb examined oh btw its not for iCustom just official indicators buffered 


tnX for help in advance

 
Amirfakhredin Ghanbari:

hi guys


i tried to make system to back test my theory however when i try CoppyBuffer seems Maximum number it work is 35!

so wondering if there is any workaround this limitation?! since i want whole year buffer eb examined oh btw its not for iCustom just official indicators buffered 


tnX for help in advance

Maximum number of what?

Show the code where you use it.

 
Keith Watford:

Maximum number of what?

Show the code where you use it.

                              ArraySetAsSeries(MA_Array,true);
                              int MA_Handle = iMA(SymbName,MyPeriod,MA_Period,MA_Shift,MODE_EMA,PRICE_CLOSE);
                              int resma=CopyBuffer(MA_Handle,0,0,365,MA_Array);
                              if (resma==-1)
                              {
                                 Print("MA_Error:",GetLastError());
                                 
                              }
                              //-----------------------------------------------------------------------
                              
                       
                              //AMA Calculation
                              ArraySetAsSeries(AMA_Array,true);
                              int AMA_Handle = iAMA(SymbName,MyPeriod,AMA_Period,AMA_Fast_ema_period,AMA_Slow_ema_period,0,PRICE_OPEN);
                              int resama=CopyBuffer(AMA_Handle,0,0,365,AMA_Array);
                              if (resma==-1)
                              {
                                 Print("AMA_Error:",GetLastError());
                                 
                              }
                              //-----------------------------------------------------------------------
                           
                          
                           for(dayCounter=365;dayCounter>1;dayCounter--)
                           {
                              if (MA_Array[dayCounter]<AMA_Array[dayCounter] && MA_Array[dayCounter+1]>AMA_Array[dayCounter+1])
                                 {
                                     Print("if_Error:",GetLastError());
                                     Print("Crossed on:",dayCounter);
                                 }
                           }

it's simple cross over but anything above 35 it will not work!

 
Amirfakhredin Ghanbari:

it's simple cross over but anything above 35 it will not work!

you have an array with total of 365 elements starting from zero index and you use 365 as last index to counter decrement?
 
roshjardine:
you have an array with total of 365 elements starting from zero index and you use 365 as last index to counter decrement?

array set from today backward thats not the point even reverse still anything in array above 35 not working

 
Amirfakhredin Ghanbari:

array set from today backward thats not the point even reverse still anything in array above 35 not working

array starts with 0 as first index and should end at 364 as last index for a total 365 count
 

what kind of error you are facing, is it out of bound error? if that's the case try using dynamic arrays.


int ma_handle;
double ma_buffer[];

int OnInit()
  {
//--- create timer
   EventSetTimer(1);
      
   ma_handle = iMA(_Symbol,PERIOD_CURRENT, 10,0,MODE_SMA,PRICE_CLOSE);
   SetIndexBuffer(0,ma_buffer,INDICATOR_DATA);
   ArraySetAsSeries(ma_buffer,true);

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   CopyBuffer(ma_handle,0,0,365,ma_buffer);
   Print(ma_buffer[364]);
   
  }

 
int AMA_Handle = iAMA(SymbName,MyPeriod,AMA_Period,AMA_Fast_ema_period,AMA_Slow_ema_period,0,PRICE_OPEN);
int resama=CopyBuffer(AMA_Handle,0,0,365,AMA_Array);

Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick (after the indicator has updated its buffers,) you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010

 
kave.me:

what kind of error you are facing, is it out of bound error? if that's the case try using dynamic arrays.


tnX for the code i even tried direct number such as MA_Array[36] and getting this error

array out of range in 'CrossTiming.mq5' (127,43)

but any number below 35 work just fine!


 
                              if (resama!=365)
                              {
                                 Print("AMA_Error:",GetLastError());
                              }
                         for(dayCounter=363;dayCounter>1;dayCounter--) // 365 - 2
                           {
                              if (MA_Array[dayCounter]<AMA_Array[dayCounter] && MA_Array[dayCounter+1]>AMA_Array[dayCounter+1])
 
William Roeder:

Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick (after the indicator has updated its buffers,) you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010

tnX William ofcourse i know that but since its long code i just posted the part i get error from 

int MA_Handle = iMA(SymbName,MyPeriod,MA_Period,MA_Shift,MODE_EMA,PRICE_CLOSE);
int resma=CopyBuffer(MA_Handle,0,0,365,MA_Array);

and as you can see i have handle and and put data from handle on copybuffer to an array MA_Array ....

with const number such as MA_Array[35] and below that code work just fine any number bigger than 35 i get an error =_=

Reason: