The CopyBuffer of this custom Indicator, doesn't seem to get it right. Why?



Im using a custom indicator, it seems to be correct, it displays correctly, but, when using it in the EA, results are not as expected.

for example, I've said to the indicator to open an order, when the value of the indicator is smaller than 0, after this equal to 100 and after this smaller than 100, but it's not doing what I've asked.


as you see in the image, the order opens, when it has had a constant 100 over the last 3 periods.

How could I say to the indicator to do this in those time periods?

   double array_st[];
   int start_pos_st=0,count_st=4;
bool iGetArrayST(const int handleST,const int bufferST,const int start_posST,
                 const int countST,double &arr_bufferST[])
   bool resultST=true;
      PrintFormat("ERROR! EA: %s, FUNCTION: %s, this a no dynamic array!",__FILE__,__FUNCTION__);
//--- reset error code
//--- fill a part of the iBands array with values from the indicator buffer
   int copiedST=CopyBuffer(handleST,bufferST,start_posST,countST,arr_bufferST);
      //--- if the copying fails, tell the error code
      PrintFormat("ERROR! EA: %s, FUNCTION: %s, amount to copy: %d, copied: %d, error code %d",
      //--- quit with zero result - it means that the indicator is considered as not calculated
if(Orden=="Buy" && ( array_st[3]<100 && array_st[2]==100  && array_st[1]<100