コード例 #1
0
 protected override void OnStartUp()
 {
     Plots[0].Pen.Width     = plot0Width;
     Plots[0].PlotStyle     = plot0Style;
     Plots[0].Pen.DashStyle = dash0Style;
     Plots[1].Pen.Width     = plot1Width;
     Plots[1].PlotStyle     = plot1Style;
     Plots[1].Pen.DashStyle = dash1Style;
     candles = false;
     if (ChartControl != null && ChartControl.ChartStyleType == ChartStyleType.CandleStick)
     {
         candles = true;
     }
     gap = (plot1Style == PlotStyle.Line) || (plot1Style == PlotStyle.Square);
     if (ShowStopDots)
     {
         Plots[0].Pen.Color = Color.Gray;
     }
     else
     {
         Plots[0].Pen.Color = Color.Transparent;
     }
     if (ShowStopLine)
     {
         Plots[1].Pen.Color = Color.Gray;
     }
     else
     {
         Plots[1].Pen.Color = Color.Transparent;
     }
     MM  = anaMovingMedian(Medians[0], periodMedian);
     MAE = ATR(Closes[0], periodATR);
 }
コード例 #2
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (CurrentBar <= period)
            {
                return;
            }

            if (_atr == null)
            {
                _atr = ATR(period);
            }

            if (_ema == null)
            {
                _ema = SMA(_atr, period);
            }

            if (_atr == null & _ema == null)
            {
                return;
            }

            ATRPlotHigh.Set(High[0] + _atr[0] * multiplier);
            ATRPlotLow.Set(Low[0] - _atr[0] * multiplier);


            EMAPlotHigh.Set(High[0] + _ema[0] * multiplier);
            EMAPlotLow.Set(Low[0] - _ema[0] * multiplier);
        }
コード例 #3
0
 protected override void OnStartUp()
 {
     k                      = 1.0 / (double)period;
     volatility             = ATR(200);
     Plots[0].PlotStyle     = plot0Style;
     Plots[0].Pen.Width     = plot0Width;
     Plots[0].Pen.DashStyle = dash0Style;
     if (showPlot)
     {
         Plots[0].Pen.Color = Color.Gray;
     }
     else
     {
         Plots[0].Pen.Color = Color.Transparent;
     }
     if (ChartControl != null && ChartControl.ChartStyleType == ChartStyleType.CandleStick)
     {
         candles = true;
         alpha   = 25 * opacity;
     }
     else
     {
         candles = false;
     }
 }
コード例 #4
0
 protected override void OnStartUp()
 {
     maxlb  = Z20100527FastMAX(High, lookBack);
     minlb  = Z20100527FastMIN(Low, lookBack);
     maxlen = Z20100527FastMAX(High, length);
     minlen = Z20100527FastMIN(Low, length);
     myatr  = ATR(length);
 }
コード例 #5
0
 protected override void OnStartUp()
 {
     if (tickFactor < 0)
     {
         atr = ATR(80);
     }
     plvl = 0;
 }
コード例 #6
0
        /// <summary>
        /// Calculates the indicator value(s) at the current index.
        /// </summary>
        protected override void OnBarUpdate()
        {
            PipATRCalc = ATR(Inputs[0], Period);

            double PipATRValue = PipATRCalc[0] / TickSize;

            PipATR.Set(Math.Truncate(PipATRValue));
        }
コード例 #7
0
ファイル: ABTrend2.cs プロジェクト: hmgl/TradingStudies
 protected override void OnStartUp()
 {
     Plots[0].Pen.Width     = plot0Width;
     Plots[0].PlotStyle     = plot0Style;
     Plots[0].Pen.DashStyle = dash0Style;
     Plots[1].Pen.Width     = plot1Width;
     Plots[1].PlotStyle     = plot1Style;
     Plots[1].Pen.DashStyle = dash1Style;
     gap = plot1Style == PlotStyle.Line || plot1Style == PlotStyle.Square;
     Plots[1].Pen.Color = ShowStopLine ? Color.Gray : Color.Transparent;
     mm  = anaMovingMedian(Medians[0], periodMedian);
     mae = ATR(Closes[0], periodAtr);
 }
コード例 #8
0
        /// <summary>
        /// The Average True Range (ATR) is a measure of volatility. It was introduced by Welles Wilder in his book 'New Concepts in Technical Trading Systems' and has since been used as a component of many indicators and trading systems.
        /// </summary>
        /// <returns></returns>
        public ATR ATR(Data.IDataSeries input, int period)
        {
            if (cacheATR != null)
            {
                for (int idx = 0; idx < cacheATR.Length; idx++)
                {
                    if (cacheATR[idx].Period == period && cacheATR[idx].EqualsInput(input))
                    {
                        return(cacheATR[idx]);
                    }
                }
            }

            lock (checkATR)
            {
                checkATR.Period = period;
                period          = checkATR.Period;

                if (cacheATR != null)
                {
                    for (int idx = 0; idx < cacheATR.Length; idx++)
                    {
                        if (cacheATR[idx].Period == period && cacheATR[idx].EqualsInput(input))
                        {
                            return(cacheATR[idx]);
                        }
                    }
                }

                ATR indicator = new ATR();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input  = input;
                indicator.Period = period;
                Indicators.Add(indicator);
                indicator.SetUp();

                ATR[] tmp = new ATR[cacheATR == null ? 1 : cacheATR.Length + 1];
                if (cacheATR != null)
                {
                    cacheATR.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheATR            = tmp;
                return(indicator);
            }
        }
コード例 #9
0
 protected override void OnStartUp()
 {
     Plots[0].Pen.Width     = plot0Width;
     Plots[0].PlotStyle     = plot0Style;
     Plots[0].Pen.DashStyle = dash0Style;
     Plots[1].Pen.Width     = plot1Width;
     Plots[1].PlotStyle     = plot1Style;
     Plots[1].Pen.DashStyle = dash1Style;
     gap = (plot1Style == PlotStyle.Line) || (plot1Style == PlotStyle.Square);
     Plots[0].Pen.Color = ShowStopDots ? Color.Gray : Color.Transparent;
     Plots[1].Pen.Color = ShowStopLine ? Color.Gray : Color.Transparent;
     mm      = anaMovingMedian(Medians[0], periodMedian);
     mae     = ATR(Closes[0], periodAtr);
     candles = ChartControl != null && ChartControl.ChartStyleType == ChartStyleType.CandleStick;
 }
コード例 #10
0
		protected override void OnStartUp()
		{
			Plots[0].Pen.Width		= plot0Width;
			Plots[0].PlotStyle		= plot0Style;
			Plots[0].Pen.DashStyle	= dash0Style;
			Plots[1].Pen.Width		= plot1Width;
			Plots[1].PlotStyle		= plot1Style;
			Plots[1].Pen.DashStyle	= dash1Style;
			gap						= (plot1Style == PlotStyle.Line) || (plot1Style == PlotStyle.Square);
			Plots[0].Pen.Color		= ShowStopDots ? Color.Gray : Color.Transparent;
			Plots[1].Pen.Color		= ShowStopLine ? Color.Gray : Color.Transparent;
			mm						= anaMovingMedian(Medians[0], periodMedian);
			mae						= ATR(Closes[0], periodAtr);
			candles					= ChartControl != null && ChartControl.ChartStyleType == ChartStyleType.CandleStick;
		}
コード例 #11
0
ファイル: anaSuperTrend.cs プロジェクト: yuxi214/ninja-code
 protected override void OnStartUp()
 {
     Plots[0].Pen.Width     = plot0Width;
     Plots[0].PlotStyle     = plot0Style;
     Plots[0].Pen.DashStyle = dash0Style;
     gap = (plot0Style == PlotStyle.Line) || (plot0Style == PlotStyle.Square);
     if (ShowStopLine)
     {
         Plots[0].Pen.Color = Color.Gray;
     }
     else
     {
         Plots[0].Pen.Color = Color.Transparent;
     }
     MM  = anaMovingMedian(Medians[0], periodMedian);
     MAE = ATR(Closes[0], periodATR);
 }
コード例 #12
0
ファイル: EMAofATR.cs プロジェクト: redrhino/NinjaTrader.Base
		/// <summary>
		/// Called on each bar update event (incoming tick)
		/// </summary>
		protected override void OnBarUpdate()
		{
			 
			if (CurrentBar <= period) return;
			
			if (_atr == null)
				_atr  = ATR(period);

			if (_ema == null) 
				_ema = SMA(_atr, period);

			if (_atr == null & _ema == null) 
				return;

			ATRPlotHigh.Set(High[0] + _atr[0] * multiplier);
            ATRPlotLow.Set(Low[0] - _atr[0] * multiplier);


            EMAPlotHigh.Set(High[0] + _ema[0] * multiplier);
            EMAPlotLow.Set(Low[0] - _ema[0] * multiplier);

		}
コード例 #13
0
 public void SetupObjects()
 {
     if (_emaSlow == null)
     {
         _emaSlow = EMA(_emaSlowPeriod);
     }
     if (_emaFast == null)
     {
         _emaFast = EMA(_emaFastPeriod);
     }
     if (_rsi == null)
     {
         _rsi = RSI(Median, _rsiPeriod, 1);
     }
     if (_adx == null)
     {
         _adx = ADX(_adxPeriod);
     }
     if (_atr == null)
     {
         _atr = ATR(_atrPeriod);
     }
 }
コード例 #14
0
ファイル: ATR.cs プロジェクト: redrhino/NinjaTrader.Base
        /// <summary>
        /// The Average True Range (ATR) is a measure of volatility. It was introduced by Welles Wilder in his book 'New Concepts in Technical Trading Systems' and has since been used as a component of many indicators and trading systems.
        /// </summary>
        /// <returns></returns>
        public ATR ATR(Data.IDataSeries input, int period)
        {
            if (cacheATR != null)
                for (int idx = 0; idx < cacheATR.Length; idx++)
                    if (cacheATR[idx].Period == period && cacheATR[idx].EqualsInput(input))
                        return cacheATR[idx];

            lock (checkATR)
            {
                checkATR.Period = period;
                period = checkATR.Period;

                if (cacheATR != null)
                    for (int idx = 0; idx < cacheATR.Length; idx++)
                        if (cacheATR[idx].Period == period && cacheATR[idx].EqualsInput(input))
                            return cacheATR[idx];

                ATR indicator = new ATR();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Period = period;
                Indicators.Add(indicator);
                indicator.SetUp();

                ATR[] tmp = new ATR[cacheATR == null ? 1 : cacheATR.Length + 1];
                if (cacheATR != null)
                    cacheATR.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheATR = tmp;
                return indicator;
            }
        }
コード例 #15
0
ファイル: ABTrend2.cs プロジェクト: roonius/TradingStudies
 protected override void OnStartUp()
 {
     Plots[0].Pen.Width		= plot0Width;
     Plots[0].PlotStyle		= plot0Style;
     Plots[0].Pen.DashStyle	= dash0Style;
     Plots[1].Pen.Width		= plot1Width;
     Plots[1].PlotStyle		= plot1Style;
     Plots[1].Pen.DashStyle	= dash1Style;
     gap						= plot1Style == PlotStyle.Line || plot1Style == PlotStyle.Square;
     Plots[1].Pen.Color		= ShowStopLine ? Color.Gray : Color.Transparent;
     mm						= anaMovingMedian(Medians[0], periodMedian);
     mae						= ATR(Closes[0], periodAtr);
 }
コード例 #16
0
        public void SetupObjects()
        {

            if (_emaSlow == null)
                _emaSlow = EMA(_emaSlowPeriod);
            if (_emaFast == null)
                _emaFast = EMA(_emaFastPeriod);
            if (_rsi == null)
                _rsi = RSI(Median, _rsiPeriod, 1);
            if (_adx == null)
                _adx = ADX(_adxPeriod);
            if (_atr == null)
                _atr = ATR(_atrPeriod);
        }
コード例 #17
0
        protected override void OnStartUp()
        {
            switch (thisVolaType)
            {
            case anaSuperTrendU11VolaType.Simple_Range:
                rangeSeries = Range();
                break;

            case anaSuperTrendU11VolaType.True_Range:
                rangeSeries = ATR(Close, 1);
                break;

            case anaSuperTrendU11VolaType.Standard_Deviation:
                thisOffsetType = anaSuperTrendU11OffsetType.Default;
                rangeSeries    = StdDev(Close, rangePeriod);
                offsetSeries   = StdDev(Close, rangePeriod);
                break;
            }
            switch (thisBaseType)
            {
            case anaSuperTrendU11BaseType.Median:
                baseline = anaMovingMedian(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.ADXVMA:
                baseline = anaADXVMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.Butterworth_2:
                baseline = anaButterworthFilter(Input, basePeriod, 2);
                break;

            case anaSuperTrendU11BaseType.Butterworth_3:
                baseline = anaButterworthFilter(Input, basePeriod, 3);
                break;

            case anaSuperTrendU11BaseType.DEMA:
                baseline = DEMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.DSMA:
                baseline = DSMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.DTMA:
                baseline = DTMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.DWMA:
                baseline = DWMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.Ehlers:
                baseline = anaEhlersFilter(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.EMA:
                baseline = EMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.Gauss_2:
                baseline = anaGaussianFilter(Input, basePeriod, 2);
                break;

            case anaSuperTrendU11BaseType.Gauss_3:
                baseline = anaGaussianFilter(Input, basePeriod, 3);
                break;

            case anaSuperTrendU11BaseType.Gauss_4:
                baseline = anaGaussianFilter(Input, basePeriod, 4);
                break;

            case anaSuperTrendU11BaseType.HMA:
                baseline = HMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.HoltEMA:
                baseline = anaHoltEMA(Input, basePeriod, 2 * basePeriod);
                break;

            case anaSuperTrendU11BaseType.LinReg:
                baseline = LinReg(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.SMA:
                baseline = SMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.SuperSmoother_2:
                baseline = anaSuperSmootherFilter(Input, basePeriod, 2);
                break;

            case anaSuperTrendU11BaseType.SuperSmoother_3:
                baseline = anaSuperSmootherFilter(Input, basePeriod, 3);
                break;

            case anaSuperTrendU11BaseType.TEMA:
                baseline = TEMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.TMA:
                baseline = TMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.TSMA:
                baseline = TSMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.TWMA:
                baseline = TWMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.VWMA:
                baseline = VWMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.WMA:
                baseline = WMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.ZeroLagHATEMA:
                baseline = anaZeroLagHATEMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.ZeroLagTEMA:
                baseline = ZeroLagTEMA(Input, basePeriod);
                break;

            case anaSuperTrendU11BaseType.ZLEMA:
                baseline = ZLEMA(Input, basePeriod);
                break;
            }
            if (thisVolaType != anaSuperTrendU11VolaType.Standard_Deviation)
            {
                switch (thisOffsetType)
                {
                case anaSuperTrendU11OffsetType.Default:
                    offsetSeries = EMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.Median:
                    offsetSeries = anaMovingMedian(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.ADXVMA:
                    offsetSeries = anaADXVMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.Butterworth_2:
                    offsetSeries = anaButterworthFilter(rangeSeries, rangePeriod, 2);
                    break;

                case anaSuperTrendU11OffsetType.Butterworth_3:
                    offsetSeries = anaButterworthFilter(rangeSeries, rangePeriod, 3);
                    break;

                case anaSuperTrendU11OffsetType.DEMA:
                    offsetSeries = DEMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.DSMA:
                    offsetSeries = DSMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.DTMA:
                    offsetSeries = DTMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.DWMA:
                    offsetSeries = DWMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.Ehlers:
                    offsetSeries = anaEhlersFilter(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.EMA:
                    offsetSeries = EMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.Gauss_2:
                    offsetSeries = anaGaussianFilter(rangeSeries, rangePeriod, 2);
                    break;

                case anaSuperTrendU11OffsetType.Gauss_3:
                    offsetSeries = anaGaussianFilter(rangeSeries, rangePeriod, 3);
                    break;

                case anaSuperTrendU11OffsetType.Gauss_4:
                    offsetSeries = anaGaussianFilter(rangeSeries, rangePeriod, 4);
                    break;

                case anaSuperTrendU11OffsetType.HMA:
                    offsetSeries = HMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.HoltEMA:
                    offsetSeries = anaHoltEMA(rangeSeries, rangePeriod, 2 * rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.LinReg:
                    offsetSeries = LinReg(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.SMA:
                    offsetSeries = SMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.SuperSmoother_2:
                    offsetSeries = anaSuperSmootherFilter(rangeSeries, rangePeriod, 2);
                    break;

                case anaSuperTrendU11OffsetType.SuperSmoother_3:
                    offsetSeries = anaSuperSmootherFilter(rangeSeries, rangePeriod, 3);
                    break;

                case anaSuperTrendU11OffsetType.TEMA:
                    offsetSeries = TEMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.TMA:
                    offsetSeries = TMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.TSMA:
                    offsetSeries = TSMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.TWMA:
                    offsetSeries = TWMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.VWMA:
                    offsetSeries = VWMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.WMA:
                    offsetSeries = WMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.ZeroLagHATEMA:
                    offsetSeries = anaZeroLagHATEMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.ZeroLagTEMA:
                    offsetSeries = ZeroLagTEMA(rangeSeries, rangePeriod);
                    break;

                case anaSuperTrendU11OffsetType.ZLEMA:
                    offsetSeries = ZLEMA(rangeSeries, rangePeriod);
                    break;
                }
            }
            volatility = ATR(Close, 256);

            Plots[0].Pen.Width     = plot0Width;
            Plots[0].PlotStyle     = plot0Style;
            Plots[0].Pen.DashStyle = dash0Style;
            Plots[1].Pen.Width     = plot1Width;
            Plots[1].PlotStyle     = plot1Style;
            Plots[1].Pen.DashStyle = dash1Style;
            if (ChartControl != null && ChartControl.ChartStyleType == ChartStyleType.CandleStick)
            {
                candles = true;
                alpha   = 25 * opacity;
            }
            else
            {
                candles = false;
            }
            gap = (plot1Style == PlotStyle.Line) || (plot1Style == PlotStyle.Square);
        }