How to count standard deviation of past 200 candles

 

I want to count past 200 candles that they has highest standard deviation or lowest standard deviation value.

 double DeviationArray[200];
     
     for(int i=199;i>0;i--){
     
      double deviationValue = iStdDev(Symbol(),Period(),StdDevPeriod,0,MODE_SMA,PRICE_CLOSE,i);
      
      DeviationArray[i]=deviationValue;
     }
     
     double currentDeviationValue = iStdDev(Symbol(),Period(),20,0,MODE_SMA,PRICE_CLOSE,0);
     
     int HighestCandle = ArrayMaximum(DeviationArray,WHOLE_ARRAY,0);
     int lowestCandle = ArrayMinimum(DeviationArray,WHOLE_ARRAY,0);
     
     Print("High"+HighestCandle+"Low"+lowestCandle+"");

when run this codes, at first , count highest and lowest values alternately , but when lowest value show 0 , it never recount lowest value alternatively .

always show lowest value zero till end of backtest.


why not recount lowest array in this codes.

can someone help my issue.

 
LONNV: why not recount lowest array in this codes.
    for(int i=199;i>0;i--){

There are 199 bars between 199 and 1.  One array element not filled, therefor zero, and that is the minimum.

Reason: