public static void Interval() { int topThreshold = 110; int botThreshold = 855; img bitmapClass = new img(topThreshold, botThreshold); bitmapClass.screenshot(); using (Bitmap bmp = new Bitmap("screen.bmp")) { var scanning = bitmapClass.scanning(bmp); if (counter == 0) { previous = scanning; Console.WriteLine("First Initate initial state :{0}", previous); } else { if (scanning == "B" && previous != "B") { Console.WriteLine("Statechange from {0} to {1} BUY Signal", previous, scanning); Connect con = new Connect(1); previous = scanning; } else if (scanning == "S" && previous != "S") { Console.WriteLine("Statechange from {0} to {1} SELL signal", previous, scanning); Connect con = new Connect(2); previous = scanning; } } } counter++; }