public static void main(String[] args)throws IOException 
    {        
        double finalAnswer=-99;
        double finalShortPeriod=0;
        double finalLongPeriod=0;
        double finalPercDif=0;
        double[] PortfolioValue=new double[60*260];
        double[] BaseValue=new double[60*260];
         double[] Profit=new double[60*260];
        final XYSeriesCollection dataset = new XYSeriesCollection();
        
        for(int longPeriod=138;longPeriod<=138;longPeriod++){                     //70
            for(int shortPeriod =50;shortPeriod<=50;shortPeriod++){               //1 or 9                       
                for(int difPercent=985;difPercent<=999;difPercent++){  
                            double difpercent=(double)difPercent/10;
                            double answer=OptimiseParameters(shortPeriod,longPeriod,difpercent,PortfolioValue,BaseValue,Profit,dataset);
                            System.err.println(answer);
                            if(finalAnswer<answer){
                                
                                finalAnswer=answer;
                                finalShortPeriod=shortPeriod;
                                finalLongPeriod=longPeriod;
                                finalPercDif=difPercent;
                            }
                        }
                    }
                }
        
        System.out.println("The best parameters are : ");
        System.out.println("ShortPeriod : "+finalShortPeriod);
        System.out.println("LongPeriod : "+finalLongPeriod);
        System.out.println("PercentDifferenceNeeded : "+finalPercDif);
        System.out.println("The best effective annual return for these parameters is : "+finalAnswer);
        
        

    }