FXmFish[1]-2

Author: Skvorsov Konstantin
FXmFish[1]-2

The FX Fish indicator is a technical analysis tool designed to help traders visualize market momentum and identify potential entry or exit points. Instead of simply looking at raw price movements, this script processes data to determine the "strength" and "direction" of the current trend, representing these values as a visual histogram.

Core Logic and Mechanics

1. Data Input & Price Calculation The indicator begins by analyzing specific price points over a customizable period. It can be configured to look at various types of data, such as the closing price, opening price, or a balance of highs and lows. By calculating where the current price sits relative to the highest highs and lowest lows of a recent window, it establishes a baseline for market behavior.

2. Momentum Smoothing (The "Fish" Value) The script employs a sophisticated mathematical process to transform raw price data into a momentum value.

  • It measures how far the current price deviates from the established boundaries.
  • This deviation is smoothed out over time using a recursive calculation, meaning the indicator doesn't just react to one single tick; it considers the progression of the trend.
  • The result is a value that fluctuates above and below a zero baseline. A positive value generally indicates upward momentum, while a negative value suggests downward pressure.

3. Visual Representation The primary output is shown in a separate window as a histogram:

  • Lime (Green) Bars: Represent positive momentum.
  • Red Bars: Represent negative momentum. The height of these bars provides a visual cue regarding the intensity of the current market movement.

Trading Signals and Logic

The indicator identifies three primary types of market events based on the behavior of the "Fish" values:

  • Buy Signals: When the momentum value exceeds a specific threshold (strength) while simultaneously moving upward faster than the previous bars, it triggers a Buy signal. This suggests a strong, accelerating move to the upside.
  • Sell Signals: Conversely, when the momentum falls below a negative threshold and shows a sharp downward acceleration compared to previous bars, it triggers a Sell signal. This indicates a strong, accelerating move to the downside.
  • Exit Points: The script also monitors for "exhaustion" or trend reversals. If the momentum was positive but suddenly turns negative (or vice versa), the logic identifies an "Exit" point. This helps traders recognize when a trend might be losing steam and it may be time to close a position.

Summary of User Experience

For a trader, this indicator acts as a filter for market noise. By focusing on momentum rather than just price, it highlights:

  1. Trend Direction: Which way is the "weight" of the market moving?
  2. Trend Strength: How aggressively is that move happening?
  3. Timing: Identifying specific moments where momentum reaches a tipping point, providing clearer cues for entering or exiting trades compared to watching a standard price chart alone.
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
FXmFish[1]-2
//+------------------------------------------------------------------+
//|                                                      FX Fish.mq4 |
//|                                              Skvorsov Konstantin |
//|                                                    skvkv@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Skvorsov Konstantin"
#property link      "skvkv@mail.ru"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Aqua
#property indicator_color4 Yellow
           
double buffer1[];
double buffer2[];
double Bbuy[];
double Bsell[];


extern int period=10;
extern int Mode=MODE_SMA;
extern int price=0; // 0 or other = (H+L)/2
                    // 1 = Open
                    // 2 = Close
                    // 3 = High
                    // 4 = Low
                    // 5 = (H+L+C)/3
                    // 6 = (O+C+H+L)/4
                    // 7 = (O+C)/2
extern bool Mode_Fast= False;
extern bool Signals= False;
      
int init()
  {
  SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,Lime);
  SetIndexBuffer(0,buffer1);
  SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2,Red);
  SetIndexBuffer(1,buffer2);
  
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,159);
   SetIndexBuffer(2,Bbuy);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,159);
   SetIndexBuffer(3,Bsell);
  
  
  
  
  return(0);
  }

int deinit()
  {
  int i;
  double tmp;
  
  
  for (i=0;i<Bars;i++)
    {
    ObjectDelete("SELL SIGNAL: "+DoubleToStr(i,0));
    ObjectDelete("BUY SIGNAL: "+DoubleToStr(i,0));
    ObjectDelete("EXIT: "+DoubleToStr(i,0));
    }
  return(0);
  }


double Value=0,Value1=0,Value2=0,Fish=0,Fish1=0,Fish2=0;

int buy=0,sell=0;

int start()
  {
  int i,j;
  int barras;
  double _price;
  double tmp;
 
  
  double MinL=0;
  double MaxH=0;                    
  
  double Threshold=1.2; 

  barras = Bars;
  if (Mode_Fast)
    barras = 100;
   //..................................................................
   //....... Ýòî âcòàâëåííûé êîä äëÿ âèçóàëüíîãî òåñòèðîâàíèÿ èíäèêàòîðà 
   /**/  int start,start_j;
   /**/start_j=ObjectGet("start",OBJPROP_TIME1);     
   /**/if(GetLastError()==0) start=iBarShift(NULL,0,start_j,False); else start=0;
   //................êîíåö êîäà 
   //.....................................................................
 // i = 0;  //çàáàíåííûé ïàðàìåòð íà÷àëà öèêëà
 /**/i=start;  //íîâàÿ ãðàíèöà ðàñ÷åòà 
  while(i<barras)
   {
   MaxH = High[Highest(NULL,0,MODE_HIGH,period,i)];
   MinL = Low[Lowest(NULL,0,MODE_LOW,period,i)];
  
   switch (price)
     {
     case 1: _price = Open[i]; break;
     case 2: _price = Close[i]; break;
     case 3: _price = High[i]; break;
     case 4: _price = Low[i]; break;
     case 5: _price = (High[i]+Low[i]+Close[i])/3; break;
     case 6: _price = (Open[i]+High[i]+Low[i]+Close[i])/4; break;
     case 7: _price = (Open[i]+Close[i])/2; break;
     default: _price = (High[i]+Low[i])/2; break;
     }
   
        
   Value = 0.33*2*((_price-MinL)/(MaxH-MinL)-0.5) + 0.67*Value1;     
   Value=MathMin(MathMax(Value,-0.999),0.999); 
   Fish = 0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1;
   
   buffer1[i]= 0;
   buffer2[i]= 0;
   
   if ( (Fish<0) && (Fish1>0)) 
     {
     if (Signals)
       {
       ObjectCreate("EXIT: "+DoubleToStr(i,0),OBJ_TEXT,0,Time[i],_price);
       ObjectSetText("EXIT: "+DoubleToStr(i,0),"EXIT AT "+DoubleToStr(_price,4),7,"Arial",White);
       }
     buy = 0;
     }   
   if ((Fish>0) && (Fish1<0))
     {
     if (Signals)
       {
       ObjectCreate("EXIT: "+DoubleToStr(i,0),OBJ_TEXT,0,Time[i],_price);
       ObjectSetText("EXIT: "+DoubleToStr(i,0),"EXIT AT "+DoubleToStr(_price,4),7,"Arial",White);
       }
     sell = 0;
     }        
    
   if (Fish>=0)
     {
     buffer1[i] = Fish;
     }
   else
     {
     buffer2[i] = Fish;  
     }
     
   tmp = i;
   if ((Fish<-Threshold) && 
       (Fish>Fish1) && 
       (Fish1<=Fish2))
     {     
    
    Bsell[i]=Fish; //+20*Point;
    /*
     if (Signals)
       {
       ObjectCreate("SELL SIGNAL: "+DoubleToStr(i,0),OBJ_TEXT,0,Time[i],_price);
       ObjectSetText("SELL SIGNAL: "+DoubleToStr(i,0),"SELL AT "+DoubleToStr(_price,4),7,"Arial",Red);
       }
    */
     sell = 1;
     }

  if ((Fish>Threshold) && 
       (Fish<Fish1) && 
       (Fish1>=Fish2))
    {
    
    Bbuy[i]=Fish;//-20*Point;
    
    /*
    if (Signals)
       {
       ObjectCreate("BUY SIGNAL: "+DoubleToStr(i,0),OBJ_TEXT,0,Time[i],_price);
       ObjectSetText("BUY SIGNAL: "+DoubleToStr(i,0),"BUY AT "+DoubleToStr(_price,4),7,"Arial",Lime);
       }
     */
    buy=1;
    }

   Value1 = Value;
   Fish2 = Fish1;  
   Fish1 = Fish;
 
   i++;
   }
  return(0);
  }
//+------------------------------------------------------------------+

Comments