Instantaneous Trendline (iTrend) free

by qualitiedx2 in category Trend at 16/05/2012
Description

The early identification of a trend then depends on a valid measurement of short-term cyclic activity. There are two ways to do so, either by cycle elimination or by spectrum analysis. Of the two, cycle elimination is by far the easier.The identification of the trend is that easy. One can eliminate the cyclic component when use the average over the cycle length.One could adjust the average as the cycle length varies and plot the results day-by-day. The author called the result an "instantaneous trendline".You can read more about this approach in Early Trend Identification by John F. Ehlers article published in 10/1990 Stocks&Commodities magazine.

itrend

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 = true, AccessRights = AccessRights.None)]
    public class ITrend : Indicator
    {
        [Output("ITrend",Color=Colors.Red)]
        public IndicatorDataSeries itrend { get; set; }
        
        [Output("Lag",Color=Colors.DodgerBlue)]
        public IndicatorDataSeries lag { get; set; }

        [Parameter(DefaultValue = 0.07)]
        public double Alpha { get; set; }
		
		private IndicatorDataSeries price;
		
		protected override void Initialize()
        {
        	price = CreateDataSeries();
		}

        public override void Calculate(int index)
        {
        	price[index] = (MarketSeries.High[index]+MarketSeries.Low[index])/2;
            if(index<3)
            {
            	itrend[index]=price[index];
           	}
           	else
           	{
           		if(index<7)
           		{
           			itrend[index]=((price[index]+
           			2*price[index-1]+price[index-2])/4);
           		}
           		else
           		{
           			itrend[index]=(Alpha - Alpha *Alpha/4)*price[index]
           			+0.5*Alpha*Alpha*price[index-1]-
           			(Alpha-0.75*Alpha*Alpha)*price[index-2]+2
           			*(1-Alpha )*itrend[index-1]-(1-Alpha )
           			*(1-Alpha )*itrend[index-2];
           		}
           		lag[index]=2*itrend[index]-itrend[index-2];
           	}
        }
    }
}
Comments
5