FisherTransform

Download script
Author: Coded by Witold Wozniak
FisherTransform

This technical indicator is designed to help traders identify market trends and potential reversals by analyzing price action through a mathematical lens known as the Fisher Transform. Unlike standard indicators that might show a lagging view of where the price has been, this script aims to clarify the "momentum" of the market, making it easier to see when a trend is reaching an extreme point or beginning to exhaust.

Core Logic and Data Processing

The tool operates by looking at specific historical windows of time (defined by the user as "Length"). To determine the current market sentiment, the logic follows these three main stages:

1. Price Normalization Instead of looking at raw price numbers—which can be volatile and difficult to compare across different assets—the script first simplifies the data. It identifies the highest high and the lowest low within the selected timeframe. It then calculates where the current midpoint of the price sits relative to that range. This converts the market movement into a standardized scale, allowing the tool to focus on the relative strength of the move rather than the absolute price.

2. Smoothing and Range Limitation The script takes that normalized value and applies a smoothing process. By blending the current data with the previous calculation, it filters out "noise" (minor, insignificant price flickers) to reveal the underlying trend. During this phase, the logic also ensures the values stay within a strictly controlled boundary. This prevents the indicator from producing erratic spikes, ensuring that the final output remains stable and readable.

3. The Fisher Transformation This is the final mathematical step. The smoothed data is processed through a logarithmic transformation. In practical terms, this "stretches" the data at the extremes (the edges of the move) and "compresses" it in the middle. By doing this, the indicator can more clearly highlight when the market is becoming overextended.

Visual Output for the Trader

The script produces two distinct visual components on your chart:

  • The Fisher Line: This represents the primary transformed momentum. It fluctuates above and below a zero line. When it moves significantly high or low, it suggests strong momentum in that direction.
  • The Trigger Line: This is essentially a "shadow" of the Fisher line, representing the previous value. By comparing the current Fisher Line against this Trigger Line, traders can look for "crossovers"—moments where the momentum shifts direction, which often serves as a signal to watch for a potential change in the market trend.
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
FisherTransform
//+------------------------------------------------------------------+
//|                                              FisherTransform.mq4 |
//|                                                                  |
//| Fisher Transform                                                 |
//|                                                                  |
//| Algorithm taken from book                                        |
//|     "Cybernetics Analysis for Stock and Futures"                 |
//| by John F. Ehlers                                                |
//|                                                                  |
//|                                              contact@mqlsoft.com |
//|                                          http://www.mqlsoft.com/ |
//+------------------------------------------------------------------+
#property copyright "Coded by Witold Wozniak"
#property link      "www.mqlsoft.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

#property indicator_level1 0

double Fisher[];
double Trigger[];
double Value1[];

extern int Length = 10;
int buffers = 0;
int drawBegin = 0;

int init() {
    if (Length < 3) Length = 3;
    drawBegin = Length;      
    initBuffer(Fisher, "Fisher", DRAW_LINE);
    initBuffer(Trigger, "Trigger", DRAW_LINE);
    initBuffer(Value1);
    IndicatorBuffers(buffers);
    IndicatorShortName("Fisher Tranform [" + Length + "]");
    return (0);
}
  
int start() {
    if (Bars <= Length)  return (0);
    int countedBars = IndicatorCounted();
    if (countedBars < 0) return (-1);
    if (countedBars > 0) countedBars--;
    int s, limit = Bars - countedBars - 1;
    for (s = limit; s >= 0; s--) {
        double price = P(s);
        double MaxH = price;
        double MinL = price;
        for (int i = 0; i < Length; i++) {
            price = P(s + i);
            if (price > MaxH) MaxH = price;
            if (price < MinL) MinL = price;
        }        
        Value1[s] = 0.5 * 2.0 * ((P(s) - MinL) / (MaxH - MinL) - 0.5) + 0.5 * Value1[s + 1];
        if (Value1[s] > 0.9999) Value1[s] = 0.9999;
        if (Value1[s] < -0.9999) Value1[s] = -0.9999;
        Fisher[s] = 0.25 * MathLog((1 + Value1[s]) / (1 - Value1[s])) + 0.5 * Fisher[s + 1];
        Trigger[s] = Fisher[s + 1];
    }    
    return (0);
}

double P(int index) {
    return ((High[index] + Low[index]) / 2.0);
}

void initBuffer(double array[], string label = "", int type = DRAW_NONE, int arrow = 0, int style = EMPTY, int width = EMPTY, color clr = CLR_NONE) {
    SetIndexBuffer(buffers, array);
    SetIndexLabel(buffers, label);
    SetIndexEmptyValue(buffers, EMPTY_VALUE);
    SetIndexDrawBegin(buffers, drawBegin);
    SetIndexShift(buffers, 0);
    SetIndexStyle(buffers, type, style, width);
    SetIndexArrow(buffers, arrow);
    buffers++;
}

Comments