Adaptive_IFish

Download script
Author: Fabio Butto'
Adaptive_IFish

This script functions as a specialized technical analysis tool designed to visualize market momentum and sentiment by combining three distinct layers of data processing. Instead of simply looking at raw price movements, it filters the "noise" of the market to identify underlying cycles and trends.

How the Logic Works

1. Dynamic Cycle Detection The core of the script begins by determining the current market cycle. Rather than using a fixed timeframe, it references an external "CyclePeriod" calculation. This allows the tool to adapt to different market conditions, identifying how long a specific trend or movement typically lasts based on historical behavior.

2. Momentum Measurement (RSI Processing) Once the period is established, the script calculates a Relative Strength Index (RSI). It takes this momentum data and normalizes it—essentially centering the data so that it fluctuates around a neutral baseline. By using half of the detected cycle period to calculate this momentum, the tool ensures that it is reacting at a speed appropriate for the current market environment.

3. Trend Smoothing To prevent the indicator from jumping erratically with every minor price tick, the script applies a Linear Weighted Moving Average (LWMA) to the processed momentum data. This smoothing process prioritizes more recent information while filtering out minor fluctuations, resulting in a cleaner, more readable trend line.

4. Final Signal Conversion In the final stage, the script performs a mathematical transformation on the smoothed data to produce the "IFish" value. This converts the raw numbers into a specific range (typically between -1 and 1). The result is a visual representation that makes it easier for a user to see:

  • Strength of Trend: How far the line deviates from the center.
  • Direction: Whether the current momentum is leaning bullish or bearish.
  • Stability: How consistently the price is moving in its current direction.

Summary for the User

In simple terms, this script acts like a "smart filter." It looks at the market's past cycles to figure out how fast it is currently moving, calculates the strength of that movement, smooths out the jagged edges of that data, and presents it to you as a clear, adaptive line. This helps traders identify the underlying "heartbeat" of the market rather than getting distracted by temporary price spikes.

Indicators Used
Relative strength indexMoving average indicator
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
Adaptive_IFish
//+------------------------------------------------------------------+
//|                                               Adaptive_IFish.mq4 |
//|                                                     Fabio Butto' |
//|                                            fabio.butto@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Fabio Butto'"
#property link      "fabio.butto@gmail.com"
#property indicator_buffers 1
#property indicator_color1 DarkOrchid
 
#property indicator_level1 0.5
#property indicator_level2 -0.5
#property indicator_levelcolor Orange
#property indicator_maximum 1
#property indicator_minimum -1
double value1[];
double value2[];
double ifish[];
double red[];
double green[];
double period;
double Alpha = 0.07;

#property indicator_separate_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(3);
   
   SetIndexBuffer(0,ifish);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
  
   SetIndexBuffer(1,value1);
   SetIndexBuffer(2,value2);
   
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) counted_bars=0;
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- 
   for(int i = 0 ;i <= limit ;i++)
     { 
      period=iCustom(0, PERIOD_D1, "CyclePeriod", Alpha, 0, i);
      int RSIPeriod = MathFloor(period/2);
      value1[i] = 0.1*(iRSI(Symbol(),0,RSIPeriod,PRICE_OPEN,i)-50);
     }  
   for(int j = 0 ;j <= limit ;j++) value2[j] = iMAOnArray(value1,0,RSIPeriod+1,0,MODE_LWMA,j);
   for(int f = 0 ;f <= limit ;f++) ifish[f] = (MathExp(2*value2[f])-1)/(MathExp(2*value2[f])+1);
   
  
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments