Center Of Gravity Oscillator free

by qualitiedx2 in category Trend at 17/02/2012

COG is an oscillator based on an article by John F. Ehlers on page 20 of the May 2002 issue of Stocks and Commodities Magazine. COG has essentially zero lag and enables clear identification of turning points.

Center of Gravity

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class COGOsci : Indicator	//John Ehler's
        public IndicatorDataSeries cg { get; set; }

        public IndicatorDataSeries lag { get; set; }
        [Parameter(DefaultValue = 10)]
        public int Length { get; set; }

		private IndicatorDataSeries input;
		protected override void Initialize()
        	input = CreateDataSeries();
        public override void Calculate(int index)
            input[index] = (MarketSeries.High[index]+MarketSeries.Low[index])/2;
           	double Num=0;
            double Denom=0;
            for(int i=0;i<Length;i++)
            	Num += (1+i)*input[index-i];
            	Denom += input[index-i];
            	cg[index]= -Num/Denom + (Length+1)/2;