PlotIndexSetInteger concern

 

The term in my EA 'if(CopyBuffer(handle,1,0,10,zm)<0)' works as expected and returns valid array variables.

When I attempt to shift the plot in my custom indicator using 'PlotIndexSetInteger(1,PLOT_SHIFT,10)' to show a future prediction, the term in my EA returns unitialised array values.

Any ideas how to resolve this other than by having a second array which is not shifted.

Step on New Rails: Custom Indicators in MQL5
  • 2009.11.23
  • Андрей
  • www.mql5.com
I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
 
winston:

The term in my EA 'if(CopyBuffer(handle,1,0,10,zm)<0)' works as expected and returns valid array variables.

When I attempt to shift the plot in my custom indicator using 'PlotIndexSetInteger(1,PLOT_SHIFT,10)' to show a future prediction, the term in my EA returns unitialised array values.

Any ideas how to resolve this other than by having a second array which is not shifted.

Read this topic https://www.mql5.com/en/docs/series/copybuffer

On error function CopyBuffer will return -1 and set LastError is not zero value.

It is small positive example for you

int OnStart()
  {
   int h1=iMA(_Symbol,_Period,13,0,MODE_EMA,PRICE_CLOSE);
   int h2=iMA(_Symbol,_Period,13,10,MODE_EMA,PRICE_CLOSE);
   if(h1!=INVALID_HANDLE && h2!=INVALID_HANDLE)
     {
      double a1[],a2[];
      int cp1=CopyBuffer(h1,0,0,1,a1);
      int cp2=CopyBuffer(h2,0,-10,1,a2);
     }
//---
   return(0);
  }
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
  • www.mql5.com
Timeseries and Indicators Access / CopyBuffer - Documentation on MQL5