IFish_v1
Download scriptThis custom trading indicator is designed to provide visual signals and real-time alerts by analyzing momentum and price trends. Instead of looking at raw prices directly, the script processes market data through a multi-layered mathematical transformation to identify specific turning points in the market cycle.
How the Logic Works
The indicator operates through three distinct stages of calculation:
1. Momentum Filtering The process begins by taking the Relative Strength Index (RSI)—a common tool used to measure the speed and change of price movements—over a very short timeframe. The script then adjusts this value so that it centers around a neutral midpoint. This helps the indicator focus on the "pulse" of the market rather than the absolute price.
2. Trend Smoothing To filter out minor market "noise" and erratic fluctuations, the script applies a Linear Weighted Moving Average to the filtered momentum data. This smoothing effect ensures that the indicator responds to sustained trends rather than momentary spikes or dips, providing a more stable foundation for its final signals.
3. The Hyperbolic Transformation The smoothed data is then put through a specific mathematical formula (a hyperbolic tangent function). This converts the smoothed trend into a standardized range. This step is crucial because it flattens the extremes and compresses the data into a predictable window, making it easier to identify when the market is reaching a peak or a valley.
Signals and Alerts
The indicator monitors this final transformed value against two specific thresholds:
- Upper Threshold (0.5): When the logic determines that momentum has surged to the top of its range, it triggers an alert indicating a potential "exit" point for Buy positions.
- Lower Threshold (-0.5): When the logic determines that momentum has dropped to the bottom of its range, it triggers an alert indicating a potential "exit" point for Sell positions.
User Experience
The script is designed to be proactive. If the SoundON setting is enabled, the platform will provide an audible alert and a pop-up notification the moment the data crosses these critical levels. It includes internal logic to ensure that alerts are only triggered once per occurrence, preventing the system from sending repetitive notifications on the same price movement.
//+------------------------------------------------------------------+
//| IFish.mq4 |
//| Kalenzo |
//| bartlomiej.gorski@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link "bartlomiej.gorski@gmail.com"
#property indicator_buffers 1
#property indicator_color1 Yellow
#property indicator_level1 0.5
#property indicator_level2 -0.5
double value1[];
double value2[];
double ifish[];
double red[];
double green[];
double alertBar;
double prev;
double high=0.5;
double low=-0.5;
extern bool SoundON=true;
#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++) value1[i] = 0.1*(iRSI(Symbol(),0,5,PRICE_CLOSE,i)-50);
for(int j = 0 ;j <= limit ;j++) value2[j] = iMAOnArray(value1,0,9,0,MODE_LWMA,j);
for(int f = 0 ;f <= limit ;f++) ifish[f] = (MathExp(2*value2[f])-1)/(MathExp(2*value2[f])+1);
if(ifish[f] >= high && prev==0) prev = 1;
if(ifish[f] <= low && prev==0) prev = 2;
if(SoundON==true && prev == 1 && ifish[f] >= high && Bars>alertBar) {Alert("IFISH Hit 0.5 or above exit Buy on ",Symbol()," Period ",Period());alertBar = Bars;prev = 2;}
if(SoundON==true && prev == 2 && ifish[f] <= low && Bars>alertBar) {Alert("IFISH Hit -0.5 or below exit Sell on ",Symbol()," Period ",Period());alertBar = Bars;prev = 1;}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments