コード例 #1
0
        /// <summary>
        /// Creates a new On Balance Volume indicator. This will compute the cumulative total volume
        /// based on whether the close price being higher or lower than the previous period.
        /// The indicator will be automatically updated on the given resolution.
        /// </summary>
        /// <param name="symbol">The symbol whose On Balance Volume we seek</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 casting the input value to a TradeBar</param>
        /// <returns>The On Balance Volume indicator for the requested symbol.</returns>
        public OnBalanceVolume OBV(string symbol, Resolution?resolution = null, Func <BaseData, TradeBar> selector = null)
        {
            var name            = CreateIndicatorName(symbol, "OBV", resolution);
            var onBalanceVolume = new OnBalanceVolume(name);

            RegisterIndicator(symbol, onBalanceVolume, resolution, selector);
            return(onBalanceVolume);
        }
コード例 #2
0
        public void ComparesAgainstExternalData()
        {
            var onBalanceVolumeIndicator = new OnBalanceVolume("OBV");

            TestHelper.TestIndicator(onBalanceVolumeIndicator, "spy_with_obv.txt", "OBV",
                                     (ind, expected) => Assert.AreEqual(
                                         expected.ToString("0.##E-00"),
                                         (onBalanceVolumeIndicator.Current.Value).ToString("0.##E-00")
                                         )
                                     );
        }
コード例 #3
0
        public async Task TestObvAsync()
        {
            var candles = await ImportCandlesAsync();

            var indicator = new OnBalanceVolume(candles);
            var result0   = indicator[candles.Count - 1];
            var result1   = indicator[candles.Count - 2];
            var result2   = indicator[candles.Count - 3];

            Assert.IsTrue(result0 - result1 > 0 && result1 - result2 < 0);
        }
コード例 #4
0
        public async Task TestObvAsync()
        {
            var equity = await ImportEquityAsync();

            var indicator = new OnBalanceVolume(equity);
            var result0   = indicator.ComputeByIndex(equity.Count - 1);
            var result1   = indicator.ComputeByIndex(equity.Count - 2);
            var result2   = indicator.ComputeByIndex(equity.Count - 3);

            Assert.IsTrue(result0.Obv - result1.Obv > 0 && result1.Obv - result2.Obv < 0);
        }
コード例 #5
0
        // other filter indicator 1


        // other filter indicator 2


        // exit indicator

/*
 *          private HeikenAshiDirection i_ha;
 */


        #endregion

        #region cTrader events

        protected override void OnStart()
        {
            // Instantiate Indicators
            i_atr = Indicators.AverageTrueRange(14, MovingAverageType.Exponential);
            i_obv = Indicators.OnBalanceVolume(Source);
            //i_ha = Indicators.GetIndicator<HeikenAshiDirection>();


            Positions.Opened += PositionsOnOpened;
            Positions.Closed += PositionsOnClosed;
        }
コード例 #6
0
        public void ResetsProperly()
        {
            var onBalanceVolumeIndicator = new OnBalanceVolume("OBV");

            foreach (var data in TestHelper.GetTradeBarStream("spy_with_obv.txt", false))
            {
                onBalanceVolumeIndicator.Update(data);
            }

            Assert.IsTrue(onBalanceVolumeIndicator.IsReady);

            onBalanceVolumeIndicator.Reset();
        }
コード例 #7
0
        protected override void OnStart()
        {
            _botName       = ToString();
            _instanceLabel = string.Format("{0}-{1}-{2}-{3}-{4}", _botName, _botVersion, Symbol.Code, TimeFrame.ToString(), GlobalTimeFrame.ToString());
            tendency       = Indicators.GetIndicator <CandlestickTendencyII>(GlobalTimeFrame, MinimumGlobalCandleSize);
            tendency2      = Indicators.GetIndicator <CandlestickTendencyII_2>(GlobalTimeFrame2, MinimumGlobalCandleSize2);
            //_emaFast = Indicators.ExponentialMovingAverage(Price, FastPeriods);
            _adx    = Indicators.GetIndicator <ADXR>(Source, interval);
            _heiken = Indicators.GetIndicator <HeikenAshi2>(1);
            _kama   = Indicators.GetIndicator <kama1>(Period, FastPeriod, SlowPeriod);
            Fischer = Indicators.GetIndicator <FisherTransform>(Len);
            //COG = Indicators.GetIndicator<CenterOfGravityOscillator>(Length);
            pipsATR          = Indicators.GetIndicator <PipsATRIndicator>(TimeFrame, AtrPeriod, AtrMaType);
            _onBalanceVolume = Indicators.OnBalanceVolume(Source);

            minPipsATR = pipsATR.Result.Minimum(pipsATR.Result.Count);
            maxPipsATR = pipsATR.Result.Maximum(pipsATR.Result.Count);
        }
コード例 #8
0
        public void ComparesAgainstExternalData()
        {
            var onBalanceVolumeIndicator = new OnBalanceVolume("OBV")
            {
                Current =
                {
                    Time  = new DateTime(2013,                             4, 30),
                    Value = decimal.Parse("1.156486E+08", NumberStyles.Float, CultureInfo.InvariantCulture)
                }
            };

            TestHelper.TestIndicator(onBalanceVolumeIndicator, "spy_with_obv.txt", "OBV",
                                     (ind, expected) => Assert.AreEqual(
                                         expected.ToString("0.##E-00"),
                                         (onBalanceVolumeIndicator.Current.Value).ToString("0.##E-00")
                                         )

                                     );
        }
コード例 #9
0
 protected override void Initialize()
 {
     obv = Indicators.OnBalanceVolume(Bars.ClosePrices);
     ma  = Indicators.MovingAverage(OBV, Period, MAType);
 }
コード例 #10
0
        private void BData_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
            {
                var candle        = (BinanceCandle)e.NewItems[0];
                var TPC           = (candle.Candle.High + candle.Candle.Low + candle.Candle.Close) / 3;
                var TPVM          = TPC * candle.Candle.Volume;
                var RawData       = Starter.core.Candles.Select(y => y.Candle).ToList();
                int countIndex    = RawData.Count - 1;
                var indexdcandles = new IndexedCandle(RawData, RawData.Count() - 1);
                //public static class OhlcvExtension

                //zone to update with TA - Node (temporary here)
                try
                {
                    var rsi        = RawData.Rsi(12, 0, countIndex);
                    var bb         = RawData.BbWidth(20, 2);
                    var macd       = RawData.Macd(7, 10, 12);
                    var chandelier = RawData.Chandlr(14, 22);
                    var ichimoku   = RawData.Ichimoku(9, 26, 52);
                    var KAMA       = RawData.Kama(21, 12, 32);
                    var Median     = RawData.Median(12);
                    var PSAR       = RawData.Sar(0.2m, 0.2m);
                    var DM         = new DownMomentum(RawData);
                    var bbw        = new BollingerBands(RawData, 20, 2);
                    var UM         = new UpMomentum(RawData);
                    var Bullish    = new Bullish(RawData);
                    var Bearish    = new Bearish(RawData);
                    var trendup    = new UpTrend(RawData);
                    var trenddown  = new DownTrend(RawData);
                    var dmi        = new DynamicMomentumIndex(RawData, 14, 30, 12, 70, 30);
                    var minusDI    = new MinusDirectionalIndicator(RawData, 12);
                    var truerange  = new TrueRange(RawData);
                    var efratio    = new EfficiencyRatio(RawData, 12);
                    var obv        = new OnBalanceVolume(RawData);
                    var sthrsi     = new StochasticsRsiOscillator(RawData, 12);
                    if (rsi.Count() > 0)
                    {
                        //TA
                        candle.Properties.Add("RSI", rsi.Last().Tick);
                        candle.Properties.Add("DOWNMOMENTUM", DM.Compute(12).Last().Tick);
                        candle.Properties.Add("UPMOMENTUM", UM.Compute(12).Last().Tick);
                        candle.Properties.Add("MACD", macd.Last().Tick);
                        candle.Properties.Add("BB", bb.Last().Tick);
                        candle.Properties.Add("bbw", bbw.Compute().Last().Tick);
                        candle.Properties.Add("PSAR", PSAR.Last().Tick);
                        candle.Properties.Add("CHANDELIEREXIT", chandelier.Last().Tick);
                        candle.Properties.Add("ichimoku", ichimoku.Last().Tick);
                        candle.Properties.Add("KAMA", KAMA.Last().Tick);
                        candle.Properties.Add("Median", Median.Last().Tick);
                        candle.Properties.Add("DynamicMomentumIndex", dmi.Compute(12).Last().Tick);
                        candle.Properties.Add("MinusDirectionalIndicator", minusDI.Compute(12).Last().Tick);
                        candle.Properties.Add("TrueRange", truerange.Compute(12).Last().Tick);
                        candle.Properties.Add("EfficiencyRatio", efratio.Compute(12).Last().Tick);
                        candle.Properties.Add("OnBalanceVolume", obv.Compute(12).Last().Tick);
                        candle.Properties.Add("StochasticsRsiOscillator", sthrsi.Compute(12).Last().Tick);

                        //Pattern Periodic
                        candle.Properties.Add("BullishPeriodic_L1", Bullish.Compute(12).Last().Tick);
                        candle.Properties.Add("BearishPeriodic_L1", Bearish.Compute(12).Last().Tick);
                        candle.Properties.Add("UptrendPeriodic_L1", trendup.Compute(12).Last().Tick);
                        candle.Properties.Add("DowntrendPeriodic_L1", trenddown.Compute(12).Last().Tick);
                        Console.WriteLine(candle.ToString());

                        //candle.Properties.Add("BullishPeriodic_L2", Bullish.Compute(24).Last().Tick);
                        //candle.Properties.Add("BearishPeriodic_L2", Bearish.Compute(24).Last().Tick);
                        //candle.Properties.Add("UptrendPeriodic_L2", trendup.Compute(24).Last().Tick);
                        //candle.Properties.Add("DowntrendPeriodic_L2", trenddown.Compute(24).Last().Tick);


                        //candle.Properties.Add("BullishPeriodic_L3", Bullish.Compute(36).Last().Tick);
                        //candle.Properties.Add("BearishPeriodic_L3", Bearish.Compute(36).Last().Tick);
                        //candle.Properties.Add("UptrendPeriodic_L3", trendup.Compute(36).Last().Tick);
                        //candle.Properties.Add("DowntrendPeriodic_L3", trenddown.Compute(36).Last().Tick);

                        //PatternInject
                        candle.Properties.Add("bearish", indexdcandles.IsBearish());
                        candle.Properties.Add("isbullish", indexdcandles.IsBullish());
                        candle.Properties.Add("isaccumdistbearish", indexdcandles.IsAccumDistBearish());
                        candle.Properties.Add("isaccumdistbullish", indexdcandles.IsAccumDistBullish());
                        candle.Properties.Add("closepricepercentagechange", indexdcandles.ClosePricePercentageChange());
                        candle.Properties.Add("closepricechange", indexdcandles.ClosePriceChange());
                        candle.Properties.Add("isbreakinghistoricalhighestclose", indexdcandles.IsBreakingHistoricalHighestClose());
                        candle.Properties.Add("isbreakinghistoricalhighesthigh", indexdcandles.IsBreakingHistoricalHighestHigh());
                        candle.Properties.Add("isbreakinghistoricallowestlow", indexdcandles.IsBreakingHistoricalLowestLow());
                        candle.Properties.Add("isobvbearish", indexdcandles.IsObvBearish());
                        candle.Properties.Add("isobvbullish", indexdcandles.IsObvBullish());
                        candle.UpdateContainer();
                    }
                }
                catch { }
                var LastBinanceCandle = (BinanceCandle)e.NewItems[0];

                Console.WriteLine("Market Node - Sending candle : {0} to suscribers", LastBinanceCandle.UID);
                Messages Content = new Messages();
                Content.Content      = candle.Jscontainer;
                Content.MessageType  = TypeOfContent.Binance_Candles;
                Content.RootType     = candle.TypeOfData;
                Content.TargetObject = "BinanceCandle";
                try
                {
                    Send(Content.ToString());
                    this.Starter.core.Candles.Clear();
                }
                catch
                {
                }
            }
        }
コード例 #11
0
ファイル: OnBalanceVolumeTrend.cs プロジェクト: yangar/Trady
 public OnBalanceVolumeTrend(Equity equity) : base(equity)
 {
     _obvIndicator = new OnBalanceVolume(equity);
 }