Fisher_v1
Download scriptThis tool is a technical analysis indicator designed to help traders identify momentum shifts and trend reversals in financial markets. Rather than just looking at price action alone, it processes data to determine whether the current market movement is gaining strength or losing steam.
How the Logic Works
The indicator operates by calculating the relationship between current market prices and recent historical highs and lows. Here is a breakdown of the process:
1. Data Collection & Normalization The script looks back at a specific number of candles (defined by the user) to identify the highest price reached and the lowest price reached during that timeframe. It then takes a moving average of the current price to determine where the market is currently positioned relative to those highs and lows. This "normalizes" the price into a value between -1 and 1, allowing the tool to compare different assets (like different currencies or stocks) on a consistent scale.
2. Smoothing and Filtering To prevent the data from jumping around erratically due to small, insignificant price fluctuations, the script applies a smoothing calculation. It blends the current normalized value with the previous value using a specific weighting system. This ensures that the resulting trend line is fluid and represents a sustained movement rather than momentary "noise."
3. The Fisher Transformation The core of this logic is a mathematical transformation called the Fisher Transfom. By applying a logarithmic calculation to the smoothed values, the tool effectively "squashes" extreme price movements while expanding smaller ones. This makes it much easier for a trader to spot when a trend is reaching an exhaustion point and is about to turn around.
4. Visual Indicators and Alerts The results are displayed in a separate window as a histogram:
- Positive Values: When the calculated momentum turns positive, it appears as an upward trend (Light Blue).
- Negative Values: When the momentum turns negative, it appears as a downward trend (Tomato).
5. Automated Notifications The script is designed to act as an active monitor. It constantly checks for "crosses"—the exact moment the indicator flips from positive to negative (or vice versa). Whenever such a shift occurs, the system triggers an audible alert sound, notifying the trader of a potential change in market direction in real-time.
//+------------------------------------------------------------------+
//| Fisher_v1.mq4 |
//| Copyright © 2005, TrendLaboratory Ltd. |
//| http://finance.groups.yahoo.com/group/TrendLaboratory |
//| E-mail: igorad2004@list.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, TrendLaboratory Ltd."
#property link "http://finance.groups.yahoo.com/group/TrendLaboratory"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LightBlue
#property indicator_color2 Tomato
//---- input parameters
extern int Length=10;
extern int Price=4;
extern int NumBars=0;
extern string AlertFileName = "alert.wav";
//---- buffers
double UpBuffer [];
double DnBuffer [];
double Value [];
double Fisher[];
int init()
{
IndicatorBuffers(4);
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
SetIndexBuffer(0,UpBuffer);
SetIndexBuffer(1,DnBuffer);
SetIndexBuffer(2,Value);
SetIndexBuffer(3,Fisher);
IndicatorShortName ("Fisher(" + Length + "," + Price + ")");
SetIndexLabel (0, "UpTrend");
SetIndexLabel (1, "DownTrend");
SetIndexDrawBegin(0,Length);
SetIndexDrawBegin(1,Length);
return(0);
}
//+------------------------------------------------------------------+
//| Fisher_v1 |
//+------------------------------------------------------------------+
int start()
{
int shift;
double smin=0,smax=0;
if (NumBars>0) int NBars=NumBars; else NBars=Bars;
for(shift=NBars;shift>=0;shift--)
{
UpBuffer[shift]=0.0;
DnBuffer[shift]=0.0;
Value [shift]=0.0;
Fisher[shift]=0.0;
}
for(shift=NBars-1-Length;shift>=0;shift--)
{
smax = High[Highest(NULL,0,MODE_HIGH,Length,shift)];
smin = Low[Lowest(NULL,0,MODE_LOW,Length,shift)];
double price = iMA(NULL,0,1,0,0,Price,shift);
if (smax-smin==0.0) double wpr=1.0; else wpr=(price-smin)/(smax-smin);
Value[shift] = 0.33*2*(wpr-0.5) + 0.67*Value[shift+1];
Value[shift] = MathMin(MathMax(Value[shift],-0.999),0.999);
Fisher[shift] = 0.5*MathLog((1.0+Value[shift])/(1.0-Value[shift]))+0.5*Fisher[shift+1];
static datetime dt = 0;
if (Fisher[shift]>=0)
{
UpBuffer[shift] = Fisher[shift];
DnBuffer[shift] = 0.0;
if ((UpBuffer[shift+1] == 0) && ( dt != iTime(NULL,0,0)))
{
PlaySound(AlertFileName);
dt = iTime(NULL,0,0);
}
}
else
{
UpBuffer[shift] = 0.0;
DnBuffer[shift] = Fisher[shift];
if ((DnBuffer[shift+1] == 0) && ( dt != iTime(NULL,0,0)))
{
PlaySound(AlertFileName);
dt = iTime(NULL,0,0);
}
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments