/// <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();
                }
            };
        }
Exemple #2
0
        /// <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();
                }
            };
        }
Exemple #3
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;
 }
Exemple #4
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 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();
            };
        }
        /// <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();
            };
        }