FN Signal_v2

Download script
Author: Belomor
FN Signal_v2

This tool is designed to provide visual market signals by analyzing price fluctuations and smoothing out "market noise" to identify potential trends. Instead of looking at raw price data alone, it uses a multi-layered mathematical approach to determine whether the current momentum is shifting in an upward or downward direction.

How the Logic Works

1. Statistical Normalization The script begins by measuring how far the current price has deviated from its recent average. It looks at the distance between the closing price and a moving average, then scales that distance based on the market's volatility (standard deviation). This step is crucial because it helps the tool understand if a price move is significant relative to recent history or just minor "jitter."

2. The Fisher Transformation Once the data is normalized, the script applies a specific mathematical transformation known as a Fisher calculation. This process compresses extreme price spikes and expands smaller movements into a more readable format. Essentially, it takes volatile, erratic market data and converts it into a smoother wave-like pattern that is much easier to interpret visually.

3. Trend Smoothing (The Signal Line) To prevent the tool from reacting too quickly to minor fluctuations, the script calculates a "Signal" line. This is a long-term moving average of the transformed data. Think of this as the "baseline" or the "equilibrium" of the current trend.

4. Dynamic Signal Generation (Fast vs. Slow) The final output is determined by comparing two different speeds of calculation:

  • The Fast Component: This tracks very recent changes in momentum.
  • The Slow Component: This reflects the broader, established trend.

When the Fast momentum crosses above the Slow signal line, the tool identifies an upward push (represented on your chart as a Green histogram). Conversely, when the Fast momentum falls below the Slow signal line, it identifies a downward pressure (represented as a Red histogram).

Summary for the User

In simple terms, this script takes messy market data, smooths out the noise using advanced statistics, and then watches for specific "crossings" between short-term momentum and long-term trends. When these two speeds disagree, it provides you with a visual signal of which way the market is likely leaning at that moment.

Indicators Used
Moving average indicatorStandard Deviation indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
17 Views
0 Downloads
0 Favorites
FN Signal_v2
//+------------------------------------------------------------------+
//|                                                    FN Signal.mq4 |
//|                                                          Belomor |
//|                                                 belomor@inbox.ru |
//+------------------------------------------------------------------+
#property copyright "Belomor"
#property link      "belomor@inbox.ru"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Silver
#property indicator_level1 1
#property indicator_level2 2
#property indicator_level3 -1
#property indicator_level4 -2
//---- input parameters
extern int       FN=34;
extern double    Deviation=3.0;
extern int       FastEMA=5;
extern int       SlowEMA=13;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexStyle(2,DRAW_LINE,STYLE_DOT);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
   if(FN<2)
   FN=2;
   if(Deviation<0)
   Deviation=1;
   if(FastEMA<1)
   FastEMA=1;
   if(SlowEMA<1)
   SlowEMA=1;
   IndicatorShortName("FN Signal ("+FN+","+FastEMA+","+SlowEMA+")");
   SetIndexDrawBegin(0,FN+SlowEMA);
   SetIndexDrawBegin(1,FN+SlowEMA);
   SetIndexDrawBegin(2,FN+SlowEMA);
   SetIndexLabel(0,"FN Up");
   SetIndexLabel(1,"FN Down");
   SetIndexLabel(2,"Signal");
   SetIndexEmptyValue(0,0);
   SetIndexEmptyValue(1,0);
   IndicatorDigits(4);
//----
   return(0);
  }
  
double NormalizedX(int F_period, int i)
   {
   double result;
   double A;
   double S;
   double C;
   if(i<Bars-F_period)
   {
   C=Close[i];
   A=iMA(NULL,0,F_period,0,MODE_SMA,PRICE_CLOSE,i);
   S=iStdDev(NULL,0,F_period,MODE_SMA,0,PRICE_CLOSE,i);
   result=(C-A)/S;
   }
   else
   result=0;
   return(result);
   }
   
double FisherNormalizedX(int F_period, double Dev, int i)
   {
   double result;
   double X;
   if(i<Bars-F_period && Dev>0)
   {
   X=NormalizedX(F_period,i)/Dev;
   if(X>0.99)
   X=0.99;
   if(X<-0.99)
   X=-0.99;
   result=0.5*MathLog((1+X)/(1-X));
   }
   else
   result=0;
   return(result);
   }
   
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(int i=0; i<limit; i++)
      ExtMapBuffer4[i]=FisherNormalizedX(FN,Deviation,i);
   for(i=0; i<limit; i++)
      ExtMapBuffer3[i]=iMAOnArray(ExtMapBuffer4,Bars,SlowEMA,0,MODE_EMA,i);
   for(i=0; i<limit; i++)
      {
      if(iMAOnArray(ExtMapBuffer4,Bars,FastEMA,0,MODE_EMA,i)>ExtMapBuffer3[i])
         {
         ExtMapBuffer1[i]=iMAOnArray(ExtMapBuffer4,Bars,FastEMA,0,MODE_EMA,i);
         ExtMapBuffer2[i]=0;
         }
      else
         {
         ExtMapBuffer1[i]=0;
         ExtMapBuffer2[i]=iMAOnArray(ExtMapBuffer4,Bars,FastEMA,0,MODE_EMA,i);
         }
      }
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments