public static double[] EMA(Index[] data2,int n,double alfa){
        Index[] data = new Index[data2.length];
        data=ReverseIndex(data2);
        double[] out = new double[data.length];
        for(int i=0;i<data.length;i++){
            int expo=0;
            double avg_close=0;
            double div=0;
            if(data.length-n<=i){
                 for(int j=i;j<data.length;j++){
                    avg_close+=data[j].getClose_val()*Math.pow((1-alfa),expo);
                    div+=Math.pow((1-alfa), expo);
                    expo++;
                }
                out[i]=avg_close/div;
                System.out.println();
            }else{
                for(int j=i;j<i+n;j++){
                    avg_close+=data[j].getClose_val()*Math.pow((1-alfa),expo);
                    div+=Math.pow((1-alfa), expo);
                    expo++;
                }
                out[i]=avg_close/div;
            }
        }
        out=Reverse(out);
        return out;
    }