FX_FISH Mod

Download script
Author: Copyright � 2005, Kiko Segui
FX_FISH Mod

The FX_FISH indicator is designed to provide a visual representation of market momentum and trend direction by calculating a smoothed oscillator. It translates complex price movements into a distinct histogram, helping traders identify when the market is gaining strength in one direction versus another.

Core Logic and Calculation

The script works by analyzing specific price points over a user-defined lookback period (defaulting to 30 bars). Here is how it processes that data:

1. Price Selection and Range Analysis The indicator first identifies the "High" and "Low" boundaries of the market within its lookback window. It then selects a specific price point to track—this can be the opening price, closing price, high, low, or various averages of these figures. By comparing the current price to these historical extremes, the script determines where the price sits relative to the recent "range."

2. Smoothing and Momentum Tracking Instead of reacting wildly to every small tick, the logic uses a smoothing formula. It takes the relative position of the current price (the "Value") and blends it with previous calculations. This creates a fluid movement that filters out minor noise while highlighting the primary trend.

3. Logarithmic Transformation To make the visual data more readable for human eyes, the script applies a logarithmic transformation to the values. This helps in visualizing accelerating trends, ensuring that the "Fish" (the oscillator value) provides a clear representation of momentum magnitude.

Visual Output and Signaling

The indicator produces two distinct visual outputs based on the calculated momentum:

  • The Histogram: The primary visual is split into two colors. Positive momentum is displayed in Lime, while negative momentum is shown in Red. This allows for an immediate at-a-glance understanding of whether the current trend is "bullish" or "bearish."
  • Automatic Signals: When specific conditions are met regarding the speed and direction of the momentum shift, the script can generate text labels on the chart:
    • Buy/Sell Signals: These appear when the momentum exceeds a specific "Threshold" (defaulting to 1.2) and shows a significant directional change compared to previous bars.
    • Exit Signals: The logic also monitors for trend reversals—specifically when the momentum crosses back toward the zero line—and can place "EXIT" labels to alert the user that the current move may be losing steam.

Key Features for the User

  • Fast Mode: A toggle allows the indicator to switch between a standard smoothed analysis and a "Fast" mode, which reacts more aggressively to immediate price changes.
  • Customizable Price Source: Users can choose exactly which price data (e.g., just the Highs, or a balanced average) drives the calculation to suit different trading styles.
  • Visual Clarity: By using a separate window and clear color coding, it provides a dedicated space for trend analysis that doesn't clutter the main price candles.
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
FX_FISH Mod
// FX_FISH
#property copyright "Copyright © 2005, Kiko Segui"
#property link      "webtecnic@terra.es"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_level1 0.2
#property indicator_level2 0.5
#property indicator_level3 1.0
#property indicator_level4 -0.2
#property indicator_level5 -0.5
#property indicator_level6 -1.0
// #property indicator_maximum 2
// #property indicator_minimum -2

           
double buffer1[];
double buffer2[];


extern int period=30;
extern int price=6; // 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= True;
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);
  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;
  int barras;
  double _price;
  double tmp;
  
  double MinL=0;
  double MaxH=0;                    
  
  double Threshold=1.2; 

  barras = Bars;
  if (Mode_Fast)
    barras = 1;
  i = 300;
  while(i>-1)
   {
   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 -0.5*Fish2;

   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))
     {     
     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))
    {
    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