Ejemplo n.º 1
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (CurrentBar < Period + 1)
            {
                return;
            }

            double Numerator   = MAX(Close, Period)[0] - MIN(Close, Period)[0];
            double Denominator = 0;

            for (int i = 0; i < Period; i++)
            {
                Denominator = Denominator + Math.Abs(Close[i] - Close[i + 1]);
            }

            VHFLine.Set(Numerator / Denominator);

            if (VHFLine[0] < Threshold)
            {
                BackColor = _backColorChop;
            }
            else
            {
                BackColor = _backColorTrend;
            }

//			if (Lines[0].Value != Threshold)
//				Lines[0].Value= Threshold;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (CurrentBar < Period + 1)
            {
                return;
            }

            double Numerator   = MAX(Close, Period)[0] - MIN(Close, Period)[0];
            double Denominator = 0;

            for (int i = 0; i < Period; i++)
            {
                Denominator = Denominator + Math.Abs(Close[i] - Close[i + 1]);
            }

            VHFLine.Set(10 * Numerator / Denominator);


            //	The congestion index is calculated by taking the difference between the
            // highest close price and the lowest close price for a specific period and
            // then dividing the result by the lowest close price for the same period.
            // Finally, the index value is multiplied by 100.
            double congestionIndex = 100 * (MAX(Close, Period)[0] - MIN(Close, Period)[0]) / MIN(Close, Period)[0];

            CongestionIdx.Set(congestionIndex);

//			if (Volume[0] > SMA(Volume, volumePeriod)[0] * extremeVolume / 100)
//				DrawSquare(CurrentBar + "vol", false, 0, High[0] * 1.005, Color.Blue);
//			else if (Volume[0] > SMA(Volume, volumePeriod)[0] * highVolume / 100)
//				DrawSquare(CurrentBar + "vol", false, 0, High[0] * 1.005, Color.Cyan);


            if (VHFLine[0] < Threshold && CongestionIdx[0] < Threshold)
            {
                BackColor = _backColorChop;
            }
            else
            {
                BackColor = _backColorTrend;
            }
        }