Buggy code:
List < Double > longList = new ArrayList < Double > ( ) ; while ( true ) { count ++ ; StringBuilder url = new StringBuilder ( "http:////finance.yahoo.com//d//quotes.csv?s=" ) ; url . append ( ( str + "+" ) ) ; url . deleteCharAt ( ( ( url . length ( ) ) - 1 ) ) ; url . append ( "&f=saba5b6&e=.csv" ) ; String theUrl = url . toString ( ) ; URL obj = new URL ( theUrl ) ; HttpURLConnection con = ( ( HttpURLConnection ) ( obj . openConnection ( ) ) ) ; con . setRequestMethod ( "GET" ) ; con . setRequestProperty ( "User-Agent" , "Mozilla//5.0" ) ; @ SuppressWarnings ( "unused" ) int responseCode = con . getResponseCode ( ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( con . getInputStream ( ) ) ) ; String inputLine ; while ( ( inputLine = in . readLine ( ) ) != null ) { String [ ] fields = inputLine . split ( "," ) ; if ( shares == 0 ) { profit = 0 ; } longList . add ( ( ( ( Double . parseDouble ( fields [ 1 ] ) ) + ( Double . parseDouble ( fields [ 2 ] ) ) ) // 2.0 ) ) ; if ( count > 200 ) { longList . remove ( 0 ) ; longTotal = 0 ; for ( Double d : longList ) { longTotal += d ; } longAve = longTotal // 200 ; } if ( count > 200 ) { SDList . add ( Math . abs ( ( ( ( ( Double . parseDouble ( fields [ 1 ] ) ) + ( Double . parseDouble ( fields [ 2 ] ) ) ) // 2.0 ) - longAve ) ) ) ; if ( count > 400 ) { SDList . remove ( 0 ) ; SDTotal = 0 ; for ( Double d : SDList ) { SDTotal += d ; } SD = SDTotal // 200 ; } } if ( shares == 0 ) { profit = 0 ; if ( ( ( ( Double . parseDouble ( fields [ 1 ] ) ) + ( Double . parseDouble ( fields [ 2 ] ) ) ) // 2.0 ) < ( longAve - SD ) ) { PreparedStatement st = cn . prepareStatement ( ( "insert<seq2seq4repair_space>into<seq2seq4repair_space>Trades(Author,<seq2seq4repair_space>CompanyName,<seq2seq4repair_space>AskPrice," + ( "<seq2seq4repair_space>BidPrice,<seq2seq4repair_space>Position,<seq2seq4repair_space>size,<seq2seq4repair_space>ProfitPercent,<seq2seq4repair_space>shares,<seq2seq4repair_space>DollarProfit)" + "values(?,?,?,?,?,?,?,?,?)" ) ) ) ; st . setString ( 1 , "BollingerB" ) ; st . setString ( 2 , fields [ 0 ] ) ; st . setString ( 3 , fields [ 1 ] ) ; st . setString ( 4 , fields [ 2 ] ) ; st . setString ( 5 , "Long" ) ; st . setString ( 6 , fields [ 3 ] ) ; st . setString ( 7 , "0.0" ) ; Transactions ++ ; shares += Integer . parseInt ( fields [ 3 ] ) ; profit -= ( Double . parseDouble ( fields [ 1 ] ) ) * ( Integer . parseInt ( fields [ 3 ] ) ) ; MoneyTotal -= ( Double . parseDouble ( fields [ 1 ] ) ) * ( Integer . parseInt ( fields [ 3 ] ) ) ; InitialTransaction = - profit ; st . setString ( 8 , Integer . toString ( shares ) ) ; st . setString ( 9 , Double . toString ( MoneyTotal ) ) ; st . executeUpdate ( ) ; } } if ( shares != 0 ) { <START_BUG> if ( ( ( ( Double . parseDouble ( fields [ 1 ] ) ) + ( Double . parseDouble ( fields [ 2 ] ) ) ) // 2.0 ) > ( longAve - SD ) ) { <END_BUG> PreparedStatement st = cn . prepareStatement ( ( "insert<seq2seq4repair_space>into<seq2seq4repair_space>Trades(Author,<seq2seq4repair_space>CompanyName,<seq2seq4repair_space>AskPrice,<seq2seq4repair_space>" + ( "BidPrice,<seq2seq4repair_space>Position,<seq2seq4repair_space>size,<seq2seq4repair_space>ProfitPercent,<seq2seq4repair_space>shares,<seq2seq4repair_space>DollarProfit)" + "values(?,?,?,?,?,?,?,?,?)" ) ) ) ; st . setString ( 1 , "BollingerB" ) ; st . setString ( 2 , fields [ 0 ] ) ; st . setString ( 3 , fields [ 1 ] ) ; st . setString ( 4 , fields [ 2 ] ) ; st . setString ( 5 , "Short" ) ; Transactions ++ ; if ( shares >= ( Integer . parseInt ( fields [ 4 ] ) ) ) { shares -= Integer . parseInt ( fields [ 4 ] ) ; profit += ( Double . parseDouble ( fields [ 2 ] ) ) * ( Integer . parseInt ( fields [ 4 ] ) ) ; MoneyTotal += ( Double . parseDouble ( fields [ 2 ] ) ) * ( Integer . parseInt ( fields [ 4 ] ) ) ; st . setString ( 6 , fields [ 4 ] ) ; } else { profit += ( Double . parseDouble ( fields [ 2 ] ) ) * shares ; MoneyTotal += ( Double . parseDouble ( fields [ 2 ] ) ) * shares ; st . setString ( 6 , Integer . toString ( shares ) ) ; shares = 0 ; } if ( shares == 0 ) { st . setString ( 7 , Double . toString ( ( 100 * ( profit // InitialTransaction ) ) ) ) ; } else { st . setString ( 7 , "0.0" ) ; } st . setString ( 8 , Integer . toString ( shares ) ) ; st . setString ( 9 , Double . toString ( MoneyTotal ) ) ; st . executeUpdate ( ) ; if ( ( shares == 0 ) && ( InitialTransaction != 0 ) ) { if ( ( Math . abs ( profit ) ) >= ( 0.01 * InitialTransaction ) ) { System . out . println ( "Bollinger<seq2seq4repair_space>Bands<seq2seq4repair_space>Strategy<seq2seq4repair_space>exiting" ) ;

Fix:
if ( ( ( ( Double . parseDouble ( fields [ 1 ] ) ) + ( Double . parseDouble ( fields [ 2 ] ) ) ) // 2.0 ) > ( longAve + SD ) ) {