Example #1
0
		public override void Set(int index, Mq4Double value)
		{
			base.Set(index, value);
			switch (index)
			{
				case MQ4Const.OBJPROP_TIME1:
					_index = _timeSeries.GetIndexByTime(Time1);
					break;
			}
		}
		private void OnValueChanged(int index, Mq4Double value)
		{
			int indexToSet;
			if (_mq4Array.IsInverted)
				indexToSet = _mq4Array.Length - index;
			else
				indexToSet = index;

			if (indexToSet < 0)
				return;

			_dataSeries[indexToSet] = value;
		}
Example #3
0
		public virtual void Set(int index, Mq4Double value)
		{
			_properties[index] = value;
		}
        Mq4Double calculateZigzagKwanMBFXTiming()
        {
            Mq4Double index            = 0;
            Mq4Double debut            = 0;
            Mq4Double ld_208           = 0;
            Mq4Double ld_200           = 0;
            Mq4Double ld_192           = 0;
            Mq4Double ld_184           = 0;
            Mq4Double ld_176           = 0;
            Mq4Double ld_168           = 0;
            Mq4Double ld_160           = 0;
            Mq4Double ld_152           = 0;
            Mq4Double ld_144           = 0;
            Mq4Double ld_136           = 0;
            Mq4Double ld_128           = 0;
            Mq4Double ld_120           = 0;
            Mq4Double ld_112           = 0;
            Mq4Double coFactor         = 0;
            Mq4Double factor           = 0;
            Mq4Double oldAverage       = 0;
            Mq4Double average          = 0;
            Mq4Double ld_72            = 0;
            Mq4Double ld_64            = 0;
            Mq4Double ld_56            = 0;
            Mq4Double ld_48            = 0;
            Mq4Double ld_40            = 0;
            Mq4Double priceProgression = 0;
            Mq4Double result           = 0;
            Mq4Double secondCycle      = 0;
            Mq4Double firstCycle       = 0;
            Mq4Double lenBase          = 0;

            debut = MarketSeries.Close.Count - len - 1;
            for (index = debut; index >= 0; index--)
            {
                if (firstCycle == 0.0)
                {
                    firstCycle  = 1.0;
                    secondCycle = 0.0;

                    lenBase = Math.Max(len - 1.0, 5);

                    average  = 100.0 * ((High[index] + Low[index] + Close[index]) / 3.0);
                    factor   = 3.0 / (len + 2.0);
                    coFactor = 1.0 - factor;
                }
                else
                {
                    firstCycle = (firstCycle < lenBase) ? firstCycle + 1 : lenBase + 1.0;

                    oldAverage       = average;
                    average          = 100.0 * ((High[index] + Low[index] + Close[index]) / 3.0);
                    priceProgression = average - oldAverage;

                    ld_112 = coFactor * ld_112 + factor * priceProgression;
                    ld_120 = factor * ld_112 + coFactor * ld_120;
                    ld_40  = 1.5 * ld_112 - ld_120 / 2.0;

                    ld_128 = coFactor * ld_128 + factor * ld_40;
                    ld_208 = factor * ld_128 + coFactor * ld_208;
                    ld_48  = 1.5 * ld_128 - ld_208 / 2.0;

                    ld_136 = coFactor * ld_136 + factor * ld_48;
                    ld_152 = factor * ld_136 + coFactor * ld_152;
                    ld_56  = 1.5 * ld_136 - ld_152 / 2.0;

                    ld_160 = coFactor * ld_160 + factor * Math.Abs((double)priceProgression);
                    ld_168 = factor * ld_160 + coFactor * ld_168;
                    ld_64  = 1.5 * ld_160 - ld_168 / 2.0;

                    ld_176 = coFactor * ld_176 + factor * ld_64;
                    ld_184 = factor * ld_176 + coFactor * ld_184;
                    ld_144 = 1.5 * ld_176 - ld_184 / 2.0;

                    ld_192 = coFactor * ld_192 + factor * ld_144;
                    ld_200 = factor * ld_192 + coFactor * ld_200;
                    ld_72  = 1.5 * ld_192 - ld_200 / 2.0;

                    if (firstCycle <= lenBase && average != oldAverage)
                    {
                        secondCycle = 1.0;
                    }

                    if (firstCycle == lenBase && secondCycle == 0.0)
                    {
                        firstCycle = 0.0;
                    }
                }

                if (firstCycle > lenBase && ld_72 > 1E-10)
                {
                    result = 50.0 * (ld_56 / ld_72 + 1.0);

                    if (result > 100.0)
                    {
                        result = 100.0;
                    }

                    if (result < 0.0)
                    {
                        result = 0.0;
                    }
                }
                else
                {
                    result = 50.0;
                }

                standMq4Output[index]  = result;
                buyMq4Output[index]    = result;
                sellMq4Output[index]   = result;
                signalMq4Output[index] = standSignal;

                if (standMq4Output[index] > standMq4Output[index + 1] - filter)
                {
                    sellMq4Output[index]   = MQ4Const.EMPTY_VALUE;
                    signalMq4Output[index] = buySignal;
                }
                else if (standMq4Output[index] < standMq4Output[index + 1] + filter)
                {
                    buyMq4Output[index]     = MQ4Const.EMPTY_VALUE;
                    signalMq4Output[index] += sellSignal;
                }
                else if (standMq4Output[index] == standMq4Output[index + 1] + filter)
                {
                    buyMq4Output[index]    = MQ4Const.EMPTY_VALUE;
                    sellMq4Output[index]   = MQ4Const.EMPTY_VALUE;
                    signalMq4Output[index] = standSignal;
                }
            }
            return(0);
        }