Beispiel #1
0
        private void HandleAlerts(bool isBullish, int index)
        {
            // Make sure the alert will only be triggered in Real Time and ensure we haven't triggered already because this is called every tick
            if (IsBacktesting || !IsLastBar || _lastAlertBarIndex == index)
            {
                return;
            }

            _lastAlertBarIndex = index;
            if (SendEmailAlerts)
            {
                var subject = string.Format("{0} MA Cross formed on {1} {2}",
                                            isBullish ? "Bullish" : "Bearish",
                                            Symbol.Name,
                                            Bars.TimeFrame);

                Notifications.SendEmail("*****@*****.**", "*****@*****.**", subject, string.Empty);
            }

            if (PlayAlertSound)
            {
                Notifications.PlaySound(@"c:\windows\media\ring03.wav");
            }

            if (ShowMessage)
            {
                AlertService.SendAlert(new Alert("MA Cross Over", Symbol.Name, Bars.TimeFrame.ToString()));
            }
        }
Beispiel #2
0
        private void HandleAlerts()
        {
            // Make sure the email will be sent only at RealTime
            if (IsBacktesting || !IsLastBar)
            {
                return;
            }

            if (SendEmailAlerts)
            {
                var subject = string.Format("Spring formed on {0} {1}",
                                            Symbol.Name,
                                            Bars.TimeFrame);

                Notifications.SendEmail("*****@*****.**", "*****@*****.**", subject, string.Empty);
            }

            if (PlayAlertSound)
            {
                Notifications.PlaySound(@"c:\windows\media\ring03.wav");
            }

            if (ShowMessage)
            {
                AlertService.SendAlert(new Alert("Spring", Symbol.Name, Bars.TimeFrame.ToString()));
            }
        }
        public async Task SendAlert_Should_SendNewAlert(string message, bool confirmation, Icon icon)
        {
            //arrange
            Alert actual   = null;
            var   notifier = new Mock <IAlertNotifier>();

            notifier.Setup(n => n.Notify(It.IsAny <Alert>())).Callback <Alert>(a => actual = a);
            var service = new AlertService(notifier.Object);

            //act
            await service.SendAlert(message, confirmation, icon);

            //assert
            actual.Should().NotBeNull();
            actual.Message.Should().BeEquivalentTo(message);
            actual.NeedsConfirmation.Should().Be(confirmation);
            actual.Icon.Should().Be(icon);
        }