Пример #1
0
		private int CalcDelta(TickTypeEnum tickType, double price, int volume, GomCDCalculationModeType calcmode, bool backupmode, int filtersize, GomFilterModeType filtermode)
		{
			int delta = 0;
			int direction = lastdirection;


			if ((calcmode == GomCDCalculationModeType.BidAsk) && (tickType != TickTypeEnum.Unknown) && (tickType != TickTypeEnum.BetweenBidAsk))
			{
				if ((tickType == TickTypeEnum.BelowBid) || (tickType == TickTypeEnum.AtBid))
					delta = -volume;
				else if ((tickType == TickTypeEnum.AboveAsk) || (tickType == TickTypeEnum.AtAsk))
					delta = volume;
			}
			else if (calcmode == GomCDCalculationModeType.UpDownTick)
			{
				if (lastprice != 0)
				{
					if (price > lastprice) delta = volume;
					if (price < lastprice) delta = -volume;
				}
			}
			else if ((calcmode == GomCDCalculationModeType.UpDownTickWithContinuation) ||(calcmode == GomCDCalculationModeType.UpDownOneTickWithContinuation)|| ((calcmode == GomCDCalculationModeType.BidAsk) && (backupmode == true)))
			{
				if (price > lastprice)  //normal uptick/dn tick
					direction = 1;
				else if (price < lastprice)
					direction = -1;

				if (calcmode == GomCDCalculationModeType.UpDownOneTickWithContinuation)
					delta=direction;
				else
					delta = direction * volume;
			}

			// added	

			else if ((calcmode == GomCDCalculationModeType.Hybrid))
			{

				if (price > lastprice)  //normal uptick/dn tick
				{
					direction = 1;
					//price changed, we reinit the startlookingforreversal bool.
					startlookingforreversal = false;
				}
				else if (price < lastprice)
				{
					direction = -1;
					startlookingforreversal = false;
				}


				if (!startlookingforreversal)
					if (direction == 1)
						//if going up, we want to be hitting bid to be able to start to spot reversals (hitting the ask)
						startlookingforreversal = (tickType == TickTypeEnum.AtBid) || (tickType == TickTypeEnum.BelowBid);
					else
						startlookingforreversal = (tickType == TickTypeEnum.AtAsk) || (tickType == TickTypeEnum.AboveAsk);

				//what happens when price is same
				if (price == lastprice)
				{
					//if going up, and we have already hit the bid (startlookingforreversal is true) at a price level, 
					// and start hitting the ask, let's reverse

					if ((direction == 1) && startlookingforreversal && ((tickType == TickTypeEnum.AtAsk) || (tickType == TickTypeEnum.BetweenBidAsk)))
						direction = -1;

					else if ((direction == -1) && startlookingforreversal && ((tickType == TickTypeEnum.AtBid) || (tickType == TickTypeEnum.BetweenBidAsk)))
						direction = 1;	//buyers take control of ask
				}


				delta = direction * volume;

			}

			lastprice = price;
			lastdirection = direction;

			if ((filtermode == GomFilterModeType.OnlyLargerThan) && (volume <= filtersize))
				delta = 0;

			if ((filtermode == GomFilterModeType.OnlySmallerThan) && (volume >= filtersize))
				delta = 0;

			return delta;

		}
Пример #2
0
 public Indicator.GomDeltaIndicator GomDeltaIndicator(bool backupMode, GomCDCalculationModeType calcMode, GomFilterModeType filterMode, int filterSize)
 {
     return _indicator.GomDeltaIndicator(Input, backupMode, calcMode, filterMode, filterSize);
 }
Пример #3
0
        /// <summary>
        /// Base Class. Do not instantiate
        /// </summary>
        /// <returns></returns>
        public Indicator.GomDeltaIndicator GomDeltaIndicator(Data.IDataSeries input, bool backupMode, GomCDCalculationModeType calcMode, GomFilterModeType filterMode, int filterSize)
        {
            if (InInitialize && input == null)
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

            return _indicator.GomDeltaIndicator(input, backupMode, calcMode, filterMode, filterSize);
        }
Пример #4
0
        public GomCD GomCD(GomCDCalculationModeType calcMode, GomCDChartType chart, string fileFormat, Gom.FileModeType fileModeType, GomFilterModeType filterMode, int filterSize, bool reinitSession)
        {
            GomCD indy = GomCD(calcMode, chart, fileFormat, filterMode, filterSize, reinitSession);

            indy.CalcMode   = calcMode;
            indy.FilterMode = filterMode;
            indy.FilterSize = filterSize;
            indy.FileMode   = fileModeType;


            return(indy);
        }
Пример #5
0
        /// <summary>
        /// Base Class. Do not instantiate
        /// </summary>
        /// <returns></returns>
        public GomDeltaIndicator GomDeltaIndicator(Data.IDataSeries input, bool backupMode, GomCDCalculationModeType calcMode, GomFilterModeType filterMode, int filterSize)
        {
            if (cacheGomDeltaIndicator != null)
                for (int idx = 0; idx < cacheGomDeltaIndicator.Length; idx++)
                    if (cacheGomDeltaIndicator[idx].BackupMode == backupMode && cacheGomDeltaIndicator[idx].CalcMode == calcMode && cacheGomDeltaIndicator[idx].FilterMode == filterMode && cacheGomDeltaIndicator[idx].FilterSize == filterSize && cacheGomDeltaIndicator[idx].EqualsInput(input))
                        return cacheGomDeltaIndicator[idx];

            lock (checkGomDeltaIndicator)
            {
                checkGomDeltaIndicator.BackupMode = backupMode;
                backupMode = checkGomDeltaIndicator.BackupMode;
                checkGomDeltaIndicator.CalcMode = calcMode;
                calcMode = checkGomDeltaIndicator.CalcMode;
                checkGomDeltaIndicator.FilterMode = filterMode;
                filterMode = checkGomDeltaIndicator.FilterMode;
                checkGomDeltaIndicator.FilterSize = filterSize;
                filterSize = checkGomDeltaIndicator.FilterSize;

                if (cacheGomDeltaIndicator != null)
                    for (int idx = 0; idx < cacheGomDeltaIndicator.Length; idx++)
                        if (cacheGomDeltaIndicator[idx].BackupMode == backupMode && cacheGomDeltaIndicator[idx].CalcMode == calcMode && cacheGomDeltaIndicator[idx].FilterMode == filterMode && cacheGomDeltaIndicator[idx].FilterSize == filterSize && cacheGomDeltaIndicator[idx].EqualsInput(input))
                            return cacheGomDeltaIndicator[idx];

                GomDeltaIndicator indicator = new GomDeltaIndicator();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.BackupMode = backupMode;
                indicator.CalcMode = calcMode;
                indicator.FilterMode = filterMode;
                indicator.FilterSize = filterSize;
                Indicators.Add(indicator);
                indicator.SetUp();

                GomDeltaIndicator[] tmp = new GomDeltaIndicator[cacheGomDeltaIndicator == null ? 1 : cacheGomDeltaIndicator.Length + 1];
                if (cacheGomDeltaIndicator != null)
                    cacheGomDeltaIndicator.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheGomDeltaIndicator = tmp;
                return indicator;
            }
        }
Пример #6
0
        /// <summary>
        /// Base Class. Do not instantiate
        /// </summary>
        /// <returns></returns>
        public Indicator.GomDeltaIndicator GomDeltaIndicator(Data.IDataSeries input, bool backupMode, GomCDCalculationModeType calcMode, GomFilterModeType filterMode, int filterSize)
        {
            if (InInitialize && input == null)
            {
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
            }

            return(_indicator.GomDeltaIndicator(input, backupMode, calcMode, filterMode, filterSize));
        }
Пример #7
0
        private int CalcDelta(TickTypeEnum tickType, double price, int volume, GomCDCalculationModeType calcmode, bool backupmode, int filtersize, GomFilterModeType filtermode)
        {
            int delta     = 0;
            int direction = lastdirection;


            if ((calcmode == GomCDCalculationModeType.BidAsk) && (tickType != TickTypeEnum.Unknown) && (tickType != TickTypeEnum.BetweenBidAsk))
            {
                if ((tickType == TickTypeEnum.BelowBid) || (tickType == TickTypeEnum.AtBid))
                {
                    delta = -volume;
                }
                else if ((tickType == TickTypeEnum.AboveAsk) || (tickType == TickTypeEnum.AtAsk))
                {
                    delta = volume;
                }
            }
            else if (calcmode == GomCDCalculationModeType.UpDownTick)
            {
                if (lastprice != 0)
                {
                    if (price > lastprice)
                    {
                        delta = volume;
                    }
                    if (price < lastprice)
                    {
                        delta = -volume;
                    }
                }
            }
            else if ((calcmode == GomCDCalculationModeType.UpDownTickWithContinuation) || ((calcmode == GomCDCalculationModeType.BidAsk) && (backupmode == true)))
            {
                if (price > lastprice)                  //normal uptick/dn tick
                {
                    direction = 1;
                }
                else if (price < lastprice)
                {
                    direction = -1;
                }

                delta = direction * volume;
            }

            // added

            else if ((calcmode == GomCDCalculationModeType.Hybrid))
            {
                if (price > lastprice)                  //normal uptick/dn tick
                {
                    direction = 1;
                    //price changed, we reinit the startlookingforreversal bool.
                    startlookingforreversal = false;
                }
                else if (price < lastprice)
                {
                    direction = -1;
                    startlookingforreversal = false;
                }


                if (!startlookingforreversal)
                {
                    if (direction == 1)
                    {
                        //if going up, we want to be hitting bid to be able to start to spot reversals (hitting the ask)
                        startlookingforreversal = (tickType == TickTypeEnum.AtBid) || (tickType == TickTypeEnum.BelowBid);
                    }
                    else
                    {
                        startlookingforreversal = (tickType == TickTypeEnum.AtAsk) || (tickType == TickTypeEnum.AboveAsk);
                    }
                }

                //what happens when price is same
                if (price == lastprice)
                {
                    //if going up, and we have already hit the bid (startlookingforreversal is true) at a price level,
                    // and start hitting the ask, let's reverse

                    if ((direction == 1) && startlookingforreversal && ((tickType == TickTypeEnum.AtAsk) || (tickType == TickTypeEnum.BetweenBidAsk)))
                    {
                        direction = -1;
                    }

                    else if ((direction == -1) && startlookingforreversal && ((tickType == TickTypeEnum.AtBid) || (tickType == TickTypeEnum.BetweenBidAsk)))
                    {
                        direction = 1;                          //buyers take control of ask
                    }
                }


                delta = direction * volume;
            }

            lastprice     = price;
            lastdirection = direction;

            if ((filtermode == GomFilterModeType.OnlyLargerThan) && (volume <= filtersize))
            {
                delta = 0;
            }

            if ((filtermode == GomFilterModeType.OnlySmallerThan) && (volume >= filtersize))
            {
                delta = 0;
            }

            return(delta);
        }
Пример #8
0
 public Indicator.GomDeltaIndicator GomDeltaIndicator(bool backupMode, GomCDCalculationModeType calcMode, GomFilterModeType filterMode, int filterSize)
 {
     return(_indicator.GomDeltaIndicator(Input, backupMode, calcMode, filterMode, filterSize));
 }
Пример #9
0
        /// <summary>
        /// Base Class. Do not instantiate
        /// </summary>
        /// <returns></returns>
        public GomDeltaIndicator GomDeltaIndicator(Data.IDataSeries input, bool backupMode, GomCDCalculationModeType calcMode, GomFilterModeType filterMode, int filterSize)
        {
            if (cacheGomDeltaIndicator != null)
            {
                for (int idx = 0; idx < cacheGomDeltaIndicator.Length; idx++)
                {
                    if (cacheGomDeltaIndicator[idx].BackupMode == backupMode && cacheGomDeltaIndicator[idx].CalcMode == calcMode && cacheGomDeltaIndicator[idx].FilterMode == filterMode && cacheGomDeltaIndicator[idx].FilterSize == filterSize && cacheGomDeltaIndicator[idx].EqualsInput(input))
                    {
                        return(cacheGomDeltaIndicator[idx]);
                    }
                }
            }

            lock (checkGomDeltaIndicator)
            {
                checkGomDeltaIndicator.BackupMode = backupMode;
                backupMode = checkGomDeltaIndicator.BackupMode;
                checkGomDeltaIndicator.CalcMode = calcMode;
                calcMode = checkGomDeltaIndicator.CalcMode;
                checkGomDeltaIndicator.FilterMode = filterMode;
                filterMode = checkGomDeltaIndicator.FilterMode;
                checkGomDeltaIndicator.FilterSize = filterSize;
                filterSize = checkGomDeltaIndicator.FilterSize;

                if (cacheGomDeltaIndicator != null)
                {
                    for (int idx = 0; idx < cacheGomDeltaIndicator.Length; idx++)
                    {
                        if (cacheGomDeltaIndicator[idx].BackupMode == backupMode && cacheGomDeltaIndicator[idx].CalcMode == calcMode && cacheGomDeltaIndicator[idx].FilterMode == filterMode && cacheGomDeltaIndicator[idx].FilterSize == filterSize && cacheGomDeltaIndicator[idx].EqualsInput(input))
                        {
                            return(cacheGomDeltaIndicator[idx]);
                        }
                    }
                }

                GomDeltaIndicator indicator = new GomDeltaIndicator();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input      = input;
                indicator.BackupMode = backupMode;
                indicator.CalcMode   = calcMode;
                indicator.FilterMode = filterMode;
                indicator.FilterSize = filterSize;
                Indicators.Add(indicator);
                indicator.SetUp();

                GomDeltaIndicator[] tmp = new GomDeltaIndicator[cacheGomDeltaIndicator == null ? 1 : cacheGomDeltaIndicator.Length + 1];
                if (cacheGomDeltaIndicator != null)
                {
                    cacheGomDeltaIndicator.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]    = indicator;
                cacheGomDeltaIndicator = tmp;
                return(indicator);
            }
        }
Пример #10
0
        public Indicator.GomCD GomCD(GomCDCalculationModeType calcMode, GomCDChartType chart, string fileFormat, GomFilterModeType filterMode, int filterSize, bool reinitSession)
        {
            Indicator.GomCD indy = _indicator.GomCD(Input, calcMode, chart, reinitSession);
            indy.FileFormat = fileFormat;
            indy.FilterMode = filterMode;
            indy.FilterSize = filterSize;

            return(indy);
        }
Пример #11
0
		public Indicator.GomCD GomCD(GomCDCalculationModeType calcMode, GomCDChartType chart, string fileFormat, Gom.FileModeType fileModeType,GomFilterModeType filterMode, int filterSize, bool reinitSession)
        {
            Indicator.GomCD indy = _indicator.GomCD(calcMode,chart,fileFormat,filterMode,filterSize,reinitSession);
			indy.FileMode=fileModeType;

            return indy;
        }
Пример #12
0
		public GomCD GomCD(GomCDCalculationModeType calcMode, GomCDChartType chart, string fileFormat, GomFilterModeType filterMode, int filterSize, bool reinitSession)
        {
            GomCD indy = GomCD(Input,calcMode,chart,reinitSession);
			indy.FileFormat=fileFormat;
            indy.FilterMode = filterMode;
            indy.FilterSize = filterSize;


            return indy;
        }