I need a large number of bars (E.g. 1000) of indicator data in my EA. When the EA starts, obviously it will then need to copy 1000 bars from the indicator in an array. On subsequent ticks (or in my case, subsequent bars, since it is stopped from doing the copy every tick), should I copy 1000 bars again, or can I just copy the most recent bar and everything will shift along, with the old now unneeded data falling off the back of the array?
static datetime prevTime=0;
if(CopyTime(_Symbol,_Period,0,1,lastTime)==1 && prevTime!=lastTime)
int copy_count = (prevTime==0) ? 1000 : 2; // is this correct? or should it be 1000 every bar?
int CopyBufferFunction(int indicator_handle,int buffer_number,int start_index,int count,double &destination_buffer)
bool success = false;
int attempts = 0;
while(!success && attempts<100)
success = false;
Print("Copying of buffer ",IntegerToString(buffer_number)," has failed: ",ErrorDescription(GetLastError()));
success = true;
if(success) return 1;
else return -1;
copy the 1000 values once, then after a new bar add only the last one