Exemplo n.º 1
6
 protected override void OnStart()
 {
     bb=Indicators.BollingerBands(MarketSeries.Close,bbperiod,bbotcl, MovingAverageType.Simple);
     rsi=Indicators.RelativeStrengthIndex(MarketSeries.Close,rsiperiod);
     psar=Indicators.ParabolicSAR(SARstep,SARmax);
     frc=Indicators.FractalChaosBands(5);
 }
Exemplo n.º 2
0
        public override bool InitIndicatorsAsync()
        {
            string  directoryName   = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
            string  env             = TestMode ? "test" : "live";
            string  coinbaseRSIFile = Path.Combine(directoryName, $"data\\coinbase_{env}");
            Product product         = Products.FirstOrDefault(x => x.BaseCurrency == "BTC" && x.QuoteCurrency == "EUR");
            RelativeStrengthIndex relativeStrengthIndex = new RelativeStrengthIndex(coinbaseRSIFile, product);

            if (product != null)
            {
                relativeStrengthIndex.TechnicalIndicatorInformationBroadcast +=
                    delegate(Dictionary <string, string> input)
                {
                    TechnicalIndicatorInformationBroadcast?.Invoke(ApplicationName, input);
                };
                relativeStrengthIndex.ProcessLogBroadcast += delegate(MessageType messageType, string message)
                {
                    ProcessLogBroadcast?.Invoke(ApplicationName, messageType, message);
                };
                relativeStrengthIndex.UpdateProductHistoricCandles += UpdateProductHistoricCandlesAsync;
                relativeStrengthIndex.EnableRelativeStrengthIndexUpdater();
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
 protected override void Initialize()
 {
     STO_RSI = CreateDataSeries();
     RSI     = Indicators.RelativeStrengthIndex(MarketSeries.Close, Rsi_Period);
     MA_SK   = Indicators.MovingAverage(STO_RSI, PeriodSK, MA_Type);
     MA_SD   = Indicators.MovingAverage(MA_SK.Result, PeriodSD, MA_Type);
 }
Exemplo n.º 4
0
 public Worker(ILogger <Worker> logger, IHubContext <ExchangeHub, IExchangeHub> exchangeHub, IExchangeService exchangeService)
 {
     _logger          = logger;
     _exchangeHub     = exchangeHub;
     _exchangeService = exchangeService;
     _relativeStrengthIndexIndicator = new RelativeStrengthIndex(exchangeService);
 }
Exemplo n.º 5
0
        public void TestBullishSignalTriggered()
        {
            var startDate                   = new DateTime(2017, 1, 3);
            RelativeStrengthIndex rsi       = new RelativeStrengthIndex("AAPL", 14, MovingAverageType.Simple);
            RSIBullBearIndicator  indicator = new RSIBullBearIndicator("AAPL", rsi);
            IndicatorDataPoint    dataPoint = new IndicatorDataPoint(startDate, Convert.ToDecimal(GetRandomNumber(127.8, 398.6)));

            Assert.False(indicator.BullishSignalTriggered());

            //prime up indicator with lots of data points
            for (int i = 0; i < 250; i++)
            {
                rsi.Update(dataPoint);
                indicator.Update(dataPoint);
                Assert.False(indicator.BullishSignalTriggered());
                dataPoint = new IndicatorDataPoint(startDate = startDate.AddDays(1), Convert.ToDecimal(GetRandomNumber(127.8, 398.6)));
            }

            dataPoint = new IndicatorDataPoint(startDate = startDate.AddDays(1), Decimal.Add(dataPoint.Value, Convert.ToDecimal(249.8)));
            rsi.Update(dataPoint);
            indicator.Update(dataPoint);

            dataPoint = new IndicatorDataPoint(startDate = startDate.AddDays(1), Decimal.Subtract(dataPoint.Value, Convert.ToDecimal(121.8)));
            rsi.Update(dataPoint);
            indicator.Update(dataPoint);

            Assert.True(indicator.BullishSignalTriggered());
        }
        //set out of area

        protected override void Initialize()
        {
            RSINow = Indicators.RelativeStrengthIndex(SourceSeries, RSI_period);
            seriesH1 = MarketData.GetSeries(TimeFrame.Daily);
            ATR = Indicators.AverageTrueRange(seriesH1, ATR_period, MovingAverageType.Simple);

        }
Exemplo n.º 7
0
 protected override void Initialize()
 {
     _rsi            = Indicators.RelativeStrengthIndex(Source, RsiPeriod);
     _bollingerBands = Indicators.BollingerBands(_rsi.Result, Volatility, StDev, MovingAverageType.Simple);
     _price          = Indicators.MovingAverage(_rsi.Result, PricePeriod, PriceMaType);
     _signal         = Indicators.MovingAverage(_rsi.Result, SignalPeriod, SignalMaType);
 }
Exemplo n.º 8
0
        public FuzzySignal(RelativeStrengthIndex rsi, SecurityHolding securityHolding)
        {
            _rsi             = rsi;
            _securityHolding = securityHolding;

            _engine = new FuzzyEngine();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Determines the new state. This is basically cross-over detection logic that
        /// includes considerations for bouncing using the configured bounce tolerance.
        /// </summary>
        private State GetState(RelativeStrengthIndex rsi, State previous)
        {
            if (rsi > 70m)
            {
                return(State.TrippedHigh);
            }

            if (rsi < 30m)
            {
                return(State.TrippedLow);
            }

            if (previous == State.TrippedLow)
            {
                if (rsi > 35m)
                {
                    return(State.Middle);
                }
            }

            if (previous == State.TrippedHigh)
            {
                if (rsi < 65m)
                {
                    return(State.Middle);
                }
            }

            return(previous);
        }
Exemplo n.º 10
0
        //******************************************

        protected override void Initialize()
        {
            //**************************************
            LR_Slope = Indicators.LinearRegressionSlope(MarketSeries.Close, 12);
            MA20     = Indicators.ExponentialMovingAverage(MarketSeries.Close, 20);
            MA50     = Indicators.ExponentialMovingAverage(MarketSeries.Close, 50);
            MA100    = Indicators.ExponentialMovingAverage(MarketSeries.Close, 100);

            LTF_Candle = MarketData.GetSeries(LTF);
            MTF_Candle = MarketData.GetSeries(MTF);
            STF_Candle = MarketData.GetSeries(STF);
            //**************************************

            ///////////////////////////////////////////////////////////

            // Initialize and create nested indicators

            MA = Indicators.MovingAverage(MarketSeries.Close, MA_Periods, MovingAverageType.Exponential);
            // Initalize RSI
            RSI = Indicators.RelativeStrengthIndex(MarketSeries.Close, RSI_Periods);

            // Initalize CCI
            CCI = Indicators.CommodityChannelIndex(MarketSeries, CCI_Periods);

            thecount = MarketSeries.Close.Count;
            Print("theCount = " + thecount);
        }
Exemplo n.º 11
0
        public RelativeStrengthIndex CreateRelativeStrengthIndexIndicator(int period, MovingAverageType movingAverageType)
        {
            RelativeStrengthIndex indicator = new RelativeStrengthIndex(period, movingAverageType);

            Indicators.Add(indicator);
            return(indicator);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Determines the new state. This is basically cross-over detection logic that
        /// includes considerations for bouncing using the configured bounce tolerance.
        /// </summary>
        private State GetState(RelativeStrengthIndex rsi, State previous)
        {
            if (rsi > _parameters.UpperRsiBound)
            {
                return(State.TrippedHigh);
            }

            if (rsi < _parameters.LowerRsiBound)
            {
                return(State.TrippedLow);
            }

            if (previous == State.TrippedLow)
            {
                if (rsi > _parameters.LowerRsiBound + _parameters.BounceTolerance)
                {
                    return(State.Middle);
                }
            }

            if (previous == State.TrippedHigh)
            {
                if (rsi < _parameters.UpperRsiBound - _parameters.BounceTolerance)
                {
                    return(State.Middle);
                }
            }

            return(previous);
        }
Exemplo n.º 13
0
 protected override void OnStart()
 {
     i_Moving_Average_200MA      = Indicators.SimpleMovingAverage(MarketSeries.Close, (int)_Slow_SMA);
     i_Relative_Strength_Index   = Indicators.RelativeStrengthIndex(MarketSeries.Close, (int)_RSI_Period);
     i_Relative_Strength_Index_2 = Indicators.RelativeStrengthIndex(MarketSeries.Close, (int)_RSI_Period);
     i_Moving_Average_5MA        = Indicators.SimpleMovingAverage(MarketSeries.Close, (int)_Fast_SMA);
 }
Exemplo n.º 14
0
 protected override void OnStart()
 {
     bb   = Indicators.BollingerBands(MarketSeries.Close, bbperiod, bbotcl, MovingAverageType.Simple);
     rsi  = Indicators.RelativeStrengthIndex(MarketSeries.Close, rsiperiod);
     psar = Indicators.ParabolicSAR(SARstep, SARmax);
     frc  = Indicators.FractalChaosBands(5);
 }
Exemplo n.º 15
0
 protected override void Initialize()
 {
     _rsi = Indicators.RelativeStrengthIndex(Source, RsiPeriod);
     _bollingerBands = Indicators.BollingerBands(_rsi.Result, Volatility, StDev, MovingAverageType.Simple);
     _price = Indicators.MovingAverage(_rsi.Result, PricePeriod, PriceMaType);
     _signal = Indicators.MovingAverage(_rsi.Result, SignalPeriod, SignalMaType);
 }
Exemplo n.º 16
0
        public override void Initialize()
        {
            SetCash(100000);
            symbols.Add("SPY");
            SetStartDate(1998, 1, 1);
            SetEndDate(2014, 12, 1);

            //Present Social Media Stocks:
            // symbols.Add("FB");symbols.Add("LNKD");symbols.Add("GRPN");symbols.Add("TWTR");
            // SetStartDate(2011, 1, 1);
            // SetEndDate(2014, 12, 1);

            //2008 Financials:
            // symbols.Add("C");symbols.Add("AIG");symbols.Add("BAC");symbols.Add("HBOS");
            // SetStartDate(2003, 1, 1);
            // SetEndDate(2011, 1, 1);

            //2000 Dot.com:
            // symbols.Add("IPET");symbols.Add("WBVN");symbols.Add("GCTY");
            // SetStartDate(1998, 1, 1);
            // SetEndDate(2000, 1, 1);

            //CAPE data
            AddData <CAPE>("CAPE");

            foreach (string stock in symbols)
            {
                AddSecurity(SecurityType.Equity, stock, Resolution.Minute);

                macd = MACD(stock, 12, 26, 9, MovingAverageType.Exponential, Resolution.Daily);
                macdDic.Add(stock, macd);
                rsi = RSI(stock, 14, MovingAverageType.Exponential, Resolution.Daily);
                rsiDic.Add(stock, rsi);
            }
        }
Exemplo n.º 17
0
        protected override void OnStart()
        {
            i_Moving_Average_200MA = Indicators.SimpleMovingAverage(MarketSeries.Close, (int)_Slow_SMA);
            i_Relative_Strength_Index = Indicators.RelativeStrengthIndex(MarketSeries.Close, (int)_RSI_Period);
            i_Moving_Average_5MA = Indicators.SimpleMovingAverage(MarketSeries.Close, (int)_Fast_SMA);

        }
Exemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CrossEMAStrategy"/> class.
        /// </summary>
        /// <param name="Price">The injected price indicator.</param>
        /// <param name="SlowEMAPeriod">The slow EMA period.</param>
        /// <param name="FastEMAPeriod">The fast EMA period.</param>
        public RSIStrategy(Indicator Price, int RSIPeriod = 40, decimal Threshold = 20)
        {
            // Initialize fields.
            _threshold   = Threshold;
            _price       = Price;
            ActualSignal = OrderSignal.doNothing;
            Position     = StockState.noInvested;
            EntryPrice   = null;

            rsi = new RelativeStrengthIndex(RSIPeriod).Of(_price);

            // Fill the RSI rolling windows at every new RSI update. Once the
            // rolling windows is ready, at every indicator update the CheckSignal method will be called.
            rsi.Updated += (object sender, IndicatorDataPoint updated) =>
            {
                if (rsi.IsReady)
                {
                    rsiRW.Add(rsi);
                }
                if (rsiRW.IsReady)
                {
                    CheckSignal();
                }
            };
        }
Exemplo n.º 19
0
        protected override void OnStart()
        {
            i_Relative_Strength_Index = Indicators.RelativeStrengthIndex(MarketSeries.Close, 2);
            i_Moving_Average_200MA = Indicators.SimpleMovingAverage(MarketSeries.Close, 200);
            i_Moving_Average_5MA = Indicators.SimpleMovingAverage(MarketSeries.Close, 5);

        }
Exemplo n.º 20
0
 public RSISignal(RelativeStrengthIndex rsi,
                  ExponentialMovingAverage ema,
                  SecurityHolding securityHolding)
 {
     _rsi             = rsi;
     _ema             = ema;
     _securityHolding = securityHolding;
 }
Exemplo n.º 21
0
        /// <summary>
        /// Creates a new RelativeStrengthIndex indicator. This will produce an oscillator that ranges from 0 to 100 based
        /// on the ratio of average gains to average losses over the specified period.
        /// </summary>
        /// <param name="symbol">The symbol whose RSI we want</param>
        /// <param name="period">The period over which to compute the RSI</param>
        /// <param name="movingAverageType">The type of moving average to use in computing the average gain/loss values</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 RelativeStrengthIndex indicator for the requested symbol over the specified period</returns>
        public RelativeStrengthIndex RSI(string symbol, int period, MovingAverageType movingAverageType = MovingAverageType.Simple, Resolution?resolution = null, Func <BaseData, decimal> selector = null)
        {
            var name = CreateIndicatorName(symbol, "RSI" + period, resolution);
            var rsi  = new RelativeStrengthIndex(name, period, movingAverageType);

            RegisterIndicator(symbol, rsi, resolution, selector);
            return(rsi);
        }
Exemplo n.º 22
0
 protected override void Initialize()
 {
     _cyclePrice     = CreateDataSeries();
     _zeroLag        = CreateDataSeries();
     _ma             = Indicators.MovingAverage(MarketSeries.Close, PriceActionFilter, MaType);
     _rsi            = Indicators.RelativeStrengthIndex(_cyclePrice, 14);
     _useCycleFilter = UseCycleFilter == 1;
 }
Exemplo n.º 23
0
        private void rsiParameterNext_Click(object sender, EventArgs e)
        {
            rsiResultTitle.Text = Code + " için Relative Strength Index sonucu";
            RSIPeriod           = (int)rsiPeriod.Value;

            rsiDataResultChart.Series.Clear();
            rsiIndicatorResultChart.Series.Clear();

            var closeSeries = new Series
            {
                Name      = "Kapanış",
                Color     = System.Drawing.Color.Black,
                ChartType = SeriesChartType.Line
            };

            var rsiSeries = new Series
            {
                Name      = "Relative Strength Index",
                Color     = System.Drawing.Color.Blue,
                ChartType = SeriesChartType.Line
            };

            rsiDataResultChart.Series.Add(closeSeries);
            rsiIndicatorResultChart.Series.Add(rsiSeries);

            var closeData = IndicatorService.GetData(Code, TargetDate, new string[] { "Tarih", "Kapanis" }, NumberOfData);

            double[] rsi;
            if (MapReduceAllowed)
            {
                rsi = RelativeStrengthIndex.RsiMR(Code, TargetDate, RSIPeriod, NumberOfData);
            }
            else
            {
                rsi = RelativeStrengthIndex.Rsi(Code, TargetDate, RSIPeriod, NumberOfData);
            }

            DateTime date;

            for (int i = 0; i < rsi.Length; i++)
            {
                var close = closeData.ElementAt(i);
                date = close.GetElement("Tarih").Value.AsBsonDateTime.ToLocalTime();
                closeSeries.Points.AddXY(date, close.GetElement("Kapanis").Value.ToDouble());
                rsiSeries.Points.AddXY(date, rsi[i]);
            }

            rsiDataResultChart.ChartAreas[0].AxisY.Minimum = Math.Floor(closeData.Select(p => p.GetElement("Kapanis").Value.ToDouble()).Min());
            rsiDataResultChart.ChartAreas[0].AxisY.Maximum = Math.Ceiling(closeData.Select(p => p.GetElement("Kapanis").Value.ToDouble()).Max());

            rsiIndicatorResultChart.ChartAreas[0].AxisY.Minimum = 0;
            rsiIndicatorResultChart.ChartAreas[0].AxisY.Maximum = 100;

            rsiDataResultChart.Invalidate();
            rsiIndicatorResultChart.Invalidate();

            rsiResultPanel.BringToFront();
        }
Exemplo n.º 24
0
        public override void Initialize()
        {
            // backtest parameters
            // we have data for these dates locally
            var start = new DateTime(2020, 01, 01, 09, 30, 0);

            SetStartDate(start);
            SetEndDate(start.AddDays(30));
            SetCash(100000);

            // set security and option universe for tradebar
            _spy = AddEquity("SPY", Resolution.Minute);
            var option = AddOption("SPY", Resolution.Minute);

            // set filter on option universe
            _optionSymbol = option.Symbol;
            option.SetFilter(universe =>
                             from symbol in universe
                             .WeeklysOnly().Expiration(TimeSpan.Zero, TimeSpan.FromDays(10))
                             where symbol.ID.OptionRight != OptionRight.Put
                             select symbol);

            // use the underlying equity as the benchmark
            SetBenchmark("SPY");

            // Creates a Rolling Window indicator to hold 2 TradeBars
            _window = new RollingWindow <TradeBar>(2);

            // Creates a Rolling Window indicator to hold 1 option contract
            _optionWindow = new RollingWindow <OptionContract>(1);

            // create RSI indicator
            fast = new RelativeStrengthIndex("SPY", 14, MovingAverageType.Wilders);

            // Create a Rolling Window to keep two Indicator Data Points
            _rsiLag = new RollingWindow <IndicatorDataPoint>(2);

            // define our 5 minute trade bar consolidator. we can access the 5 minute bar
            // from the DataConsolidated events
            var minConsolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(5));

            // attach our event handler. the event handler is a function that will be called each time we produce
            // a new consolidated piece of data.
            minConsolidator.DataConsolidated += OnFiveMinutes;

            // this call adds our daily consolidator to the manager to receive updates from the engine
            SubscriptionManager.AddConsolidator("SPY", minConsolidator);

            // we need to manually register these indicators for automatic updates
            RegisterIndicator("SPY", fast, minConsolidator);

            Schedule.On(DateRules.EveryDay(), TimeRules.BeforeMarketClose(_spy.Symbol, 4), () =>
            {
                CloseOpenPositions(_spy);
            });

            SetWarmUp(TimeSpan.FromDays(100));
        }
Exemplo n.º 25
0
        /// <summary>
        /// Viene generato all'avvio dell'indicatore, si inizializza l'indicatore
        /// </summary>
        protected override void Initialize()
        {
            // --> Stampo nei log la versione corrente
            Print("{0} : {1}", NAME, VERSION);

            _ma  = Indicators.MovingAverage(Source, MAPeriods, MaType);
            _rsi = Indicators.RelativeStrengthIndex(_ma.Result, RSIPeriods);
            _ema = Indicators.ExponentialMovingAverage(_rsi.Result, TPeriods);
        }
Exemplo n.º 26
0
 protected override void OnStart()
 {
     i_TrendMovingAverage   = Indicators.SimpleMovingAverage(MarketSeries.Close, (int)_TrendSMA);
     i_Intermediate_SMA     = Indicators.SimpleMovingAverage(MarketData.GetSeries(TimeFrame.Hour4).Close, (int)_DailyIntermediateTrend_SMA);
     i_RSI_StopLoss         = Indicators.RelativeStrengthIndex(MarketSeries.Close, (int)_wRSI_StopLossMA);
     i_TriggerMovingAverage = Indicators.SimpleMovingAverage(MarketSeries.Close, (int)_SlowSMATrigger);
     i_Average_True_Range   = Indicators.AverageTrueRange((int)_ATR_MA, MovingAverageType.Simple);
     i_RSI = Indicators.RelativeStrengthIndex(MarketSeries.Close, (int)_cRSI_MA);
 }
Exemplo n.º 27
0
        public async Task TestRsiAsync()
        {
            var equity = await ImportEquityAsync();

            var indicator = new RelativeStrengthIndex(equity, 14);
            var result    = indicator.ComputeByIndex(equity.Count - 1);

            Assert.IsTrue(73.03m.IsApproximatelyEquals(result.Rsi.Value));
        }
Exemplo n.º 28
0
        protected override void OnStart()
        {
            rsi = Indicators.RelativeStrengthIndex(Source, Periods);

            _equity = Account.Balance;
            Print("ScalpingWithRSI.OnStart() equity: ", _equity.ToString());

            MakeBuySellOrder(Volume);
        }
Exemplo n.º 29
0
 protected override void OnStart()
 {
     Positions.Closed += OnPositionsClosed;
     rsi           = Indicators.RelativeStrengthIndex(MarketData.GetSeries(TimeFrame.Hour).Close, 14);
     sma           = Indicators.SimpleMovingAverage(MarketData.GetSeries(TimeFrame.Minute5).Close, 800);
     currentVolume = InitialVolume;
     balance       = Account.Balance;
     Timer.Start(1);
 }
Exemplo n.º 30
0
        protected override void OnStart()
        {
            _hmaslow = Indicators.GetIndicator <HMAslow>(SlowPeriod);
            _macd    = Indicators.MacdHistogram(LongCycle, ShortCycle, Period);
            rsi      = Indicators.RelativeStrengthIndex(Source, Periods);

            Positions.Opened += PositionsOnOpened;
            Positions.Closed += PositionsOnClosed;
        }
Exemplo n.º 31
0
        protected override void OnStart()
        {
            rsi = Indicators.RelativeStrengthIndex(Source, Period0);
            bol = Indicators.BollingerBands(Source, Period1, stdev, MovingAverageType.Simple);

            //obtain high and low of initial start bar
            double max = MarketSeries.High.LastValue;
            double min = MarketSeries.Low.LastValue;
        }
Exemplo n.º 32
0
        public async Task TestRsiAsync()
        {
            var candles = await ImportCandlesAsync();

            var indicator = new RelativeStrengthIndex(candles, 14);
            var result    = indicator[candles.Count - 1];

            Assert.IsTrue(73.03m.IsApproximatelyEquals(result.Value));
        }
Exemplo n.º 33
0
        protected override void OnStart()
        {

            rsi = Indicators.RelativeStrengthIndex(Source, Period0);
            bol = Indicators.BollingerBands(Source, Period1, stdev, MovingAverageType.Simple);

            //obtain high and low of initial start bar 
            double max = MarketSeries.High.LastValue;
            double min = MarketSeries.Low.LastValue;
        }
        public override void Initialize()
        {
            SetStartDate(1998, 1, 1);
            SetEndDate(DateTime.Now);
            SetCash(10000);

            AddSecurity(SecurityType.Equity, Symbol, Resolution.Daily);

            _rsi = new RelativeStrengthIndex(Symbol, 3, MovingAverageType.Simple);
        }
Exemplo n.º 35
0
        public void ComparesAgainstExternalData()
        {
            var rsiSimple = new RelativeStrengthIndex("rsi", 14, MovingAverageType.Simple);

            TestHelper.TestIndicator(rsiSimple, "RSI 14");

            var rsiWilder = new RelativeStrengthIndex("rsi", 14, MovingAverageType.Wilders);

            TestHelper.TestIndicator(rsiWilder, "RSI 14 Wilder");
        }
Exemplo n.º 36
0
        protected override void OnStart()
        {
            currentVolume     = InitialVolume;
            Positions.Closed += OnPositionsClosed;
            Timer.Start(60);
            var marketSeriesMin10 = MarketData.GetSeries(TimeFrame.Minute10);

            rsiMin10 = Indicators.RelativeStrengthIndex(marketSeriesMin10.Close, 14);
            rsi      = Indicators.RelativeStrengthIndex(MarketSeries.Close, 14);
        }
Exemplo n.º 37
0
        protected override void Initialize()
        {

            _atrRsi = CreateDataSeries();
            CreateDataSeries();

            _wildersPeriod = Period * 2 - 1;
            _startBar = _wildersPeriod < SF ? SF : _wildersPeriod;

            _rsi = Indicators.RelativeStrengthIndex(MarketSeries.Close, Period);
            _emaRsi = Indicators.ExponentialMovingAverage(_rsi.Result, SF);
            _emaAtr = Indicators.ExponentialMovingAverage(_atrRsi, _wildersPeriod);
            _ema = Indicators.ExponentialMovingAverage(_emaAtr.Result, _wildersPeriod);

        }
Exemplo n.º 38
0
 protected override void Initialize()
 {
     DataSeries ds;
     ds = MarketSeries.Typical;
     if (is_typic)
     {
         ds = MarketSeries.Typical;
     }
     if (is_wclose)
     {
         ds = MarketSeries.WeightedClose;
     }
     if (is_median)
     {
         ds = MarketSeries.Median;
     }
     rsi = Indicators.RelativeStrengthIndex(ds, Period);
 }
Exemplo n.º 39
0
 protected override void Initialize()
 {
     rsi = Indicators.RelativeStrengthIndex(Source, Period);
     bbands = Indicators.BollingerBands(rsi.Result, Period, stdDev, MAType);
 }
Exemplo n.º 40
0
 protected override void Initialize()
 {
     // Initialize and create nested indicators
     macdCrossOver = Indicators.MacdCrossOver(source, longCycle, shortCycle, Periods);
     rsi = Indicators.RelativeStrengthIndex(source, Periods);
 }
Exemplo n.º 41
0
 protected override void OnStart()
 {
     rsi = Indicators.RelativeStrengthIndex(Source, Periods);
     ma = Indicators.MovingAverage(Source, MAPeriod, MAType);
 }
Exemplo n.º 42
0
        // func()

        protected override void OnStart()
        {
            // demonstrate using indicators easier to compute in pre-build cAlgo
            // code than to compute in the external system. 
            //rsiBase = Indicators.RelativeStrengthIndex(DataSeries, RSIPeriod);
            rsi = Indicators.RelativeStrengthIndex(Source, RSIPeriod);
            stdDev = Indicators.StandardDeviation(Source, RSIPeriod, MovingAverageType.Simple);
            var ticktype = MarketSeries.TimeFrame.ToString();
            fiName = DataDir + "\\" + "exp-" + Symbol.Code + "-" + ticktype + "-rsi" + RSIPeriod + "-stddev" + StdDevPeriod + "-bars.csv";
            Print("fiName=" + fiName);

            if (System.IO.Directory.Exists(DataDir) == false)
            {
                System.IO.Directory.CreateDirectory(DataDir);
            }

            if (System.IO.File.Exists(fiName) == false)
            {
                // generate new file with CSV header only if
                // one does not already exist. 
                System.IO.File.WriteAllText(fiName, csvhead);
            }
            else
            {
                maxDate = get_most_recent_date(fiName);
            }
            Print("maxDate=" + maxDate);

            // had to open file this way to prevent .net from locking it and preventing
            // access by other processes when using to download live ticks.
            fstream = File.Open(fiName, FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
            // setup to append to end of file
            Print("File is Open");
            fstream.Seek(0, SeekOrigin.End);
            // write stream has to be created after seek due to .net wierdness
            // creating with 0 prevents buffering since we want tick data
            // to be available to consumers right away.            
            fwriter = new System.IO.StreamWriter(fstream, System.Text.Encoding.UTF8, 1);
            // QUESTION:  How to tell when in Backtest mode so we
            //  can create the stream with a large buffer and turn off 
            // auto flush to improve IO performance.             
            Print("Fwriter is created");
            fwriter.AutoFlush = true;
            // with autoflush true will autocleanup 
            // since we can not close since we may run forever
            Print("done onStart()");
        }
Exemplo n.º 43
0
		protected override void OnStart()
        {
			_botName = ToString();
			_instanceLabel = string.Format("{0}-{1}-{2}-{3}", _botName, _botVersion, Symbol.Code, TimeFrame.ToString());
			rsi = Indicators.RelativeStrengthIndex(RsiSource, RsiPeriod);

            pipsATR = Indicators.GetIndicator<PipsATRIndicator>(TimeFrame, AtrPeriod, AtrMaType);

            minPipsATR = pipsATR.Result.Minimum(pipsATR.Result.Count);
            maxPipsATR = pipsATR.Result.Maximum(pipsATR.Result.Count);

        }
Exemplo n.º 44
0
 protected override void Initialize()
 {
     rsi = Indicators.RelativeStrengthIndex(Source, rsiperiods);
     sma = Indicators.SimpleMovingAverage(Source, smaperiods);
 }
Exemplo n.º 45
0
        protected override void OnStart()
        {
            _SOC = Indicators.StochasticOscillator(KPeriods, KSlowing, DPeriods, MovingAverageType.Simple);
            _MACD = Indicators.MacdCrossOver(LongCycle, ShortCycle, MACDPeriod);

            _RSI = Indicators.RelativeStrengthIndex(MarketSeries.Close, RSIPeriods);

            fastMa = Indicators.ExponentialMovingAverage(MarketSeries.Close, FastPeriods);
            slowMa = Indicators.ExponentialMovingAverage(MarketSeries.Close, SlowPeriods);

            TakeProfit = TakeProfit * 10;
            PipStart = PipStep / 10;
            PipStep = PipStep * 10;

            PipMulti = PipStep / 100;
        }
Exemplo n.º 46
0
 protected override void OnStart()
 {
     rsi = Indicators.RelativeStrengthIndex(Source, Periods);
 }
Exemplo n.º 47
0
 protected override void Initialize()
 {
     _cyclePrice = CreateDataSeries();
     _zeroLag = CreateDataSeries();
     _ma = Indicators.MovingAverage(MarketSeries.Close, PriceActionFilter, MaType);
     _rsi = Indicators.RelativeStrengthIndex(_cyclePrice, 14);
     _useCycleFilter = UseCycleFilter == 1;
 }
Exemplo n.º 48
0
 protected override void Initialize()
 {
     rsi = Indicators.RelativeStrengthIndex(DataSource, Period);
     value1 = CreateDataSeries();
 }
Exemplo n.º 49
0
 protected override void Initialize()
 {
     _fastEma = Indicators.ExponentialMovingAverage(MarketSeries.Close, FastEMA);
     _slowEma = Indicators.ExponentialMovingAverage(MarketSeries.Close, SlowEMA);
     iRSI = Indicators.RelativeStrengthIndex(MarketSeries.Close, RSIPeriod);
 }
Exemplo n.º 50
0
 protected override void Initialize()
 {
     _weightedMovingAverage = Indicators.WeightedMovingAverage(MarketSeries.Close, 21);
     _averageTrueRange = Indicators.GetIndicator<AverageTrueRange>(100);
     _relativeStrengthIndex = Indicators.RelativeStrengthIndex(TMA, rsiPeriod);
 }
Exemplo n.º 51
0
 protected override void Initialize()
 {
     rsi = Indicators.RelativeStrengthIndex(MarketSeries.Close, Period);
 }