Fisher Transformation

by A T in category Oscilator at 17/02/2012
Description

This is a very fast crossover trade trigger indicator and if used in conjunction with a good trend-following tool it is predictive and can be applied in strategies (coming soon). When compared to MACD or other crossover indicators the Fisher Transform is clearly superior and timely.

Fisher Transformation

Download
4710 downloads
How to install
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 FisherTransform : Indicator
    {       
        [Output("FisherTransform", Color = Colors.Orange)]
        public IndicatorDataSeries Fish { get; set; }
    	
    	[Output("Trigger", Color = Colors.Green)]
        public IndicatorDataSeries trigger { get; set; }
        
        [Parameter(DefaultValue = 13, MinValue = 2)]
        public int Len { get; set; }
		
		double MaxH;
		double MinL;
		int tr = 0;
		private IndicatorDataSeries price;
		private IndicatorDataSeries Value1;
		
		protected override void Initialize()
        {
        	price = CreateDataSeries();
        	Value1 = CreateDataSeries();
		}
        public override void Calculate(int index)
        {
        	if(index <= Len+1)
        	{
        	Value1[index-1]=1;
        	Fish[index-1]=0;
        	}

			price[index] = (MarketSeries.High[index]+MarketSeries.Low[index])/2;
			
			MaxH=price[index];
			MinL=price[index];
			for(int i=index; i > index - Len; i--)
			{
				MinL = Math.Min(MinL,price[i]);
				MaxH = Math.Max(MaxH,price[i]);
			}
			if(Value1[index] > 0.9999){Value1[index] = 0.9999;}
			if(Value1[index] < -0.9999) {Value1[index] = -0.9999;}
			
			Value1[index] = 0.5*2*((price[index]-MinL)/(MaxH-MinL)-0.5)+0.5*Value1[index-1];
			
			Fish[index] = 0.25*Math.Log((1+Value1[index])/(1-Value1[index])) +0.5*Fish[index-1];
			trigger[index] = Fish[index-1];
        }
    }
}
Comments

aimerdoux - March 13, 2016 @ 18:56

Sorry I might be wrong but can you explain me why do you calculate the fisher transform without calculating the Correlation coefficient ? thank you

cwik_m - July 08, 2018 @ 19:04

Most of your indicators are great! and really useful

Unfortunatelly, this one doesn't show anything once loaded onto the chart

Moreover, the variable from line 22 (int tr = 0;) is not used anywhere..

Could you, by any chance, look into this code again, please?

gakazas - April 27, 2019 @ 16:51

Here is the code optimized, and with a fix. the 0.9999 check should be after assigning a value to Value1, thats why some periods appear are blank.


using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class FisherTransform : Indicator
    {
        [Output("FisherTransform", LineColor = "Orange")]
        public IndicatorDataSeries Fish { get; set; }

        [Output("Trigger", LineColor = "Green")]
        public IndicatorDataSeries trigger { get; set; }

        [Parameter(DefaultValue = 13, MinValue = 2)]
        public int Len { get; set; }

        double MaxH;
        double MinL;
        private IndicatorDataSeries Value1;

        protected override void Initialize()
        {
            Value1 = CreateDataSeries();
        }
        public override void Calculate(int index)
        {
            if (index <= Len + 1)
            {
                Value1[index - 1] = 1;
                Fish[index - 1] = 0;
            }

            MaxH = MarketSeries.Median.Maximum(Len);
            MinL = MarketSeries.Median.Minimum(Len);
            Value1[index] = 0.5 * 2 * ((MarketSeries.Median[index] - MinL) / (MaxH - MinL) - 0.5) + 0.5 * Value1[index - 1];

            if (Value1[index] > 0.9999)
                Value1[index] = 0.9999;
            else if (Value1[index] < -0.9999)
                Value1[index] = -0.9999;

            Fish[index] = 0.25 * Math.Log((1 + Value1[index]) / (1 - Value1[index])) + 0.5 * Fish[index - 1];
            trigger[index] = Fish[index - 1];
        }
    }
}

5