示例#1
0
 public RiskStrategyLegacy(CandleSeries series, AverageTrueRange latr, AverageTrueRange satr)
 {
     _series  = series;
     LongATR  = latr;
     ShortATR = satr;
     PLB      = new ParabolicSar();
 }
示例#2
0
        /// <summary>
        /// Обработчик появления новых данных
        /// Вычисляет среднюю за период
        /// Вычисляет отклонение источника от средней за период
        /// </summary>
        ///// <param name="item">Bar</param>
        //public override void OnEvent(long id)
        public void Do(long id)
        {
            ///вычисляем новые занчения
            ///Input
            var    input             = Input.Value.ToList <Bar>();
            double iAverageTrueRange = TRx.Indicators.BarSource.Indicator.AverageTrueRange_i(
                input, input.Count - 1);

            AverageTrueRange.Add(iAverageTrueRange);

            ///вызываем обработчики значений
            foreach (var handler in HandlersAverageTrueRange)
            {
                handler.Invoke(AverageTrueRange.Last());
            }

            ///упаковка посчитанных значений
            ValueAverageTrueRange.Add(new ValueDouble()
            {
                Id = id,
                //DateTime = item.DateTime,
                //TODO 4. сейчас отрисовывается по имени MaFast, надо переделать на стороне отрисовки
                Name  = "AverageTrueRange",
                Value = iAverageTrueRange
            });

            ///отправка посчитанных значений
            foreach (var handler in HandlersValueAverageTrueRange)
            {
                handler.Invoke(ValueAverageTrueRange.Last());
            }
        }
示例#3
0
        public void AnalyzeATR(XSymbol xs, int minutes, int atrLength)
        {
            var candles = m_maker.ReadCandles(xs.Exchange, xs.Symbol, minutes);
            var atr     = new AverageTrueRange(candles, atrLength);

            atr.Values.ToList().ForEach(kv => Console.WriteLine("{0,20}   {1:0.00000000}", kv.Key, kv.Value));
        }
        /// <summary>
        /// Calculate the normalized Maximum Favorable Excursion and Maximum Adversed Excursion for a given point
        /// </summary>
        /// <param name="bars"></param>
        /// <param name="barIndex"></param>
        /// <returns></returns>
        public static void CalculateNormalizedMfeAndMae(Bar[] bars, int barIndex, out double[] mfe, out double[] mae)
        {
            AverageTrueRange atr = new AverageTrueRange(ERatioAtrWindowSize);
            int startIndex       = Math.Max(0, barIndex - ERatioAtrWindowSize);

            for (int i = startIndex; i < barIndex; ++i)
            {
                atr.Update(bars[i]);
            }

            double initialPrice = bars[barIndex].ClosePrice;

            mfe = new double[ERatioWindowSizes.Length];
            mae = new double[ERatioWindowSizes.Length];

            for (int i = 0; i < ERatioWindowSizes.Length; ++i)
            {
                var windowSize = ERatioWindowSizes[i];

                var highestPrice = Enumerable
                                   .Range(barIndex, Math.Min(bars.Length - barIndex, windowSize))
                                   .Max(index => bars[index].ClosePrice);

                var lowestPrice = Enumerable
                                  .Range(barIndex, Math.Min(bars.Length - barIndex, windowSize))
                                  .Min(index => bars[index].ClosePrice);

                mfe[i] = (highestPrice - initialPrice) / atr.Value;
                mae[i] = (initialPrice - lowestPrice) / atr.Value;
            }
        }
示例#5
0
 protected override void OnStart()
 {
     Positions.Opened += OnPositionOpen;
     tm            = new TradeManager(this);
     _announceTime = Convert.ToDateTime(AnnounceDateTime);
     _atr          = Indicators.AverageTrueRange(14, MovingAverageType.Simple);
 }
        //-----------------------------------------------------------------------------------------------
        // SCALPER SIGNAL FUNCTION ----------------------------------------------------------------------
        //-----------------------------------------------------------------------------------------------
        private void SignalScalper_Main(int index)
        {
            if (!NewBar(index) || (index < 6))
            {
                return;
            }

            ATR = Indicators.AverageTrueRange(14, MovingAverageType.Exponential);

            double bs = BuySignal(index);
            double ss = SellSignal(index);

            if (bs > 0)
            {
                BuyIndicator[index]      = bs;
                SignalBarHigh[index - 3] = MarketSeries.High[index - 3];
                SignalBarLow[index - 3]  = MarketSeries.Low[index - 3];
                ChartObjects.DrawLine("SignalBar" + (index - 3), index - 3, SignalBarHigh[index - 3], index - 3, SignalBarLow[index - 3], Colors.Gold, 3, LineStyle.Solid);
            }
            else if (ss > 0)
            {
                SellIndicator[index]     = ss;
                SignalBarHigh[index - 3] = MarketSeries.High[index - 3];
                SignalBarLow[index - 3]  = MarketSeries.Low[index - 3];
                ChartObjects.DrawLine("SignalBar" + (index - 3), index - 3, SignalBarHigh[index - 3], index - 3, SignalBarLow[index - 3], Colors.Gold, 3, LineStyle.Solid);
            }
        }
        protected override void OnStart()
        {
            Print("Lot sizing rule: {0}", LotSizingRule);

            var symbolLeverage = Symbol.DynamicLeverage[0].Leverage;

            Print("Symbol leverage: {0}", symbolLeverage);

            var realLeverage = Math.Min(symbolLeverage, Account.PreciseLeverage);

            Print("Account leverage: {0}", Account.PreciseLeverage);

            Init(true,
                 false,
                 InitialStopLossRuleValues.None,
                 InitialStopLossInPips,
                 TrailingStopLossRule,
                 TrailingStopLossInPips,
                 LotSizingRule,
                 TakeProfitRuleValues.None,
                 0,
                 0,
                 false,
                 false,
                 DynamicRiskPercentage,
                 BarsToAllowTradeToDevelop);

            _atr    = Indicators.AverageTrueRange(14, MovingAverageType.Exponential);
            _spring = Indicators.GetIndicator <Spring>(SourceSeries, 89, 55, 21, SendEmailAlerts, PlayAlertSound, ShowMessage,
                                                       SignalBarRangeMultiplier, MaFlatFilter, BreakoutFilter, MinimumBarsForLowestLow, SwingHighStrength, BigMoveFilter);
            _minimumBuffer      = Symbol.PipSize * 6;
            _timeFrameInMinutes = GetTimeFrameInMinutes();
        }
示例#8
0
        /// <summary>
        /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
        /// </summary>
        /// <seealso cref="QCAlgorithm.SetStartDate(System.DateTime)"/>
        /// <seealso cref="QCAlgorithm.SetEndDate(System.DateTime)"/>
        /// <seealso cref="QCAlgorithm.SetCash(decimal)"/>
        public override void Initialize()
        {
            UniverseSettings.Leverage   = 1m;
            UniverseSettings.Resolution = Resolution.Daily;

            //Initialize dates
            SetStartDate(1995, 01, 01);
            SetEndDate(2015, 08, 15);
            SetCash(25000);

            var averages = new ConcurrentDictionary <string, SelectionData>();

            SetUniverse(coarse => (from cf in coarse
                                   let avg = averages.GetOrAdd(cf.Symbol, sym => new SelectionData())
                                             where avg.Update(cf.EndTime, cf.Price)
                                             // only pick symbols who have Close > 100 day MA and < 5 day MA
                                             where cf.Price > avg.SMA100 && cf.Price < avg.SMA5
                                             orderby cf.Volume descending
                                             select cf).Take(Count));

            //Add as many securities as you like. All the data will be passed into the event handler:
            //AddSecurity(SecurityType.Equity, symbol, Resolution.Minute);

            #region indicators

            Price     = new RollingWindow <IndicatorDataPoint>(14);
            Lows      = new RollingWindow <IndicatorDataPoint>(4);
            LowerLows = false;
            ATR       = this.ATR("ATR10", 10, MovingAverageType.Simple, Resolution.Daily);

            #endregion
        }
示例#9
0
 protected override void Initialize()
 {
     FastMA = Indicators.MovingAverage(MarketSeries.Close, Fast_Period, MA_Type);
     SlowMA = Indicators.MovingAverage(MarketSeries.Open, Slow_Period, MA_Type);
     ATR    = Indicators.AverageTrueRange(14, MovingAverageType.Simple);
     count  = MarketSeries.Open.Count;
 }
        // Retrieve the current list of ATR values
        private AverageTrueRange GetCurrentATR(XSymbol xs, int minutes, int atrLength)
        {
            var candles = m_maker.GetRecentCandles(xs, minutes);
            var atr     = new AverageTrueRange(candles, atrLength);

            return(atr);
        }
示例#11
0
文件: Bot.cs 项目: bildukas86/bots
        protected override void Initialize()
        {
            // Summary
            YesterdayKeyLevels = Business.KeyLevels.GetYesterdaysKeyLevels(Account.BrokerName, Symbol.Code);

            if (YesterdayKeyLevels != null)
            {
                YesterdayKeyLevels.CalculateDaily();

                // Write Summary
                string Summary = Symbol.Code.ToString() + ": Yesterday's (" + YesterdayKeyLevels.Date.ToShortDateString() + ") Open: " + YesterdayKeyLevels.Open.ToString() + ", Close: " + YesterdayKeyLevels.Close.ToString() + ", High: " + YesterdayKeyLevels.High.ToString() + ", Low: " + YesterdayKeyLevels.Low.ToString();
                ChartObjects.DrawText("Previous", Summary, StaticPosition.BottomRight, Colors.Red);

                // Calculate ATR
                var ATRSeries        = MarketData.GetSeries(TimeFrame.Daily);
                AverageTrueRange ATR = Indicators.AverageTrueRange(ATRSeries, 5, MovingAverageType.Simple);
                ChartObjects.DrawText("ATR", "ATR: " + ATR.Result.LastValue.ToString("0.##") + ", 15% ATR: " + (ATR.Result.LastValue * 0.15).ToString("0.##") + ",30% ATR: " + (ATR.Result.LastValue * 0.3).ToString("0.##") + "", StaticPosition.TopRight, Colors.Red);

                // DAILY
                //  ChartObjects.DrawHorizontalLine("DailyHigh", YesterdayKeyLevels.High,  Colors.Green, 1, LineStyle.LinesDots);
                //  ChartObjects.DrawHorizontalLine("DailyLow", YesterdayKeyLevels.Low, Colors.Green, 1, LineStyle.LinesDots);
                // ChartObjects.DrawHorizontalLine("DailyCLose", YesterdayKeyLevels.Close, Colors.Green, 1, LineStyle.LinesDots);



                // Daily Levels

                P = ((YesterdayKeyLevels.High + YesterdayKeyLevels.Low + YesterdayKeyLevels.Close) / 3);

                R1 = ((2 * P) - YesterdayKeyLevels.Low);
                R2 = (P + YesterdayKeyLevels.High - YesterdayKeyLevels.Low);
                R3 = (YesterdayKeyLevels.High + 2 * (P - YesterdayKeyLevels.Low));

                S1 = ((2 * P) - YesterdayKeyLevels.High);
                S2 = (P - YesterdayKeyLevels.High + YesterdayKeyLevels.Low);
                S3 = YesterdayKeyLevels.Low - 2 * (YesterdayKeyLevels.High - P);

                CBOL = ((YesterdayKeyLevels.High - YesterdayKeyLevels.Low) * 1.1 / 2 + YesterdayKeyLevels.Close);
                CBOS = YesterdayKeyLevels.Close - (YesterdayKeyLevels.High - YesterdayKeyLevels.Low) * 1.1 / 2;



                //WP = ((WeeklyHigh + WeeklyLow + WeeklyClose) / 3);
                //MP = ((MonthlyHigh + MonthlyLow + MonthlyClose) / 3);



                // WEEKLY
                // ChartObjects.DrawHorizontalLine("WeeklyHigh", WeeklyHigh, Colors.Green, 1, LineStyle.Lines);
                //ChartObjects.DrawHorizontalLine("WeeklyLow", WeeklyLow, Colors.Red, 1, LineStyle.Lines);
                //   ChartObjects.DrawHorizontalLine("WeeklyClose", WeeklyClose, Colors.DeepSkyBlue, 1, LineStyle.LinesDots);


                // MONTHLY
                //ChartObjects.DrawHorizontalLine("MonthlyHigh", MonthlyHigh, Colors.Green, 3, LineStyle.Lines);
                //ChartObjects.DrawHorizontalLine("MonthlyLow", MonthlyLow, Colors.Red, 3, LineStyle.Lines);
                //   ChartObjects.DrawHorizontalLine("MonthlyClose", MonthlyClose, Colors.DarkGray, 1, LineStyle.LinesDots);
            }
        }
示例#12
0
        protected override void OnStart()
        {
            Positions.Closed += OnPositionsClosed;
            Positions.Opened += OnPositionsOpened;

            atr = Indicators.AverageTrueRange(atrPeriod, MovingAverageType.Simple);
            InitialZoneRecovery();
        }
示例#13
0
 protected override void OnStart()
 {
     fastMa   = Indicators.MovingAverage(SourceSeries, FastPeriods, MAType);
     mediumMa = Indicators.MovingAverage(SourceSeries, mediumPeriods, MAType);
     slowMa   = Indicators.MovingAverage(SourceSeries, SlowPeriods, MAType);
     atr      = Indicators.AverageTrueRange(atrPeriod, MAType);
     bBand    = Indicators.BollingerBands(SourceSeries, bBandPeriods, bBandDeviations, MAType);
 }
示例#14
0
 protected override void Initialize()
 {
     // Initialize and create nested indicators
     _fastMA = Indicators.MovingAverage(Source, FastPeriodParameter, MovingAverageType.Exponential);
     _slowMA = Indicators.MovingAverage(Source, SlowPeriodParameter, MovingAverageType.Exponential);
     _swingHighLowIndicator = Indicators.GetIndicator <SwingHighLow>(Bars.HighPrices, Bars.LowPrices, SwingHighStrength);
     _atr = Indicators.AverageTrueRange(14, MovingAverageType.Exponential);
 }
示例#15
0
        /// <summary>
        /// Creates a new AverageTrueRange indicator for the symbol. The indicator will be automatically
        /// updated on the given resolution.
        /// </summary>
        /// <param name="symbol">The symbol whose ATR we want</param>
        /// <param name="period">The smoothing period used to smooth the computed TrueRange values</param>
        /// <param name="type">The type of smoothing to use</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>A new AverageTrueRange indicator with the specified smoothing type and period</returns>
        public AverageTrueRange ATR(string symbol, int period, MovingAverageType type = MovingAverageType.Simple, Resolution?resolution = null, Func <BaseData, TradeBar> selector = null)
        {
            string name = CreateIndicatorName(symbol, "ATR" + period, resolution);
            var    atr  = new AverageTrueRange(name, period, type);

            RegisterIndicator(symbol, atr, resolution, selector);
            return(atr);
        }
示例#16
0
        protected override void Initialize()
        {
            _atr    = Indicators.AverageTrueRange(14, MovingAverageType.Exponential);
            _buffer = Symbol.PipSize * 5;
            //_fastMA = Indicators.ExponentialMovingAverage(SourceSeries, FastMAPeriod);

            //var h4 = MarketData.GetSeries(TimeFrame.Hour4);
            //_slowMA = Indicators.ExponentialMovingAverage(h4.Close, H4Periods);
        }
示例#17
0
        public async Task TestAtrAsync()
        {
            var equity = await ImportEquityAsync();

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

            Assert.IsTrue(1.372m.IsApproximatelyEquals(result.Atr.Value));
        }
示例#18
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);
 }
示例#19
0
 protected override void OnStart()
 {
     //fastMa = Indicators.MovingAverage(SourceSeries, FastPeriods, MAType);
     //mediumMa = Indicators.MovingAverage(SourceSeries, mediumPeriods, MAType);
     //slowMa = Indicators.MovingAverage(SourceSeries, SlowPeriods, MAType);
     atr   = Indicators.AverageTrueRange(atrPeriod, MAType);
     bBand = Indicators.BollingerBands(SourceSeries, bBandPeriods, bBandDeviations, MAType);
     _kama = Indicators.GetIndicator <KAMASignal>(Source, Fast, Slow, Period);
 }
示例#20
0
        public async Task TestAtrAsync()
        {
            var candles = await ImportCandlesAsync();

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

            Assert.IsTrue(1.372m.IsApproximatelyEquals(result.Value));
        }
示例#21
0
        protected override void OnStart()
        {
            dc1 = Indicators.DonchianChannel(dcPeriod1);
            dc2 = Indicators.DonchianChannel(dcPeriod2);

            ema1 = Indicators.ExponentialMovingAverage(MarketSeries.Close, emaPeriod1);
            ema2 = Indicators.ExponentialMovingAverage(MarketSeries.Close, emaPeriod2);

            atr = Indicators.AverageTrueRange(atrPeriod, MovingAverageType.Exponential);
        }
示例#22
0
        public void ComparesAgainstExternalData()
        {
            var atrSimple = new AverageTrueRange(14, MovingAverageType.Simple);

            TestHelper.TestIndicator(atrSimple, "spy_atr.txt", "Average True Range 14");

            var atrWilders = new AverageTrueRange(14, MovingAverageType.Wilders);

            TestHelper.TestIndicator(atrWilders, "spy_atr_wilder.txt", "Average True Range 14");
        }
示例#23
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;
        }
示例#24
0
        public static void SetChartViewModelPriceData(IList <Candle> candles, ChartViewModel cvm)
        {
            var priceDataSeries = new OhlcDataSeries <DateTime, double>();
            var xvalues         = new List <DateTime>();
            var openValues      = new List <double>();
            var highValues      = new List <double>();
            var lowValues       = new List <double>();
            var closeValues     = new List <double>();

            var atr = new AverageTrueRange();

            for (var i = 0; i < candles.Count; i++)
            {
                var time = new DateTime(candles[i].CloseTimeTicks, DateTimeKind.Utc).ToLocalTime();

                xvalues.Add(time);
                openValues.Add((double)candles[i].OpenBid);
                highValues.Add((double)candles[i].HighBid);
                lowValues.Add((double)candles[i].LowBid);
                closeValues.Add((double)candles[i].CloseBid);
            }

            priceDataSeries.Append(xvalues, openValues, highValues, lowValues, closeValues);
            priceDataSeries.SeriesName = "Price";

            var pricePaneVm = cvm.ChartPaneViewModels.Count > 0 ? cvm.ChartPaneViewModels[0] : null;
            var atrPaneVm   = cvm.ChartPaneViewModels.Count > 1 ? cvm.ChartPaneViewModels[1] : null;

            if (pricePaneVm == null)
            {
                pricePaneVm = new ChartPaneViewModel(cvm, cvm.ViewportManager)
                {
                    IsFirstChartPane = true,
                    IsLastChartPane  = false
                };

                var series = new FastCandlestickRenderableSeries {
                    AntiAliasing = false
                };
                series.SetValue(FilteringLegendModifier.IncludeSeriesProperty, false);
                series.SeriesColor = Colors.DarkBlue;
                pricePaneVm.ChartSeriesViewModels.Add(new ChartSeriesViewModel(priceDataSeries, series));
                cvm.ChartPaneViewModels.Add(pricePaneVm);
            }
            else
            {
                pricePaneVm.ChartSeriesViewModels.Clear();
                var renderableSeries = new FastCandlestickRenderableSeries {
                    AntiAliasing = false
                };
                renderableSeries.SetValue(FilteringLegendModifier.IncludeSeriesProperty, false);
                pricePaneVm.ChartSeriesViewModels.Add(new ChartSeriesViewModel(priceDataSeries, renderableSeries));
            }
        }
示例#25
0
        protected override void OnStart()
        {
            _maCrossIndicator = Indicators.GetIndicator <MACrossOver>(SourceSeries, SlowPeriodParameter, MediumPeriodParameter, FastPeriodParameter, false, false, false);
            _fastMA           = Indicators.MovingAverage(SourceSeries, FastPeriodParameter, MovingAverageType.Exponential);
            _mediumMA         = Indicators.MovingAverage(SourceSeries, MediumPeriodParameter, MovingAverageType.Exponential);
            _slowMA           = Indicators.MovingAverage(SourceSeries, SlowPeriodParameter, MovingAverageType.Exponential);
            _rsi = Indicators.RelativeStrengthIndex(SourceSeries, 14);
            _atr = Indicators.AverageTrueRange(Bars, 14, MovingAverageType.Exponential);

            Print("Take Longs: {0}", TakeLongsParameter);
            Print("Take Shorts: {0}", TakeShortsParameter);
            Print("Initial SL rule: {0}", InitialStopLossRule);
            Print("Initial SL in pips: {0}", InitialStopLossInPips);
            Print("Trailing SL rule: {0}", TrailingStopLossRule);
            Print("Trailing SL in pips: {0}", TrailingStopLossInPips);
            Print("Lot sizing rule: {0}", LotSizingRule);
            Print("Take profit rule: {0}", TakeProfitRule);
            Print("Take profit in pips: {0}", TakeProfitInPips);
            Print("Minutes to wait after position closed: {0}", MinutesToWaitAfterPositionClosed);
            Print("Move to breakeven: {0}", MoveToBreakEven);
            Print("Close half at breakeven: {0}", CloseHalfAtBreakEven);
            Print("MA Cross Rule: {0}", MaCrossRule);
            Print("H4MA: {0}", H4MaPeriodParameter);
            Print("Recording: {0}", RecordSession);
            Print("Enter at Market: {0}", EnterAtMarket);
            Print("BarsToAllowTradeToDevelop: {0}", BarsToAllowTradeToDevelop);

            Init(TakeLongsParameter,
                 TakeShortsParameter,
                 InitialStopLossRule,
                 InitialStopLossInPips,
                 TrailingStopLossRule,
                 TrailingStopLossInPips,
                 LotSizingRule,
                 TakeProfitRule,
                 TakeProfitInPips,
                 MinutesToWaitAfterPositionClosed,
                 MoveToBreakEven,
                 CloseHalfAtBreakEven,
                 DynamicRiskPercentage,
                 BarsToAllowTradeToDevelop);

            Notifications.SendEmail("*****@*****.**", "*****@*****.**", "MA Cross Over robot initialized", "This is a test");

            if (RecordSession)
            {
                _runId = SaveRunToDatabase();
                if (_runId <= 0)
                {
                    throw new InvalidOperationException("Run Id was <= 0!");
                }
            }
        }
示例#26
0
 /// <summary>
 /// Average Directional Index (ADX) is a technical analysis indicator used by some traders to determine the strength of a trend.
 /// </summary>
 /// <param name="highPrices">High price of the asset.</param>
 /// <param name="lowPrices">Low price of the asset.</param>
 /// <param name="closePrices">Close price of the asset.</param>
 public AverageDirectionalIndex(decimal[] highPrices, decimal[] lowPrices, decimal[] closePrices)
 {
     new DataErrors().ValidData("ADX", highPrices.Length, lowPrices.Length, closePrices.Length);
     Period        = 14;
     ATR           = new AverageTrueRange(highPrices, lowPrices, closePrices).ATRArray;
     PlusDMIArray  = GetDMI(ATR, GetSmoothDX(highPrices, lowPrices, DX.Plus));
     MinusDMIArray = GetDMI(ATR, GetSmoothDX(highPrices, lowPrices, DX.Minus));
     ADXArray      = GetADX();
     ADX           = ADXArray[0];
     PlusDMI       = PlusDMIArray[0];
     MinusDMI      = MinusDMIArray[0];
 }
示例#27
0
 protected override void Initialize()
 {
     _atr       = Indicators.AverageTrueRange(lookBack, MovingAverageType.Exponential);
     _shortExit = CreateDataSeries();
     _longExit  = CreateDataSeries();
     isTick     = MarketSeries.TimeFrame.ToString() == "Tick" ? true : false;
     if (isTick)
     {
         //intantiate bid/ask buffers
         _bids = new CircularBuffer <double>(lookBack);
         _asks = new CircularBuffer <double>(lookBack);
     }
 }
示例#28
0
        protected override void Initialize()
        {
            // Initialize and create nested indicators
            Print("Initializing Resistence Break indicator");

            _swingHighLowIndicator = Indicators.GetIndicator <SwingHighLow>(Bars.ClosePrices, Bars.ClosePrices, SwingHighStrength);
            _atr = Indicators.AverageTrueRange(14, MovingAverageType.Exponential);
            _latestSignalIndex = 0;

            Print("Finished initializing");

            //GoToTestDate();
        }
示例#29
0
        protected TrendingMABase(QREBridgeBase bridge, Symbol symbol, Converter <BarSpud, Spud <double> > signalSeries) : base(bridge, symbol)
        {
            maDays      = parameter <int>("MADays");
            riskDollars = parameter <double>("RiskDollars");
            atr         = new AverageTrueRange(bars, parameter <int>("ATRLen"));
            signal      = signalSeries(bars);
            ma          = new Average(signal, maDays);
            shortSum    = new Sum(signal, maDays - 1);
            var numDeviations = parameter <double>("BollingerBandDeviations");
            var barsBack      = parameter <int>("BollingerBandBarsBack");

            upperBand = new BollingerBand(ma, barsBack, numDeviations);
            lowerBand = new BollingerBand(ma, barsBack, -numDeviations);
        }
示例#30
0
        protected override void OnStart()
        {
            hmafast      = Indicators.GetIndicator <HMAfast>(5);
            hmaslow      = Indicators.GetIndicator <HMAslow>(31);
            _macd        = Indicators.MacdHistogram(LongCycle, ShortCycle, Period);
            HmaDaySeries = MarketData.GetSeries(TimeFrame.Hour4);
            hmaSignal    = Indicators.GetIndicator <HMASignals>(HmaDaySeries, 21, false, false, 3, false, 24);

            var dailySeries = MarketData.GetSeries(TimeFrame.Daily);

            atr = Indicators.AverageTrueRange(dailySeries, 20, MovingAverageType.Simple);

            Positions.Opened += PositionsOnOpened;
            Positions.Closed += PositionsOnClosed;
        }
示例#31
0
 protected override void Initialize()
 {
     _atr = Indicators.AverageTrueRange(Period, MAType);
 }
示例#32
0
 protected override void Initialize()
 {
     _atr = Indicators.AverageTrueRange(Period, MovingAverageType.Exponential);
 }