public static double[] SD(Index[] data2,int n){
        Index[] data = new Index[data2.length];
        data=ReverseIndex(data2);
        double[] out = new double[data.length];
        double[] temp = new double[data.length];
        temp=MA(data,n);
        for(int i=0;i<data.length;i++){
            if(temp.length-n<=i){
                double sum=0;
                int nn=data.length-i;
                for(int j=i;j<data.length;j++){
                    sum=sum+Math.pow(data[j].getClose_val()-temp[i],2);
                }
                out[i]=Math.sqrt(sum/(double)nn);
            }else{
                double sum=0;
                for(int j=i;j<i+n;j++){
                    sum=sum+Math.pow(data[j].getClose_val()-temp[i],2);
                }
                out[i]=Math.sqrt(sum/(double)n);
            }
        }
        out=Reverse(out);
        return out;
    }