similar feature like ArraySetAsSeries() on static array?

 
i can get the latest MA value for the last 5 bar using dynamic array. thanks to ArraySetAsSeries(), it reverse it's saving point so that current bar MA will be saved to index 0
double MA_Handle[];
ArraySetAsSeries(MA_Result, true);
if(CopyBuffer(MA_Handle, 0, 0, 5, MA_Result)<=0) { 
      Print("Problem reading indicator value!", GetLastError());
}
//MA_Result[0] = MA value of current bar

but since i know how much size i need (5), i tried to use the same code. but ArraySetAsSeries() only works on dynamic. this makes MA current bar is stored on index 4. how to achieve the same result.

double MA_Handle[5];
//ArraySetAsSeries(MA_Result, true);
if(CopyBuffer(MA_Handle, 0, 0, 5, MA_Result)<=0) { 
      Print("Problem reading indicator value!", GetLastError());
}
//MA_Result[0] = MA value of 5th bar
 
Abdul Arief Bogie Ardianto:
i can get the latest MA value for the last 5 bar using dynamic array. thanks to ArraySetAsSeries(), it reverse it's saving point so that current bar MA will be saved to index 0

but since i know how much size i need (5), i tried to use the same code. but ArraySetAsSeries() only works on dynamic. this makes MA current bar is stored on index 4. how to achieve the same result.

Just write your own function to return the correct array item from your stored array

 
Paul Anscombe #:
Just write your own function to return the correct array item from your stored array

yes i know i can manually do that. but that's not what i want to learn and to know

 
Abdul Arief Bogie Ardianto #:

yes i know i can manually do that. but that's not what i want to learn and to know

Well it is the only way because arrayasseries only works on dynamic
So if you want to learn why don’t  you show your attempt at the function and then we can help you
It’s not a hard function to code

 
Abdul Arief Bogie Ardianto:
i can get the latest MA value for the last 5 bar using dynamic array. thanks to ArraySetAsSeries(), it reverse it's saving point so that current bar MA will be saved to index 0

but since i know how much size i need (5), i tried to use the same code. but ArraySetAsSeries() only works on dynamic. this makes MA current bar is stored on index 4. how to achieve the same result.

After copybuffer, call ArrayReverse for 5 element array, it is an insignificant performance penalty.