/// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (CurrentBar <= BarsRequired)
            {
                return;
            }

            _macd = MACD_ZeroLag_Colors(1, MACDFast, MACDSlow, MACDSmooth, 0);
            _rsi  = RSI(RSIPeriod, RSISmooth);

            // P(_macd.MacdUp + " " + _macd.MacdDn);
            if (IsFlat)
            {
                LookForEntry();
            }
            else
            {
                LookForStop();
                LookForExit();
            }



            if (!IsFlat)
            {
                ManageTradeByTrailingATR();
                PositionPrice.Set(_positionPrice);
                StopLoss.Set(_lossLevel);
            }
        }
		/// <summary>
		/// Called on each bar update event (incoming tick)
		/// </summary>
		protected override void OnBarUpdate()
		{
			if (CurrentBar <= BarsRequired) return;

			_macd = MACD_ZeroLag_Colors(1, MACDFast, MACDSlow, MACDSmooth, 0);
			_rsi = RSI(RSIPeriod, RSISmooth);

			// P(_macd.MacdUp + " " + _macd.MacdDn);
			if (IsFlat)
			{
				LookForEntry();
			}
			else
			{
				LookForStop();
                LookForExit();
			}



			if (!IsFlat)
			{
				ManageTradeByTrailingATR();
				PositionPrice.Set(_positionPrice);
				StopLoss.Set(_lossLevel);
			   
			}

		}
Esempio n. 3
0
        protected override void MyInitialize()
        {
            _macd = MACD_ZeroLag_Colors(1, MACDFast, MACDSlow, MACDSmooth, 0);
             Add(_macd);

            _rsi = RSI(RSIPeriod, RSISmooth);
            Add(_rsi);
            TraceOrders = true;
        }
Esempio n. 4
0
        /// <summary>
        /// The RSI (Relative Strength Index) is a price-following oscillator that ranges between 0 and 100.
        /// </summary>
        /// <returns></returns>
        public RSI RSI(Data.IDataSeries input, int period, int smooth)
        {
            if (cacheRSI != null)
            {
                for (int idx = 0; idx < cacheRSI.Length; idx++)
                {
                    if (cacheRSI[idx].Period == period && cacheRSI[idx].Smooth == smooth && cacheRSI[idx].EqualsInput(input))
                    {
                        return(cacheRSI[idx]);
                    }
                }
            }

            lock (checkRSI)
            {
                checkRSI.Period = period;
                period          = checkRSI.Period;
                checkRSI.Smooth = smooth;
                smooth          = checkRSI.Smooth;

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

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

                RSI[] tmp = new RSI[cacheRSI == null ? 1 : cacheRSI.Length + 1];
                if (cacheRSI != null)
                {
                    cacheRSI.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheRSI            = tmp;
                return(indicator);
            }
        }
Esempio n. 5
0
 protected override void OnStartUp()
 {
     DYNRSI    = RSI(Input, RSIPeriod, 1);
     DYNPrice  = SMA(DYNRSI, PricePeriod);
     DYNSignal = SMA(DYNRSI, SignalPeriod);
     // added the following Aug 19 2014 zondor
     emaEMAhls = EMA(EMA(hls, EMAPeriod1), EMAPeriod2);
     emaEMAsms = (EMA(EMA(sms, EMAPeriod1), EMAPeriod2));
     emaSMI    = EMA(smis, SMIEMAPeriod);
     MaxHI     = MAX(High, range);
     MinLO     = MIN(Low, range);
 }
Esempio n. 6
0
 /// <summary>
 /// Calculates the indicator value(s) at the current index.
 /// </summary>
 protected override void OnStartUp()
 {
     DYNRSI                 = RSI(Input, RSIPeriod, 1);
     DYNPrice               = SMA(DYNRSI, PricePeriod);
     DYNSignal              = SMA(DYNRSI, SignalPeriod);
     DYNAverage             = SMA(DYNRSI, BandPeriod);
     SDBB                   = StdDev(DYNRSI, BandPeriod);
     Plots[0].Pen.Color     = main;
     Plots[1].Pen.Color     = signal;
     Plots[2].Pen.Color     = bbAverage;
     Plots[3].Pen.Color     = bbUpper;
     Plots[4].Pen.Color     = bbLower;
     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;
     Plots[2].Pen.Width     = plot2Width;
     Plots[2].PlotStyle     = plot2Style;
     Plots[2].Pen.DashStyle = dash2Style;
     Plots[3].Pen.Width     = plot3Width;
     Plots[3].PlotStyle     = plot3Style;
     Plots[3].Pen.DashStyle = dash3Style;
     Plots[4].Pen.Width     = plot3Width;
     Plots[4].PlotStyle     = plot3Style;
     Plots[4].Pen.DashStyle = dash3Style;
     Lines[0].Pen.Color     = baselineColor;
     Lines[1].Pen.Color     = upperlineColor;
     Lines[2].Pen.Color     = lowerlineColor;
     Lines[0].Pen.Width     = baselineWidth;
     Lines[0].Pen.DashStyle = baselineStyle;
     Lines[1].Value         = valueUpperLine;
     Lines[1].Pen.Width     = upperlineWidth;
     Lines[1].Pen.DashStyle = upperlineStyle;
     Lines[2].Value         = valueLowerLine;
     Lines[2].Pen.Width     = lowerlineWidth;
     Lines[2].Pen.DashStyle = lowerlineStyle;
 }
 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);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Calculates the indicator value(s) at the current index.
        /// </summary>
        protected override void OnBarUpdate()
        {
            RSIClose = RSI(Close, Period, Smooth);
            //Print("RSIClose = "+RSIClose[0]);
            RSIHigh = RSI(High, Period, Smooth);
            RSILow  = RSI(Low, Period, Smooth);



            double rsiCloseValue = RSIClose[0];

            //Print("rsiCloseValue = "+rsiCloseValue);
            RSIC.Set(rsiCloseValue);


            double rsiHighValue = RSIHigh[0];
            //Print("rsiHighValue = "+rsiHighValue);
            //**RSIH.Set(rsiHighValue + 5);

            double rsiLowValue = RSILow[0];

            //Print("rsiLowValue = "+rsiLowValue);
            //**RSIL.Set(rsiLowValue - 5);

            //Colour coriteria for RSIC
            if (rsiCloseValue > longext)
            {
                PlotColors[0][0] = Color.Red;
            }
            else if (rsiCloseValue < shortext)
            {
                PlotColors[0][0] = Color.Blue;
            }
            else
            {
                PlotColors[0][0] = Color.Magenta;
            }

            //Colour criteria for RSIH
            if (rsiHighValue > longext)
            {
                PlotColors[1][0] = Color.Transparent;
            }
            else
            {
                PlotColors[1][0] = Color.Transparent;
            }

            //Colour criteria for RSIL
            if (rsiLowValue < shortext)
            {
                PlotColors[2][0] = Color.Transparent;
            }
            else
            {
                PlotColors[2][0] = Color.Transparent;
            }

            //	Avg.Set(rsiAvg);
            //	Value.Set(rsi);
        }
        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);
        }
Esempio n. 10
0
		/// <summary>
		/// The RSI (Relative Strength Index) is a price-following oscillator that ranges between 0 and 100.
		/// </summary>
		/// <returns></returns>
		public RSI RSI(Data.IDataSeries input, int period, int smooth)
		{
			if (cacheRSI != null)
				for (int idx = 0; idx < cacheRSI.Length; idx++)
					if (cacheRSI[idx].Period == period && cacheRSI[idx].Smooth == smooth && cacheRSI[idx].EqualsInput(input))
						return cacheRSI[idx];

			lock (checkRSI)
			{
				checkRSI.Period = period;
				period = checkRSI.Period;
				checkRSI.Smooth = smooth;
				smooth = checkRSI.Smooth;

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

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

				RSI[] tmp = new RSI[cacheRSI == null ? 1 : cacheRSI.Length + 1];
				if (cacheRSI != null)
					cacheRSI.CopyTo(tmp, 0);
				tmp[tmp.Length - 1] = indicator;
				cacheRSI = tmp;
				return indicator;
			}
		}