ArrayCopySeries question

 
In the documentation of ArrayCopySeries it sais:
"There is no real memory allocation for data array and nothing is copied. When such an array is called, the access is redirected. Excluded are arrays that are assigned as indexed ones in custom indicators. In this case, data are really copied."

Well, I try to use this function on an array "that is assigned as indexed one" but then I get this runtime error message: 'ArrayCopySeries function internal error', and no data is copied.

Is this a bug? If not what is wrong?

Thanks,
Doji
 
Please expose sample of code that generates runtime error
 
Please expose sample of code that generates runtime error

I can't reproduce the bug. Now it works but there's another problem. Each time after I call ArrayCopySeries I also call ArraySetAsSeries(closeBuffer, false) because I want to use it as a standard array (not series). The first time it works. After that, the array remains a series array in spite of the call.
Here is the code
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Yellow

int Length = 50;
int size;
double closeBuffer[];
double iBuffer1[];

int init()
{
    SetIndexStyle(0,DRAW_LINE);
    SetIndexBuffer(0,iBuffer1);
    
    SetIndexStyle(1,DRAW_LINE);
    SetIndexBuffer(1,closeBuffer);
    
    return(0);
}

int start()
{
    if (Bars <= Length)
        return(0);
        
    int bar;
    int counted_bars = IndicatorCounted();
    
    // initializing buffers with zeros
    if (counted_bars < 1)
        for (bar=Bars; bar>=Bars-Length-1; bar--)
            iBuffer1[bar] = 0.0;

    size = ArrayCopySeries(closeBuffer, MODE_CLOSE, NULL, 0);
    ArraySetAsSeries(closeBuffer, false);
    Print(closeBuffer[0], " ", closeBuffer[1]);
    
    return(0);
}
 
ArraySetAsSeries cannot be applied to series arrays.
Use your own controlled array
double closeBuffer[];
...
   ArrayResize(closeBuffer,Bars);
   ArrayCopy(closeBuffer,Close);
...
 
ArraySetAsSeries cannot be applied to series arrays.
Use your own controlled array
double closeBuffer[];
...
   ArrayResize(closeBuffer,Bars);
   ArrayCopy(closeBuffer,Close);
...



Ok, Thanks. Everything works for me now.

Doji
Reason: