Esempio n. 1
0
        protected override void OnCalculate()
        {
            _orb_indicator.calculate(this.Bars, this.Bars[0]);
            //Occurred.Set(returnvalue);
            //Entry.Set(Bars[0].Close);

            //If there was a breakout and the current bar is the same bar as the long/short breakout, then trigger signal.
            if (_orb_indicator.LongBreakout != null && _orb_indicator.LongBreakout.Time == Bars[0].Time)
            {
                //Long Signal
                Occurred.Set(1);
                //Entry.Set(Close[0]);
            }
            else if (_orb_indicator.ShortBreakout != null && _orb_indicator.ShortBreakout.Time == Bars[0].Time)
            {
                //Short Signal
                Occurred.Set(-1);
                //Entry.Set(Close[0]);
            }
            else
            {
                //No Signal
                Occurred.Set(0);
                //Entry.Set(Close[0]);
            }
        }
        protected override void OnBarUpdate()
        {
            if (Bars != null && Bars.Count > 0 &&
                TimeFrame.Periodicity == DatafeedHistoryPeriodicity.Minute &&
                TimeFrame.PeriodicityValue == 1)
            {
            }
            else
            {
                return;
            }

            if (DummyOneMinuteEven_Indicator()[0] == 100)
            {
                Occurred.Set(-1);
            }
            else
            {
                Occurred.Set(1);
            }

            //Entry.Set(iv_Bars.GetOpen(iv_CurrentBar));
            //Entry.Set(10390);
            //Entry.Set(GetCurrentBid());
        }
        protected override void OnBarUpdate()
        {
            //calculate data
            OrderAction?resultdata = this._Mean_Reversion_Indicator.calculate(Input, Open, High, null, null, this.Bollinger_Period, this.Bollinger_Standard_Deviation, this.Momentum_Period, this.RSI_Period, this.RSI_Smooth, this.RSI_Level_Low, this.RSI_Level_High, this.Momentum_Level_Low, this.Momentum_Level_High);

            if (resultdata.HasValue)
            {
                switch (resultdata)
                {
                case OrderAction.Buy:
                    Occurred.Set(1);
                    //Entry.Set(Input[0]);
                    break;

                case OrderAction.SellShort:
                    Occurred.Set(-1);
                    //Entry.Set(Input[0]);
                    break;

                //case OrderAction.BuyToCover:
                //    break;
                //case OrderAction.Sell:
                //    break;
                default:
                    //nothing to do
                    Occurred.Set(0);
                    //Entry.Set(Input[0]);
                    break;
                }
            }
            else
            {
                Occurred.Set(0);
            }
        }
		protected override void OnCalculate()
		{
            EMA ema = EMA(this.Period);
            double bull_power = High[0] - ema[0];
            double bear_power = Low[0] - ema[0];
            ds_bull_power.Set(bull_power);
            ds_bear_power.Set(bear_power);

            int resultsignal = 0;
            if (ema[0] > ema[1] && bear_power < 0 && bear_power > ds_bear_power.Get(1))
            {
                resultsignal = 1;
            }

            if (ema[0] < ema[1] && bull_power > 0 && bull_power < ds_bull_power.Get(1))
            {
                resultsignal = -1;
            }

            Occurred.Set(resultsignal);

            PlotColors[0][0] = this.Plot0Color;
            OutputDescriptors[0].PenStyle = this.Dash0Style;
            OutputDescriptors[0].Pen.Width = this.Plot0Width;

            PlotColors[1][0] = this.Plot1Color;
            OutputDescriptors[1].PenStyle = this.Dash1Style;
            OutputDescriptors[1].Pen.Width = this.Plot1Width;
        }
        protected override void OnBarUpdate()
        {
            //calculate data
            OrderAction?resultdata = this._RunningWithTheWolves_Indicator.calculate(Input);

            if (resultdata.HasValue)
            {
                switch (resultdata)
                {
                case OrderAction.Buy:
                    Occurred.Set(1);
                    //Entry.Set(Input[0]);
                    break;

                case OrderAction.SellShort:
                    Occurred.Set(-1);
                    //Entry.Set(Input[0]);
                    break;

                //case OrderAction.BuyToCover:
                //    break;
                //case OrderAction.Sell:
                //    break;
                default:
                    //nothing to do
                    Occurred.Set(0);
                    //Entry.Set(Input[0]);
                    break;
                }
            }
            else
            {
                Occurred.Set(0);
            }
        }
Esempio n. 6
0
        public void Load_RequestForLoadSetting_LoadSettings()
        {
            var accountSettingsStub = new[]
            {
                new AccountSettingsItem()
                {
                    Login = expectedLogin, ServerName = expectedServerName, Token = expectedToken
                },
            };

            _mockAccountSettings.SetupGet(settings => settings.LoadAccounts()).Returns(accountSettingsStub);


            _accountRegistry = new AccountRegistry(_mockAccountSettings.Object, _accountContainerStub);

            _accountRegistry.LoadedEvent += (o, e) =>
            {
                Assert.IsNotNull(e.Accounts);
                Assert.AreEqual(e.Accounts.Length, 1);
                _mockAccount.Verify(acc => acc.LoadConnector(expectedServerName), Occurred.Once());
                _mockAccount.VerifySet(acc => acc.Login, expectedLogin, Occurred.Once());
                _mockAccount.VerifySet(acc => acc.Token, expectedToken, Occurred.Once());
                Assert.AreEqual(e.Size, expectedSize);
            };
            _accountRegistry.Load();
        }
Esempio n. 7
0
        protected override void OnCalculate()
        {
            //calculate data
            ResultValue returnvalue = this._TrendTemplate_MarkMinervini_Indicator.calculate(this.InSeries);

            //If the calculate method was not finished we need to stop and show an alert message to the user.
            if (returnvalue.ErrorOccured)
            {
                //Display error just one time
                if (!this.ErrorOccured)
                {
                    Log(this.DisplayName + ": " + Const.DefaultStringErrorDuringCalculation, InfoLogLevel.AlertLog);
                    this.ErrorOccured = true;
                }
                return;
            }


            //Entry
            if (returnvalue.Entry.HasValue)
            {
                switch (returnvalue.Entry)
                {
                case OrderDirection.Buy:
                    Occurred.Set(1);
                    break;
                }
            }
            else
            {
                Occurred.Set(0);
            }
        }
Esempio n. 8
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (eventId_ != null)
            {
                hash ^= EventId.GetHashCode();
            }
            if (source_ != null)
            {
                hash ^= Source.GetHashCode();
            }
            if (correlationId_ != null)
            {
                hash ^= CorrelationId.GetHashCode();
            }
            if (artifact_ != null)
            {
                hash ^= Artifact.GetHashCode();
            }
            if (Occurred != 0L)
            {
                hash ^= Occurred.GetHashCode();
            }
            if (originalContext_ != null)
            {
                hash ^= OriginalContext.GetHashCode();
            }
            return(hash);
        }
Esempio n. 9
0
        public void Find_RequestForFindAccount_FindAccount()
        {
            var accountSettingsStub = new[]
            {
                new AccountSettingsItem()
                {
                    Login = expectedLogin, ServerName = expectedServerName, Token = expectedToken
                },
                new AccountSettingsItem()
                {
                    Login = "******", ServerName = "Tandex", Token = "9875452"
                },
            };

            _mockAccountSettings.SetupGet(settings => settings.LoadAccounts()).Returns(accountSettingsStub);


            _accountRegistry = new AccountRegistry(_mockAccountSettings.Object, _accountContainerStub);

            _accountRegistry.Load();

            IAccountProjection accountFound = _accountRegistry.Find(expectedLogin);

            _mockAccount.VerifySet(acc => acc.Login, expectedLogin, Occurred.Once());
            _mockAccount.VerifySet(acc => acc.Token, expectedToken, Occurred.Once());
            Assert.AreEqual(expectedLogin, accountFound.Login);
            Assert.AreEqual(expectedServerName, accountFound.ServerName);
            Assert.AreEqual(expectedToken, accountFound.Token);
            Assert.IsNotNull(accountFound);
        }
        protected override void OnCalculate()
        {
            //calculate data
            OrderDirection_Enum?resultdata = this._RunningWithTheWolves_Indicator.calculate(InSeries, this.MA_Selected, this.MA_Fast, this.MA_Medium, this.MA_Slow);

            if (resultdata.HasValue)
            {
                switch (resultdata)
                {
                case OrderDirection_Enum.OpenLong:
                    Occurred.Set(1);
                    //Entry.Set(InSeries[0]);
                    break;

                case OrderDirection_Enum.OpenShort:
                    Occurred.Set(-1);
                    //Entry.Set(InSeries[0]);
                    break;

                //case OrderDirection.Buy:
                //    break;
                //case OrderDirection.Sell:
                //    break;
                default:
                    //nothing to do
                    Occurred.Set(0);
                    //Entry.Set(InSeries[0]);
                    break;
                }
            }
            else
            {
                Occurred.Set(0);
            }
        }
Esempio n. 11
0
        public DateTime GetRoundedTime()
        {
            DateTime rounded;

            rounded = Occurred.Floor(TimeSpan.FromMinutes(1));

            return(rounded);
        }
Esempio n. 12
0
        public async Task Update_RequestForUpdate_GetNewInfo()
        {
            _mockService.Setup(fileStorage => fileStorage.Update()).Returns(Task.Run(() => { }));

            await _account.Update();

            _mockService.Verify(fileStorage => fileStorage.Update(), Occurred.Once());
        }
Esempio n. 13
0
        public async Task SignOut_RequestForSignOut_DeleteToken()
        {
            _mockService.Setup(fileStorage => fileStorage.SignOut()).Returns(Task.Run(() => { }));

            await _account.SignOut();

            _mockService.Verify(fileStorage => fileStorage.SignOut(), Occurred.Once());
        }
Esempio n. 14
0
        public async Task SignIn_RequestForSignIn_GetToken()
        {
            string token = "simpleToken";

            _mockService.Setup(fileStorage => fileStorage.SignIn(token)).Returns(Task.Run(() => { }));

            await _account.SignIn(token);

            _mockService.Verify(fileStorage => fileStorage.SignIn(token), Occurred.Once());
        }
Esempio n. 15
0
        public void RaisedEventDoesNotInvokeDettachedSubjectHandler()
        {
            var proxy = Mock.Create <IThermostatService>();

            proxy.Setup(p => p.SwitchOn());
            // ReSharper disable once UnusedVariable
            var controller = new ThemostatController(proxy);

            proxy.Raise(p => p.Cold += null, new EventArgs());

            proxy.Verify(p => p.SwitchOn(), Occurred.Never());
        }
Esempio n. 16
0
        public async Task VerifyMatchesExpectedSingleVisitAsync()
        {
            var proxy = Mock.Create <IUserService>();

            proxy.Setup(p => p.DeleteAsync("Homer")).Returns(Task.Delay(0));

            var controller = new UserController(proxy);

            await controller.DeleteAsync("Homer");

            proxy.Verify(p => p.DeleteAsync("Homer"), Occurred.Once());
        }
Esempio n. 17
0
        public void VerifyMatchesExpectedSingleVisit()
        {
            var proxy = Mock.Create <IUserService>();

            proxy.Setup(p => p.Delete("Homer"));

            var controller = new UserController(proxy);

            controller.Delete("Homer");

            proxy.Verify(p => p.Delete("Homer"), Occurred.Once());
        }
Esempio n. 18
0
        public void VerifyMatchesExpectedSingleVisit()
        {
            var proxy = Mock.Create <IUserService>();

            proxy.Setup(p => p.Save("Bart")).Returns(true);

            var controller = new UserController(proxy);

            controller.Save("Bart");

            proxy.Verify(p => p.Save("Bart"), Occurred.Once());
        }
Esempio n. 19
0
        public void VerifyMatchesSingleVisitForAnyParameter()
        {
            var proxy = Mock.Create <IUserService>();

            proxy.Setup(p => p.Delete(Param.IsAny <string>()));

            var controller = new UserController(proxy);

            controller.Delete("Homer");

            proxy.Verify(p => p.Delete(Param.IsAny <string>()), Occurred.Once());
        }
        protected override void OnCalculate()
        {
            Occurred.Set(LeadIndicator.Lonely_Warrior_Indicator()[0]);

            PlotColors[0][0] = this.Plot0Color;
            OutputDescriptors[0].PenStyle  = this.Dash0Style;
            OutputDescriptors[0].Pen.Width = this.Plot0Width;

            PlotColors[1][0] = this.Plot1Color;
            OutputDescriptors[1].PenStyle  = this.Dash1Style;
            OutputDescriptors[1].Pen.Width = this.Plot1Width;
        }
Esempio n. 21
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Provenance;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Target != null)
            {
                dest.Target = new List <Hl7.Fhir.Model.ResourceReference>(Target.DeepCopy());
            }
            if (Occurred != null)
            {
                dest.Occurred = (Hl7.Fhir.Model.DataType)Occurred.DeepCopy();
            }
            if (RecordedElement != null)
            {
                dest.RecordedElement = (Hl7.Fhir.Model.Instant)RecordedElement.DeepCopy();
            }
            if (PolicyElement != null)
            {
                dest.PolicyElement = new List <Hl7.Fhir.Model.FhirUri>(PolicyElement.DeepCopy());
            }
            if (Location != null)
            {
                dest.Location = (Hl7.Fhir.Model.ResourceReference)Location.DeepCopy();
            }
            if (Reason != null)
            {
                dest.Reason = new List <Hl7.Fhir.Model.CodeableConcept>(Reason.DeepCopy());
            }
            if (Activity != null)
            {
                dest.Activity = (Hl7.Fhir.Model.CodeableConcept)Activity.DeepCopy();
            }
            if (Agent != null)
            {
                dest.Agent = new List <Hl7.Fhir.Model.Provenance.AgentComponent>(Agent.DeepCopy());
            }
            if (Entity != null)
            {
                dest.Entity = new List <Hl7.Fhir.Model.Provenance.EntityComponent>(Entity.DeepCopy());
            }
            if (Signature != null)
            {
                dest.Signature = new List <Hl7.Fhir.Model.Signature>(Signature.DeepCopy());
            }
            return(dest);
        }
Esempio n. 22
0
        public void WriteData_With3_ShouldSave8()
        {
            // Arrange
            var input = 3;

            // Act
            _underTest.WriteData(input);

            // Assert
            var expected = 8;

            _dataStore.Verify(x => x.SaveData(expected), Occurred.Once());
        }
Esempio n. 23
0
        public void VerifyMatchesExpectedZeroVisits()
        {
            var proxy = Mock.Create <IUserService>();

            proxy.Setup(p => p.Save("Bart")).Returns(true);
            proxy.Setup(p => p.Save("Marge")).Returns(false);

            var controller = new UserController(proxy);

            controller.Save("Bart");

            proxy.Verify(p => p.Save("Marge"), Occurred.Never());
        }
Esempio n. 24
0
        public void RaisedEventPassesParameters()
        {
            const int temp  = 100;
            var       proxy = Mock.Create <IThermostatService>();

            proxy.Setup(p => p.ChangeTemp(temp));
            // ReSharper disable once UnusedVariable
            var controller = new ThemostatController(proxy);

            proxy.Raise(p => p.TempChanged += null, new TempChangedEventArgs(temp));

            proxy.Verify(p => p.ChangeTemp(temp), Occurred.Once());
        }
Esempio n. 25
0
        public void VerifyMatchesExpectedZeroVisits()
        {
            var proxy = Mock.Create <IUserService>();

            proxy.Setup(p => p.Delete("Homer"));
            proxy.Setup(p => p.Delete("Marge"));

            var controller = new UserController(proxy);

            controller.Delete("Homer");

            proxy.Verify(p => p.Delete("Marge"), Occurred.Never());
        }
        protected override void OnCalculate()
        {
            //Reset color
            _signalcolor = Color.Transparent;

            if (ProcessingBarIndex == 0)
            {
                lastsignals = new Stack <DateTime>();
            }

            bool therewasasignal = false;

            //if (Low[0] < SMA(200)[0] && SMA(50)[0] >= SMA(100)[0] && SMA(100)[0] >= SMA(200)[0]  && Close[0] > SuperTrend(SuperTrendMAType.HMA, SuperTrendMode.ATR, 14, 2.618, 14).UpTrend[0])
            //if (Low[0] < SMA(200)[0] && SMA(50)[0] >= SMA(100)[0] && Close[0] > SuperTrend(SuperTrendMAType.HMA, SuperTrendMode.ATR, 14, 2.618, 14).UpTrend[0])
            //if (Low[0] < SMA(200)[0] && SMA(50)[0] >= SMA(100)[0] && Close[0] > SuperTrend(SuperTrendMAType.SMA, SuperTrendMode.ATR, 50, 2.618, 50).UpTrend[0])
            if (Low[0] < SMA(this.MA_Long)[0] && SMA(this.MA_Short)[0] >= SMA(this.MA_Medium)[0] &&
                Close[0] > SuperTrend(SuperTrendMAType.SMA, SuperTrendMode.ATR, 200, 2.618, 200).UpTrend[0])
            {
                therewasasignal = true;
            }
            double thevalue = 0;

            if (therewasasignal)
            {
                thevalue     = 1;
                _signalcolor = Color.LightGreen;
                AddChartArrowUp("ArrowLong_Entry" + +Bars[0].Time.Ticks, this.IsAutoAdjustableScale, 0, Bars[0].Low, Color.Green);
                lastsignals.Push(Time[0]);
            }
            else
            {
                if (lastsignals != null && lastsignals.Count > 0 && lastsignals.Peek() >= Time[this.Candles - 1])
                {
                    AddChartArrowUp("ArrowLong_Echo_Entry" + +Bars[0].Time.Ticks, this.IsAutoAdjustableScale, 0, Bars[0].Low, Color.LightGreen);
                    thevalue     = 0.5;
                    _signalcolor = Color.Green;
                }
            }



            Occurred.Set(thevalue);

            PlotColors[0][0] = this.Plot0Color;
            OutputDescriptors[0].PenStyle  = this.Dash0Style;
            OutputDescriptors[0].Pen.Width = this.Plot0Width;

            PlotColors[1][0] = this.Plot1Color;
            OutputDescriptors[1].PenStyle  = this.Dash1Style;
            OutputDescriptors[1].Pen.Width = this.Plot1Width;
        }
Esempio n. 27
0
        protected override void OnCalculate()
        {
            //get the indicator
            Example_Indicator_SMA_CrossOver_Basic Example_Indicator_SMA_CrossOver_Basic = LeadIndicator.Example_Indicator_SMA_CrossOver_Basic();

            //get the value
            double returnvalue = Example_Indicator_SMA_CrossOver_Basic[0];

            //Condition should be drawn on a seperate panel
            this.IsOverlay = false;

            //set the value
            Occurred.Set(returnvalue);
        }
Esempio n. 28
0
        protected override void OnCalculate()
        {
            //Check if peridocity is valid for this script
            if (!this._Example_Indicator_SMA_CrossOver_Advanced.DatafeedPeriodicityIsValid(Bars.TimeFrame))
            {
                Log(this.DisplayName + ": Periodicity of your data feed is suboptimal for this indicator!", InfoLogLevel.AlertLog);
                return;
            }

            //Lets call the calculate method and save the result with the trade action
            ResultValue_Example_Indicator_SMA_CrossOver_Advanced returnvalue = this._Example_Indicator_SMA_CrossOver_Advanced.calculate(this.InSeries, this.FastSma, this.SlowSma, this.IsLongEnabled, this.IsShortEnabled);

            //If the calculate method was not finished we need to stop and show an alert message to the user.
            if (returnvalue.ErrorOccured)
            {
                Log(this.DisplayName + ": A problem has occured during the calculation method!", InfoLogLevel.AlertLog);
                return;
            }

            //Entry
            if (returnvalue.Entry.HasValue)
            {
                switch (returnvalue.Entry)
                {
                case OrderAction.Buy:
                    //Long Signal
                    Occurred.Set(1);
                    Entry.Set(1);
                    break;

                case OrderAction.SellShort:
                    //Short Signal
                    Occurred.Set(-1);
                    Entry.Set(-1);
                    break;
                }
            }
            else
            {
                //No Signal
                Occurred.Set(0);
                Entry.Set(0);
            }

            //Set the drawing style, if the user has changed it.
            PlotColors[0][0]   = this.Plot0Color;
            Plots[0].PenStyle  = this.Dash0Style;
            Plots[0].Pen.Width = this.Plot0Width;
        }
Esempio n. 29
0
        protected override void OnCalculate()
        {
            //Print(Time[0]);

            TimeSpan now = Time[0].TimeOfDay;

            if ((now >= TimeSpan.Parse(this.Start)) && (now <= TimeSpan.Parse(this.End)))
            {
                Occurred.Set(0);
            }
            else
            {
                Occurred.Set(1);
            }
        }
Esempio n. 30
0
        protected override void OnCalculate()
        {
            double rv = 0;

            if (LeadIndicator.Holy_Grail_Indicator(this.InSeries)[0] > 0 && LeadIndicator.Holy_Grail_Indicator(this.InSeries)[1] > 0 && LeadIndicator.Holy_Grail_Indicator(this.InSeries)[3] > 0)
            {
                rv = 1;
            }


            Occurred.Set(rv);

            PlotColors[0][0] = this.Plot0Color;
            OutputDescriptors[0].PenStyle  = this.Dash0Style;
            OutputDescriptors[0].Pen.Width = this.Plot0Width;
        }