コード例 #1
0
		/// <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);
			   
			}

		}
コード例 #2
0
        /// <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);
            }
        }
コード例 #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;
        }
コード例 #4
0
        /// <summary>
        /// ZeroLag MACD with enhanced visual coloring
        /// </summary>
        /// <returns></returns>
        public MACD_ZeroLag_Colors MACD_ZeroLag_Colors(Data.IDataSeries input, double acceleration, int fast, int slow, int smooth, double threshold)
        {
            if (cacheMACD_ZeroLag_Colors != null)
            {
                for (int idx = 0; idx < cacheMACD_ZeroLag_Colors.Length; idx++)
                {
                    if (Math.Abs(cacheMACD_ZeroLag_Colors[idx].Acceleration - acceleration) <= double.Epsilon && cacheMACD_ZeroLag_Colors[idx].Fast == fast && cacheMACD_ZeroLag_Colors[idx].Slow == slow && cacheMACD_ZeroLag_Colors[idx].Smooth == smooth && Math.Abs(cacheMACD_ZeroLag_Colors[idx].Threshold - threshold) <= double.Epsilon && cacheMACD_ZeroLag_Colors[idx].EqualsInput(input))
                    {
                        return(cacheMACD_ZeroLag_Colors[idx]);
                    }
                }
            }

            lock (checkMACD_ZeroLag_Colors)
            {
                checkMACD_ZeroLag_Colors.Acceleration = acceleration;
                acceleration = checkMACD_ZeroLag_Colors.Acceleration;
                checkMACD_ZeroLag_Colors.Fast = fast;
                fast = checkMACD_ZeroLag_Colors.Fast;
                checkMACD_ZeroLag_Colors.Slow = slow;
                slow = checkMACD_ZeroLag_Colors.Slow;
                checkMACD_ZeroLag_Colors.Smooth = smooth;
                smooth = checkMACD_ZeroLag_Colors.Smooth;
                checkMACD_ZeroLag_Colors.Threshold = threshold;
                threshold = checkMACD_ZeroLag_Colors.Threshold;

                if (cacheMACD_ZeroLag_Colors != null)
                {
                    for (int idx = 0; idx < cacheMACD_ZeroLag_Colors.Length; idx++)
                    {
                        if (Math.Abs(cacheMACD_ZeroLag_Colors[idx].Acceleration - acceleration) <= double.Epsilon && cacheMACD_ZeroLag_Colors[idx].Fast == fast && cacheMACD_ZeroLag_Colors[idx].Slow == slow && cacheMACD_ZeroLag_Colors[idx].Smooth == smooth && Math.Abs(cacheMACD_ZeroLag_Colors[idx].Threshold - threshold) <= double.Epsilon && cacheMACD_ZeroLag_Colors[idx].EqualsInput(input))
                        {
                            return(cacheMACD_ZeroLag_Colors[idx]);
                        }
                    }
                }

                MACD_ZeroLag_Colors indicator = new MACD_ZeroLag_Colors();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input        = input;
                indicator.Acceleration = acceleration;
                indicator.Fast         = fast;
                indicator.Slow         = slow;
                indicator.Smooth       = smooth;
                indicator.Threshold    = threshold;
                Indicators.Add(indicator);
                indicator.SetUp();

                MACD_ZeroLag_Colors[] tmp = new MACD_ZeroLag_Colors[cacheMACD_ZeroLag_Colors == null ? 1 : cacheMACD_ZeroLag_Colors.Length + 1];
                if (cacheMACD_ZeroLag_Colors != null)
                {
                    cacheMACD_ZeroLag_Colors.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]      = indicator;
                cacheMACD_ZeroLag_Colors = tmp;
                return(indicator);
            }
        }
コード例 #5
0
        /// <summary>
        /// ZeroLag MACD with enhanced visual coloring
        /// </summary>
        /// <returns></returns>
        public MACD_ZeroLag_Colors MACD_ZeroLag_Colors(Data.IDataSeries input, double acceleration, int fast, int slow, int smooth, double threshold)
        {
            if (cacheMACD_ZeroLag_Colors != null)
                for (int idx = 0; idx < cacheMACD_ZeroLag_Colors.Length; idx++)
                    if (Math.Abs(cacheMACD_ZeroLag_Colors[idx].Acceleration - acceleration) <= double.Epsilon && cacheMACD_ZeroLag_Colors[idx].Fast == fast && cacheMACD_ZeroLag_Colors[idx].Slow == slow && cacheMACD_ZeroLag_Colors[idx].Smooth == smooth && Math.Abs(cacheMACD_ZeroLag_Colors[idx].Threshold - threshold) <= double.Epsilon && cacheMACD_ZeroLag_Colors[idx].EqualsInput(input))
                        return cacheMACD_ZeroLag_Colors[idx];

            lock (checkMACD_ZeroLag_Colors)
            {
                checkMACD_ZeroLag_Colors.Acceleration = acceleration;
                acceleration = checkMACD_ZeroLag_Colors.Acceleration;
                checkMACD_ZeroLag_Colors.Fast = fast;
                fast = checkMACD_ZeroLag_Colors.Fast;
                checkMACD_ZeroLag_Colors.Slow = slow;
                slow = checkMACD_ZeroLag_Colors.Slow;
                checkMACD_ZeroLag_Colors.Smooth = smooth;
                smooth = checkMACD_ZeroLag_Colors.Smooth;
                checkMACD_ZeroLag_Colors.Threshold = threshold;
                threshold = checkMACD_ZeroLag_Colors.Threshold;

                if (cacheMACD_ZeroLag_Colors != null)
                    for (int idx = 0; idx < cacheMACD_ZeroLag_Colors.Length; idx++)
                        if (Math.Abs(cacheMACD_ZeroLag_Colors[idx].Acceleration - acceleration) <= double.Epsilon && cacheMACD_ZeroLag_Colors[idx].Fast == fast && cacheMACD_ZeroLag_Colors[idx].Slow == slow && cacheMACD_ZeroLag_Colors[idx].Smooth == smooth && Math.Abs(cacheMACD_ZeroLag_Colors[idx].Threshold - threshold) <= double.Epsilon && cacheMACD_ZeroLag_Colors[idx].EqualsInput(input))
                            return cacheMACD_ZeroLag_Colors[idx];

                MACD_ZeroLag_Colors indicator = new MACD_ZeroLag_Colors();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Acceleration = acceleration;
                indicator.Fast = fast;
                indicator.Slow = slow;
                indicator.Smooth = smooth;
                indicator.Threshold = threshold;
                Indicators.Add(indicator);
                indicator.SetUp();

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