protected override void OnStart()
        {
            // Initialize NEWS
            news = new List <string>();

            // initialize c-bot link
            botLink        = new cBotLink();
            botLink.SubKey = "Software\\cAlgo4u\\News Manager\\Alerts";

            // set up container for all paused robots
            pausedRobots = new List <cAlgo4u.Robot>();

            // iterate through enums
            CurrencyList = Enum.GetValues(typeof(Currencies));

            // reset the instrument flags to false, no news
            foreach (Currencies currency in CurrencyList)
            {
                botLink.Write(currency.ToString(), false);
            }

            if (IncludeNewsReleaseStop)
            {
                InitialiseNewsRelease();
            }

            // setup timer to invoke method each minute
            System.Timers.Timer aTimer = new System.Timers.Timer();
            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            aTimer.Interval = 60000;
            aTimer.Enabled  = true;

            Print(cAlgoVersion);
        }
        /// <summary>
        /// called every minute to check for news releases
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTimedEvent(object sender, ElapsedEventArgs e)
        {
            if (IncludeNewsReleaseStop)
            {
                // re-open any closed news items after the pause period
                foreach (var myBot in pausedRobots)
                {
                    // re-start robot if time is after paused time
                    if (LocalDateTime >= myBot.ReStartTime.AddMinutes(-1))
                    {
                        Print("** " + myBot.Currency + " **");
                        Print("ROBOT RESTARTED.");
                        botLink.Write(myBot.Currency, false);

                        Notifications.SendEmail(EmailFrom, EmailTo, "UPDATE: " + myBot.NewsEvent, "The news event is over and your cAlgo instance has started trading again.");

                        if (IncludePauseAllInstances)
                        {
                            foreach (Currencies currency in CurrencyList)
                            {
                                botLink.Write(currency.ToString(), false);
                            }

                            pausedRobots.Clear();
                            break;
                        }

                        // remove old news item from list
                        pausedRobots.Remove(myBot);
                        break;
                    }
                }

                // close only trades that relate to the currency a news release relates to.
                if (fxNews.IsSuccess)
                {
                    try
                    {
                        string message = string.Empty;

                        foreach (NewsItem item in fxNews.NewsItems)
                        {
                            DateTime timeBeforeNews = item.UtcDateTime.AddMinutes(-MinsB4News);
                            DateTime localTime      = LocalDateTime;

                            // if past news continue
                            if (localTime > item.UtcDateTime)
                            {
                                continue;
                            }

                            // is there a robot for this currency already paused?
                            var botExists = pausedRobots.Where(x => x.Currency == item.Currency).SingleOrDefault();

                            // has news release occurred
                            if (localTime >= timeBeforeNews && localTime < item.UtcDateTime && botExists == null)
                            {
                                Print("");

                                Print("NEWS RELEASE IN " + MinsB4News.ToString() + " MINUTES.");
                                Print(item.Event);

                                // if user wants all instances to pause
                                if (IncludePauseAllInstances)
                                {
                                    foreach (Currencies currency in CurrencyList)
                                    {
                                        // Stop robots from opening any new trades
                                        botLink.Write(currency.ToString(), true);

                                        // store information about the paused robot and add to list of other robots paused.
                                        cAlgo4u.Robot cBot = new cAlgo4u.Robot(item.UtcDateTime, MinsReStart, currency.ToString(), item.Event);

                                        // add to list
                                        pausedRobots.Add(cBot);
                                    }
                                }
                                else
                                {
                                    // only stop individual currency
                                    botLink.Write(item.Currency, true);

                                    // store information about the paused robot and add to list of other robots paused.
                                    cAlgo4u.Robot cBot = new cAlgo4u.Robot(item.UtcDateTime, MinsReStart, item.Currency, item.Event);

                                    // add to list
                                    pausedRobots.Add(cBot);
                                }

                                if (IncludeEmail)
                                {
                                    message  = "NEWS EVENT OCCURRING AT " + item.UtcDateTime.ToShortTimeString();
                                    message += "\n\n" + item.Event;
                                    message += "\n\nVolatility: " + item.Importance.ToString().ToUpper();
                                    message += "\nAll currency pairs with " + item.Currency.ToUpper() + " will stop trading and positions will close.";
                                    message += "\nNews event will occur in " + MinsB4News.ToString() + " minutes.";
                                    message += "\nCurrency pairs will be paused for " + MinsReStart.ToString() + " minutes after the news event has occurred.";

                                    Notifications.SendEmail(EmailFrom, EmailTo, "WARNING: " + item.Event, message);
                                }
                            }
                        }
                    } catch (Exception er)
                    {
                        Print("Error occurred shutting down during a news release: " + er.InnerException.ToString());
                    }
                }
            }
        }