when i call the attached indicator during run time like this:
it works for a while but after 1 or 2 hours i get array out of range error and the EA is removed from chart
how can i fix this
You need to check the return value of CopyBuffer(), then act accordingly.
Not directly related but : Bars() is a function, you called it 4 times with the same parameter, call is once and record the value in a variable.