private void CollapseAll_Click(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (TabGeneral.IsSelected) { General.CollapseAllGroups(); } else if (TabCroissance.IsSelected) { Croissance.CollapseAllGroups(); } else if (TabValorisation.IsSelected) { Valorisation.CollapseAllGroups(); } else if (TabMomentum.IsSelected) { Momentum.CollapseAllGroups(); } else if (TabQuality.IsSelected) { Quality.CollapseAllGroups(); } else if (TabSynthese.IsSelected) { Synthese.CollapseAllGroups(); } }
/// <summary> /// Initializes a new instance of the <see cref="ITrendStrategy"/> class. /// </summary> /// <param name="period">The period of the Instantaneous trend.</param> public MultiSymbolStrategy(Indicator price, int period, decimal tolerance = 0.001m, decimal revetPct = 1.0015m, RevertPositionCheck checkRevertPosition = RevertPositionCheck.vsTrigger) { _price = price; sma = new SimpleMovingAverage(period).Of(price); SMAMomentum = new Momentum(2).Of(sma); MomentumWindow = new RollingWindow <decimal>(2); Position = StockState.noInvested; EntryPrice = null; ActualSignal = OrderSignal.doNothing; _tolerance = tolerance; _revertPCT = revetPct; _checkRevertPosition = checkRevertPosition; SMAMomentum.Updated += (object sender, IndicatorDataPoint updated) => { if (SMAMomentum.IsReady) { MomentumWindow.Add(SMAMomentum.Current.Value); } if (MomentumWindow.IsReady) { CheckSignal(); } }; }
} // true - если объект успешно добавлен, false - в противном случае // Конструктор класса окна добавления объекта. // Принимает как аргумент окно демонстрации public AddObject(Momentum momentum) { InitializeComponent(); this.momentum = momentum; InitCharacteristics(); InitTextBoxes(); }
private Stock_Report GetStockReportData(Stock stock) { try { List <Candel> candels = stock.Stock_Quote.Select(sq => new Candel() { Date = sq.date_round, Close = sq.closing, Maximun = sq.maximun, Minimun = sq.minimun, Open = sq.opening, Visible = true, Volume = (double)sq.volume }).ToList(); if (candels.Any()) { MA ma20 = new MA(candels, 20, ""); MA ma50 = new MA(candels, 50, ""); MA ma200 = new MA(candels, 200, ""); EMA ema12 = new EMA(candels, 12, "", false); EMA ema20 = new EMA(candels, 20, "", false); EMA ema26 = new EMA(candels, 26, "", false); RSI rsi14 = new RSI(candels, 14, 0, 0, "", ""); Momentum momentum12 = new Momentum(candels, 12, "", ""); StochasticOscillatorFast soFast = new StochasticOscillatorFast(candels, 14, 0, 0, "", "", ""); MACD macd1226 = new MACD(candels, 12, 26, 9, "", ""); BoolingerBands boolinger20 = new BoolingerBands(candels, 20, ""); WilliansR williansr14 = new WilliansR(candels, 14, 0, 0, "", "", ""); Stock_Report result = new Stock_Report(); result.Stock_ID = stock.Id; result.Price = stock.Stock_Quote.Last().closing; result.Date_Round = stock.Stock_Quote.Last().date_round; result.MA20 = ma20.Series[0].Data.Last().Value; result.MA50 = ma50.Series[0].Data.Last().Value; result.MA200 = ma200.Series[0].Data.Last().Value; result.RSI14 = rsi14.Series[0].Data.Last().Value; result.Momentum12 = momentum12.Series[0].Data.Last().Value; result.SOFast_k14 = (soFast.Series[0].Data.Any()) ? soFast.Series[0].Data.Last().Value : 0; result.SOFast_d3 = (soFast.Series[1].Data.Any()) ? soFast.Series[1].Data.Last().Value : 0; result.EMA12 = ema12.Series[0].Data.Last().Value; result.EMA26 = ema26.Series[0].Data.Last().Value; result.MACD2612 = macd1226.Series[0].Data.Last().Value; result.MA9 = macd1226.Series[1].Data.Last().Value; result.EMA20 = ema20.Series[0].Data.Last().Value; result.BoolUP = boolinger20.Series[1].Data.Last().Value; result.BoolLOW = boolinger20.Series[2].Data.Last().Value; result.WilliansR = (williansr14.Series[0].Data.Any()) ? williansr14.Series[0].Data.Last().Value : 0; return(result); } return(null); } catch (Exception ex) { throw ex; } }
public void VerifyAllEnums() { var acceleration = new Acceleration(1, AccelerationUnit.BaseUnit); var angle = new Angle(1, AngleUnit.BaseUnit); var angularAcceleration = new AngularAcceleration(1, AngularAccelerationUnit.BaseUnit); var area = new Area(1, AreaUnit.BaseUnit); var density = new MassDensity(1, MassDensityUnit.BaseUnit); var electricCurrent = new ElectricCurrent(1, ElectricCurrentUnit.BaseUnit); var electricResistance = new ElectricResistance(1, ElectricResistanceUnit.BaseUnit); var electricVoltage = new ElectricPotential(1, ElectricPotentialUnit.BaseUnit); var energy = new Energy(1, EnergyUnit.BaseUnit); var force = new Force(1, ForceUnit.BaseUnit); var frequency = new Frequency(1, FrequencyUnit.BaseUnit); var jerk = new Jerk(1, JerkUnit.BaseUnit); var length = new Length(1, LengthUnit.BaseUnit); var mass = new Mass(1, MassUnit.BaseUnit); var massFlowRate = new MassFlowRate(1, MassFlowRateUnit.BaseUnit); var momentum = new Momentum(1, MomentumUnit.BaseUnit); var numeric = new Numeric(1, NumericUnit.BaseUnit); var power = new Power(1, PowerUnit.BaseUnit); var pressure = new Pressure(1, PressureUnit.BaseUnit); var speed = new Speed(1, SpeedUnit.BaseUnit); var temperature = new Temperature(1, TemperatureUnit.BaseUnit); var time = new Time(1, TimeUnit.BaseUnit); var torque = new Torque(1, TorqueUnit.BaseUnit); var volume = new Volume(1, VolumeUnit.BaseUnit); var volumetricFlowRate = new VolumetricFlowRate(1, VolumetricFlowRateUnit.BaseUnit); }
public override Advice GetActionForBuckets(List <TradeBucket> tradeBuckets) { Advice advice = new Advice(); advice.AlgorithmName = Name; advice.Confidence = 0; advice.Group = Group; advice.Time = tradeBuckets[tradeBuckets.Count - 1].Time; List <TradeBucket> buckets = tradeBuckets; Momentum rsi = new Momentum(); TIOutput output = rsi.GetCurrentValue(buckets); advice.Price = buckets[buckets.Count - 1].Close; advice.Confidence = (decimal)output.Value; if (output.Value > 2) { advice.Action = TradeAction.Sell; } else if (output.Value < -2.5) { advice.Action = TradeAction.Buy; } else { advice.Action = TradeAction.Hold; } return(advice); }
/// <summary> /// In this function we do all the work and send back the OrderAction. /// </summary> /// <param name="data"></param> /// <returns></returns> public OrderAction?calculate(IDataSeries data, IDataSeries open, IDataSeries high, IOrder longorder, IOrder shortorder, int bollinger_period, double bollinger_standarddeviation, int momentum_period, int rsi_period, int rsi_smooth, int rsi_level_low, int rsi_level_high, int momentum_level_low, int momentum_level_high) { //Calculate BB Bollinger bb = Bollinger(data, bollinger_standarddeviation, bollinger_period); Momentum mom = Momentum(data, momentum_period); RSI rsi = RSI(data, rsi_period, rsi_smooth); bb_lower = bb.Lower[0]; bb_middle = bb.Middle[0]; bb_upper = bb.Upper[0]; //if (high[0] > open[1]) //{ if (mom[0] >= momentum_level_high && rsi[0] <= rsi_level_low && data[0] <= bb.Lower[0] && data[1] <= bb.Lower[1] && data[2] <= bb.Lower[2]) { return(OrderAction.Buy); } else if (mom[0] <= momentum_level_low && rsi[0] >= rsi_level_high && data[0] >= bb.Upper[0] && data[1] >= bb.Upper[1] && data[2] >= bb.Upper[2]) { return(OrderAction.SellShort); } else if (data[0] >= bb.Upper[0] && longorder != null) { //currently we left the building on the upper band, is it better if we switch to a stop? return(OrderAction.Sell); } else if (data[0] <= bb.Lower[0] && shortorder != null) { return(OrderAction.BuyToCover); } //} return(null); }
public void CreateMomentum(string cultureName, SourceType sourceType, MomentumType momentumType, ExtendedDate tempus, string[] resourceKeys) { Momentum newMomentum = new Momentum(); newMomentum.SourceType = sourceType; newMomentum.Tempus = tempus; newMomentum.Type = momentumType; //newMomentum.Resources = resources; List <MomentumResource> resourceList = new List <MomentumResource>(); foreach (string key in resourceKeys) { //_resourceService.CreateOrUpdate() resourceList.Add(new MomentumResource() { CulturedMediaKey = key }); } newMomentum.Resources = resourceList; //newMomentum.State = Infrastructure.Domain.Models.EntityState.Added; _unitOfWork.MomentumRepository.Add(newMomentum); _unitOfWork.Commit(); }
public MomentumProFunctionChart(ChartView BaseChart) { line1 = new Line(); line2 = new Line(); momentum = new Momentum(); var = new Variables.Variables(); BaseChart.Chart.Title.Text = "Momentum"; BaseChart.Chart.Axes.Left.Automatic = true; BaseChart.Chart.Axes.Bottom.Automatic = true; BaseChart.Chart.Axes.Left.Ticks.Transparency = 100; FillSampleValues(line1, 30, 600); line1.Color = var.GetPaletteBasic[0]; line1.LinePen.Width = 3; line1.Pointer.Visible = true; line1.Title = "Data Source"; line2.LinePen.Width = 3; line2.DataSource = line1; line2.Function = momentum; line2.Title = "Momentum"; line2.Color = var.GetPaletteBasic[1]; momentum.Period = 10; BaseChart.Chart.Series.Add(line1); BaseChart.Chart.Series.Add(line2); }
protected void CalculateIndicators() { // Init indicators momentumSeries = Momentum.Series(Close, momentumPeriod.ValueInt); DataSeries stochDSeries = StochD.Series(Bars, stochDSmooth.ValueInt, stochDPeriod.ValueInt); DataSeries stochKSeries = StochK.Series(Bars, stochKPeriod.ValueInt); }
/// <summary> /// Writes this layer as XML /// </summary> /// <param name="writer">The XML writer</param> public void WriteTo(XmlWriter writer) { writer.WriteStartElement("layer"); writer.WriteAttributeString("input-size", InputSize.ToString()); writer.WriteAttributeString("output-size", OutputSize.ToString()); writer.WriteAttributeString("activation", Activation.ToString()); writer.WriteAttributeString("weight-init", WeightInitialisation.ToString()); writer.WriteAttributeString("regularisation", Regularisation.ToString()); writer.WriteAttributeString("weight-update", WeightUpdate.ToString()); writer.WriteAttributeString("trainer", LayerTrainer.ToString()); writer.WriteAttributeString("lambda", Lambda.ToString()); writer.WriteAttributeString("momentum", Momentum.ToString()); writer.WriteAttributeString("decay-rate", DecayRate.ToString()); writer.WriteAttributeString("decay-rate2", DecayRate2.ToString()); writer.WriteAttributeString("dropout", Dropout.ToString()); if (Bias != null) { Bias.WriteTo("bias", writer); } if (Weight != null) { writer.WriteStartElement("weight"); foreach (var item in Weight) { item.WriteTo("row", writer); } writer.WriteEndElement(); } writer.WriteEndElement(); }
/// <summary> /// Updates the Physics of the entity. /// </summary> /// <param name="gameTime"></param> public override void Update(GameTime gameTime) { //ITEM: c) Implementou corretamente o cálculo de deslocamento da bala, levando em conta a inércia e fazendo uso de vetores; Vector2 forces = Vector2.Zero; Vector2 instantForces = Vector2.Zero; float secs = (float)gameTime.ElapsedGameTime.TotalSeconds; #region Calculate Forces //Constant forces foreach (Vector2 force in ConstantForces.Values) { forces += force; } //Forces applied once while (Forces.Count > 0) { instantForces += (Forces.Pop() / Mass); //Since it will be applied only once, must do a BIG BOOM. } #endregion Calculate Forces Vector2 acceleration = (forces / Mass) + Gravity; Vector2 accelSecs = acceleration * secs; Entity.Position += GlobalForces.MetersToPixels((Momentum + accelSecs / 2) * secs); Momentum += (accelSecs + instantForces); Momentum *= (Vector2.One - Friction); if (Rotate) { Entity.Rotation = Momentum.GetAngle(); } }
public void MergeFrom(OptimizableVector other) { if (other == null) { return; } if (other.value_ != null) { if (value_ == null) { Value = new global::NetworkData.Vector(); } Value.MergeFrom(other.Value); } if (other.momentum_ != null) { if (momentum_ == null) { Momentum = new global::NetworkData.Vector(); } Momentum.MergeFrom(other.Momentum); } if (other.velocity_ != null) { if (velocity_ == null) { Velocity = new global::NetworkData.Vector(); } Velocity.MergeFrom(other.Velocity); } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
/// <summary> /// Initializes a new instance of the <see cref="ITrendStrategy"/> class. /// </summary> /// <param name="period">The period of the Instantaneous trend.</param> public ITrendStrategy(Indicator price, int period, decimal tolerance = 0.001m, decimal revetPct = 1.0015m, RevertPositionCheck checkRevertPosition = RevertPositionCheck.vsTrigger) { _price = price; ITrend = new InstantaneousTrend(period).Of(price); ITrendMomentum = new Momentum(2).Of(ITrend); MomentumWindow = new RollingWindow <decimal>(2); Position = StockState.noInvested; EntryPrice = null; ActualSignal = OrderSignal.doNothing; _tolerance = tolerance; _revertPCT = revetPct; _checkRevertPosition = checkRevertPosition; //Sig9 sig9 = new Sig9(); ITrendMomentum.Updated += (object sender, IndicatorDataPoint updated) => { if (ITrendMomentum.IsReady) { MomentumWindow.Add(ITrendMomentum.Current.Value); } if (MomentumWindow.IsReady) { CheckSignal(); } }; }
void Update() { Momentum.Set(0, 0); MomentumDown.Set(0, 0); _temp = Input.GetAxisRaw("HorizontalPegi"); if (_temp != 0) { Momentum += _temp * Vector2.right; } _temp = Input.GetAxisRaw("Vertical"); if (_temp != 0) { Momentum += _temp * Vector2.up; } if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A)) { MomentumDown.Set(-1, MomentumDown.y); } else if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D)) { MomentumDown.Set(1, MomentumDown.y); } else if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W)) { MomentumDown.Set(MomentumDown.x, 1); } else if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S)) { MomentumDown.Set(MomentumDown.x, -1); } }
/// <summary> /// Creates a new Momentum indicator. This will compute the absolute n-period change in the security. /// The indicator will be automatically updated on the given resolution. /// </summary> /// <param name="symbol">The symbol whose momentumwe want</param> /// <param name="period">The period over which to compute the momentum</param> /// <param name="resolution">The resolution</param> /// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param> /// <returns>The momentum indicator for the requested symbol over the specified period</returns> public Momentum MOM(string symbol, int period, Resolution?resolution = null, Func <BaseData, decimal> selector = null) { string name = CreateIndicatorName(symbol, "MOM" + period, resolution); var momentum = new Momentum(name, period); RegisterIndicator(symbol, momentum, resolution, selector); return(momentum); }
public override string ToString() { var strValue = $"|Type:{LearnerType} |LRate:{LearningRate.ToString(CultureInfo.InvariantCulture)} " + $"|Momentum:{Momentum.ToString(CultureInfo.InvariantCulture)} |Loss:{LossFunction}" + $"|Eval:{EvaluationFunction}" + $"|L1:{L1Regularizer}" + $"|L2:{L2Regularizer}"; return(strValue); }
public void OpAddition() { var momentum1 = new Momentum(300000, MomentumUnit.GramCentimetersPerSecond); var momentum2 = new Momentum(1, MomentumUnit.KilogramMetersPerSecond); var expected = new Momentum(400000, MomentumUnit.GramCentimetersPerSecond); (momentum1 + momentum2).ShouldEqual(expected); (momentum2 + momentum1).ShouldEqual(expected); }
/// <summary> /// Creates a new Momentum indicator. This will compute the absolute n-period change in the security. /// The indicator will be automatically updated on the given resolution. /// </summary> /// <param name="symbol">The symbol whose momentumwe want</param> /// <param name="period">The period over which to compute the momentum</param> /// <param name="resolution">The resolution</param> /// <returns>The momentum indicator for the requested symbol over the specified period</returns> public Momentum MOM(string symbol, int period, Resolution?resolution = null) { string name = CreateIndicatorName(symbol, "MOM" + period, resolution); var momentum = new Momentum(name, period); RegisterIndicator(symbol, momentum, resolution); return(momentum); }
public void ComputesCorrectly() { var mom = new Momentum(5); foreach (var data in TestHelper.GetDataStream(5)) { mom.Update(data); Assert.AreEqual(data.Value, mom.Current.Value); } }
public void Momentum() { Momentum momentum = new Momentum(); momentum.Load(Directory.GetCurrentDirectory() + "\\table.csv"); SingleDoubleSerie serie = momentum.Calculate(); Assert.IsNotNull(serie); Assert.IsTrue(serie.Values.Count > 0); }
public void OpDivision() { var momentum1 = new Momentum(300000, MomentumUnit.GramCentimetersPerSecond); var momentum2 = new Momentum(3, MomentumUnit.KilogramMetersPerSecond); (momentum1 / momentum2).ShouldBeWithinEpsilonOf(1); (momentum2 / momentum1).ShouldBeWithinEpsilonOf(1); (momentum1 / 2).ShouldEqual(new Momentum(150000, MomentumUnit.GramCentimetersPerSecond)); (momentum2 / 2).ShouldEqual(new Momentum(1.5, MomentumUnit.KilogramMetersPerSecond)); }
public void OpGreaterThanOrEqual() { var momentum1 = new Momentum(300000, MomentumUnit.GramCentimetersPerSecond); var momentum2 = new Momentum(3, MomentumUnit.KilogramMetersPerSecond); var momentum3 = new Momentum(4, MomentumUnit.KilogramMetersPerSecond); (momentum1 >= momentum3).ShouldBeFalse(); (momentum3 >= momentum1).ShouldBeTrue(); (momentum1 >= momentum2).ShouldBeTrue(); (momentum2 >= momentum1).ShouldBeTrue(); }
public void OpInverseEquals() { var momentum1 = new Momentum(300000, MomentumUnit.GramCentimetersPerSecond); var momentum2 = new Momentum(3, MomentumUnit.KilogramMetersPerSecond); var momentum3 = new Momentum(4, MomentumUnit.KilogramMetersPerSecond); (momentum1 != momentum2).ShouldBeFalse(); (momentum2 != momentum1).ShouldBeFalse(); (momentum1 != momentum3).ShouldBeTrue(); (momentum3 != momentum1).ShouldBeTrue(); }
protected override void Init() { _ma1B = GetIndicator <MovingAverage>(Instrument.Id, Timeframe, _maPeriod1B, _maShift1B, _maMethod1B, _priceMode1B); _ma2B = GetIndicator <MovingAverage>(Instrument.Id, Timeframe, _maPeriod2B, _maShift2B, _maMethod2B, _priceMode2B); _momentInd = GetIndicator <Momentum>(Instrument.Id, Timeframe); _momentInd.Period = 100; _ma1R = GetIndicator <MovingAverage>(Instrument.Id, Timeframe, _maPeriod1R, _maShift1R, _maMethod1R, _priceMode1R); //_ma2R = GetIndicator<MovingAverage>(Instrument.Id, Timeframe,_maPeriod2R, _maShift2R, _maMethod2R, _priceMode2R); }
public void Momentum() { Momentum momentum = new Momentum(); momentum.Load(csvPath); SingleDoubleSerie serie = momentum.Calculate(); Assert.NotNull(serie); Assert.True(serie.Values.Count > 0); }
/// <summary> /// Initializes a new instance of the <see cref="ITrendStrategy"/> class. /// </summary> /// <param name="period">The period of the Instantaneous trend.</param> public ITrendSignal(int period, decimal tolerance = 0.001m, decimal revetPct = 1.0015m, RevertPositionCheck checkRevertPosition = RevertPositionCheck.vsTrigger) { ITrend = new InstantaneousTrend(period); ITrendMomentum = new Momentum(2).Of(ITrend); MomentumWindow = new RollingWindow <decimal>(2); _tolerance = tolerance; _revertPCT = revetPct; _checkRevertPosition = checkRevertPosition; }
/// <summary> /// Initializes a new instance of the <see cref="ITrendStrategy"/> class. /// </summary> /// <param name="period">The period of the Instantaneous trend.</param> public ITrendSignal(int period, decimal tolerance = 0.001m, decimal revetPct = 1.0015m, RevertPositionCheck checkRevertPosition = RevertPositionCheck.vsTrigger) { ITrend = new InstantaneousTrend(period); ITrendMomentum = new Momentum(2).Of(ITrend); MomentumWindow = new RollingWindow<decimal>(2); _tolerance = tolerance; _revertPCT = revetPct; _checkRevertPosition = checkRevertPosition; }
public void Momentum() { Momentum momentum = new Momentum(); momentum.Load(OhlcList); SingleDoubleSerie serie = momentum.Calculate(); Assert.IsNotNull(serie); Assert.IsTrue(serie.Values.Count > 0); }
/// <summary> /// Called on every new bar of data. /// </summary> /// <param name="currentBar">The current bar of the simulation</param> protected override void OnBarUpdate(int currentBar) { base.OnBarUpdate(currentBar); Momentum ind = (Momentum)Dependents[0]; if (DataSeries.IsAboutToCrossAbove(ind.Value, 0, currentBar) == true) { WasFound[currentBar] = true; } }
/// <summary> /// Called on every new bar of data. /// </summary> /// <param name="currentBar">The current bar of the simulation</param> protected override void OnBarUpdate(int currentBar) { base.OnBarUpdate(currentBar); Momentum ind = (Momentum)Dependents[0]; if (DataSeries.CrossBelow(ind.Value, 0, currentBar, 0) != -1) { WasFound[currentBar] = true; } }
public override void Initialize() { SetStartDate(2016, 01, 01); //Set Start Date SetEndDate(2016, 06, 30); //Set End Date SetCash(100000); //Set Strategy Cash AddEquity(symbol, Resolution.Daily); rsi = RSI(symbol, 14, MovingAverageType.Simple, Resolution.Daily); mom = MOM(symbol, 10, Resolution.Daily, Field.Close); engine = new FuzzyEngine(); }
public override void Initialize() { SetStartDate(2015, 01, 01); //Set Start Date SetEndDate(2015, 06, 30); //Set End Date SetCash(100000); //Set Strategy Cash AddEquity(_symbol, Resolution.Daily); _rsi = RSI(_symbol, 14, MovingAverageType.Simple, Resolution.Daily); _mom = MOM(_symbol, 10, Resolution.Daily, Field.Close); _engine = new FuzzyEngine(); }
public void WarmsUpProperly() { var mom = new Momentum(5); var period = ((IIndicatorWarmUpPeriodProvider)mom).WarmUpPeriod; var dataStream = TestHelper.GetDataStream(period).ToArray(); for (var i = 0; i < period; i++) { mom.Update(dataStream[i]); Assert.AreEqual(i == period - 1, mom.IsReady); } }
// МЕТОДЫ ВЫЗЫВАЕМЫЕ В ГЛАВНОМ МЕНЮ // Открывает страницу демонстрации "Сохранение импульса" private void OpenMomentum() { momentum = new Momentum(); frame.Navigate(momentum); HideMenuButtons(); // Скрываем кнопки меню ShowDemoButtons(); // Показываем кнопки демонстрации this.listBox.Items.Clear(); // Очищаем список в листбоксе от возможных предыдущих значений playBtn.IsEnabled = false; // Делаем кнопку "Старт" неактивной stopBtn.IsEnabled = false; // Делаем кнопку "Стоп" неактивной }
public IList <BaseIndicatorValue> ComputeMomentum(IList <Candle> candles, int period) { var indicator = new Momentum(candles.Select(candle => candle.ToInnerModel()), period); var innerValues = indicator.Compute(); var outputValues = new List <BaseIndicatorValue>(); outputValues.AddRange(innerValues .Where(value => value.DateTime.HasValue) .Select(value => value.ToOuterModel())); return(outputValues); }
public BackPropagation GetLearningMethod(object owner, IContextLookup globalVars, BasicNetwork theNetwork, IList <BasicData> data) { double theLearningRate = LearningRate.GetValue(owner, globalVars); double theMomentum = Momentum.GetValue(owner, globalVars); var theL1 = L1.GetValue(owner, globalVars); var theL2 = L2.GetValue(owner, globalVars); var toReturn = new BackPropagation(theNetwork, data, theLearningRate, theMomentum); toReturn.L1 = theL1; toReturn.L2 = theL2; return(toReturn); }
public void ResetsProperly() { var mom = new Momentum(5); foreach (var data in TestHelper.GetDataStream(6)) { mom.Update(data); } Assert.IsTrue(mom.IsReady); mom.Reset(); TestHelper.AssertIndicatorIsInDefaultState(mom); }
public void OpEquals() { var momentum1 = new Momentum(300000, MomentumUnit.GramCentimetersPerSecond); var momentum2 = new Momentum(3, MomentumUnit.KilogramMetersPerSecond); var momentum3 = new Momentum(4, MomentumUnit.KilogramMetersPerSecond); (momentum1 == momentum2).ShouldBeTrue(); (momentum2 == momentum1).ShouldBeTrue(); (momentum1 == momentum3).ShouldBeFalse(); (momentum3 == momentum1).ShouldBeFalse(); momentum1.Equals(momentum2) .ShouldBeTrue(); momentum1.Equals((object)momentum2) .ShouldBeTrue(); momentum2.Equals(momentum1) .ShouldBeTrue(); momentum2.Equals((object)momentum1) .ShouldBeTrue(); }
/// <summary> /// Initializes a new instance of the <see cref="ITrendStrategy"/> class. /// </summary> /// <param name="period">The period of the Instantaneous trend.</param> public ITrendStrategyJJ(Indicator price, int period, decimal tolerance = 0.001m, decimal revetPct = 1.0015m, RevertPositionCheck checkRevertPosition = RevertPositionCheck.vsTrigger) { _price = price; ITrend = new InstantaneousTrend(period).Of(price); ITrendMomentum = new Momentum(2).Of(ITrend); MomentumWindow = new RollingWindow<decimal>(2); Position = StockState.noInvested; EntryPrice = null; ActualSignal = OrderSignal.doNothing; _tolerance = tolerance; _revertPCT = revetPct; _checkRevertPosition = checkRevertPosition; ITrendMomentum.Updated += (object sender, IndicatorDataPoint updated) => { if (ITrendMomentum.IsReady) MomentumWindow.Add(ITrendMomentum.Current.Value); if (MomentumWindow.IsReady) CheckSignal(); }; }
/// <summary> /// Initializes a new instance of the <see cref="ITrendStrategy"/> class. /// </summary> /// <param name="period">The period of the Instantaneous trend.</param> public MultiSymbolStrategy(Indicator price, int period, decimal tolerance = 0.001m, decimal revetPct = 1.0015m, RevertPositionCheck checkRevertPosition = RevertPositionCheck.vsTrigger) { _price = price; sma = new SimpleMovingAverage(period).Of(price); SMAMomentum = new Momentum(2).Of(sma); MomentumWindow = new RollingWindow<decimal>(2); Position = StockState.noInvested; EntryPrice = null; ActualSignal = OrderSignal.doNothing; _tolerance = tolerance; _revertPCT = revetPct; _checkRevertPosition = checkRevertPosition; SMAMomentum.Updated += (object sender, IndicatorDataPoint updated) => { if (SMAMomentum.IsReady) MomentumWindow.Add(SMAMomentum.Current.Value); if (MomentumWindow.IsReady) CheckSignal(); }; }
protected virtual void OnMaxValueChanged(Momentum? oldValue, Momentum? newValue) { this.SetScalarValue(ScalarMaxValueProperty, newValue); }
public void OpMultiplicationScaler() { var momentum = new Momentum(1, MomentumUnit.KilogramMetersPerSecond); var expected = new Momentum(2, MomentumUnit.KilogramMetersPerSecond); (momentum * 2).ShouldEqual(expected); (2 * momentum).ShouldEqual(expected); }
public void OpSubtraction() { var momentum1 = new Momentum(700000, MomentumUnit.GramCentimetersPerSecond); var momentum2 = new Momentum(3, MomentumUnit.KilogramMetersPerSecond); (momentum1 - momentum2).ShouldEqual(new Momentum(400000, MomentumUnit.GramCentimetersPerSecond)); (momentum2 - momentum1).ShouldEqual(new Momentum(-4, MomentumUnit.KilogramMetersPerSecond)); }
public static Momentum operator *(Speed speed, Mass mass) { Momentum momentum = new Momentum(); momentum.Value = mass.Value * speed.Value; return momentum; }
public void OpLessThan() { var momentum1 = new Momentum(300000, MomentumUnit.GramCentimetersPerSecond); var momentum2 = new Momentum(3, MomentumUnit.KilogramMetersPerSecond); var momentum3 = new Momentum(4, MomentumUnit.KilogramMetersPerSecond); (momentum1 < momentum3).ShouldBeTrue(); (momentum3 < momentum1).ShouldBeFalse(); (momentum1 < momentum2).ShouldBeFalse(); (momentum2 < momentum1).ShouldBeFalse(); }
protected void SetScalarValue(DependencyProperty property, Momentum? quantity) { // we set this flag to prevent from setting scalar value changing quantity values. this.isUpdatingScalarValue = true; var value = quantity != null ? this.Unit.GetScalarValue(quantity.Value) : (double?)null; this.SetCurrentValue(property, value); this.isUpdatingScalarValue = false; }
public Sig10Strategy(SecurityHolding sym, Indicator priceIdentity, int trendPeriod, decimal lossThreshhold, decimal tolerance, decimal revertPct) { trendArray = new decimal[trendPeriod + 1]; // initialized to 0. Add a period for Deserialize to make IsReady true symbol = sym.Symbol; _holding = sym; _price = priceIdentity; _period = trendPeriod; _lossThreshhold = lossThreshhold; _tolerance = tolerance; RevPct = revertPct; Trend = new InstantaneousTrend(sym.Symbol.Value, 7, .24m).Of(priceIdentity); TrendMomentum = new Momentum(2).Of(Trend); MomentumWindow = new RollingWindow<decimal>(2); ActualSignal = OrderSignal.doNothing; Trend.Updated += (object sender, IndicatorDataPoint updated) => { Barcount++; UpdateTrendArray(Trend.Current.Value); nTrig = Trend.Current.Value; if (Trend.IsReady) { TrendMomentum.Update(Trend.Current); } if (TrendMomentum.IsReady) MomentumWindow.Add(TrendMomentum.Current.Value); if (MomentumWindow.IsReady) CheckSignal(); }; }