FX_FISH-mod_v1
Download scriptThis script is a technical analysis indicator designed for the MetaTrader platform to help traders visualize price momentum and identify potential entry or exit points in the financial markets. Instead of simply following the raw price, it uses a customized mathematical approach to smooth out market "noise" and highlight trends.
How the Logic Works
1. Price Definition and Context The indicator allows you to choose which specific part of a price candle it should focus on (such as the Open, Close, High, Low, or an average of these values). It then looks at a specific window of time (the "period") to identify the highest highs and lowest lows. This creates a boundary for the current market movement.
2. Momentum Calculation The core of the script involves a multi-step calculation to determine market sentiment:
- Relative Positioning: It determines where the current price sits relative to the recent highs and lows found in the previous step.
- Smoothing: It takes that position and blends it with previous data points. This prevents the indicator from reacting too wildly to small, insignificant price flickers.
- Logarithmic Transformation: The script applies a mathematical "Log" function to these values. This is used to convert standard price movements into a momentum value, making it easier to see if the market is accelerating or decelerating.
3. Visual Representation The results are displayed in a separate window below your main price chart as two distinct colored histograms:
- Steel Blue: Represents positive momentum or values above zero.
- Orange: Represents negative momentum or values below zero.
4. Automated Signal Logic The script includes an intelligent filtering system to provide specific visual cues on the chart:
- Buy and Sell Signals: The tool looks for "breakout" conditions. A Buy Signal appears when the momentum moves significantly above a pre-defined threshold while simultaneously showing a sharp upward turn compared to previous bars. Conversely, a Sell Signal appears when momentum drops significantly below that threshold with a sharp downward turn.
- Exit Alerts: The script also monitors for "momentum reversals." If the indicator shows that the strength of a trend is fading (e.g., shifting from positive to negative), it can place an "EXIT" label on the chart. This serves as a warning that the current move may be losing steam.
Summary for the User
In plain terms, this tool acts like a "momentum filter." It looks at how hard the price is pushing in one direction compared to recent history, smooths out the erratic movements of the market, and then draws signals on your screen when it detects that the price has reached a high level of strength (for entry) or is starting to tire out (for exiting).
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
#property copyright "Copyright © 2005, Kiko Segui"
#property link "webtecnic@terra.es"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 SteelBlue
#property indicator_color2 Orange
// #property indicator_maximum 2
// #property indicator_minimum -2
double buffer1[];
double buffer2[];
extern int period=10;
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= True;
extern bool Signals= False;
int init()
{
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1,SteelBlue);
SetIndexBuffer(0,buffer1);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1,Orange);
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