Forex Trend fxfariz_001
Download scriptThis script is designed as a technical analysis tool for the MetaTrader platform, specifically optimized for scalping on 5-minute timeframes. It functions by analyzing price action to identify momentum and trend reversals, translating complex market movements into a visual signal that helps traders decide when to enter or exit positions.
Core Analytical Logic
The script operates by scanning historical price data over a user-defined period (defaulting to 23 bars). It identifies the highest high and the lowest low within this window to establish a "trading range." By calculating where the current price sits relative to these extremes, the tool determines the immediate strength of the market move.
To ensure smooth transitions and prevent erratic signals caused by sudden price spikes, the script employs a weighting system. It blends the current price position with previous data points, creating a continuous flow that filters out "noise" while maintaining the integrity of the trend.
Trend Interpretation
The logic processes this data into two primary visual components:
- Momentum Tracking: The script uses a logarithmic transformation to calculate the intensity of the price movement. This allows it to represent both small and large market swings proportionally, making it easier to see when a trend is accelerating or losing steam.
- Directional Signaling: By comparing the current momentum against the previous state, the script detects "crosses." When the calculated value shifts from positive to negative (or vice versa), it identifies a potential change in market direction.
User Notifications and Visuals
The tool provides clear visual feedback through a separate window on the chart:
- Dynamic Highlights: It uses two distinct histogram colors (Aqua and Red) to signify different trend directions. When the trend is bullish, one color dominates; when it turns bearish, the other takes over.
- Real-Time Alerts: The script features an automated notification system. It monitors the very latest price candle and sends an instant alert (popup message) whenever a trend reversal is detected. This ensures that traders can react immediately to market shifts without needing to constantly watch the screen.
Summary for the Trader
In essence, this tool acts as a "trend filter." It looks at the recent history of price peaks and valleys, calculates the current velocity of the market, and signals a clear change in direction the moment the momentum flips. It is designed to help you stay on the right side of a trend while providing early warnings when that trend begins to exhaust itself.
//+------------------------------------------------------------------+
//| fxfariz_scalpingM5.mq4 |
//| fxfariz a.k.a warrior trader |
//| fxfariz@gmail,com |
//+------------------------------------------------------------------+
#property copyright "fxfariz a.k.a warrior trader"
#property link "fxfariz@gmail,com"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color2 Aqua
#property indicator_color3 Red
#property indicator_style2 STYLE_SOLID
#property indicator_style3 STYLE_SOLID
#property indicator_width2 2
#property indicator_width3 2
extern int period=23;
double ExtBuffer0[];
double ExtBuffer1[];
double ExtBuffer2[];
double alertBar;
int init()
{
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_HISTOGRAM);
IndicatorDigits(Digits+1);
SetIndexBuffer(0,ExtBuffer0);
SetIndexBuffer(1,ExtBuffer1);
SetIndexBuffer(2,ExtBuffer2);
IndicatorShortName("Technique Scalping_TF5M by fxfariz");
SetIndexLabel(1,NULL);
SetIndexLabel(2,NULL);
return(0);
}
int start()
{
//int period=10;
int limit;
int counted_bars=IndicatorCounted();
double prev,current,old;
double Value=0,Value1=0,Value2=0,Fish=0,Fish1=0,Fish2=0;
double price;
double MinL=0;
double MaxH=0;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(int i=0; i<Bars; i++)
{
MaxH = High[Highest(NULL,0,MODE_HIGH,period,i)];
MinL = Low[Lowest(NULL,0,MODE_LOW,period,i)];
price = (High[i]+Low[i])/2;
if(MaxH-MinL == 0) Value = 0.33*2*(0-0.5) + 0.67*Value1;
else Value = 0.33*2*((price-MinL)/(MaxH-MinL)-0.5) + 0.67*Value1;
Value=MathMin(MathMax(Value,-0.999),0.999);
if(1-Value == 0) ExtBuffer0[i]=0.5+0.5*Fish1;
else ExtBuffer0[i]=0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1;
Value1=Value;
Fish1=ExtBuffer0[i];
}
bool up=true;
for(i=Bars; i>=0; i--)
{
current=ExtBuffer0[i];
prev=ExtBuffer0[i+1];
if (((current<0)&&(prev>0))||(current<0)) up= false;if (i==0 && Bars>alertBar) {Alert("ForexTrend Changing Up on ",Period()," ",Symbol(),")");alertBar = Bars;}
if (((current>0)&&(prev<0))||(current>0)) up= true;if (i==0 && Bars>alertBar) {Alert("ForexTrend Changing Down on ",Period()," ",Symbol(),")");alertBar = Bars;}
if(!up)
{
ExtBuffer2[i]=current;
ExtBuffer1[i]=0.0;
if (i==0 && Bars>alertBar) {Alert("ForexTrend Changing Up on ",Period()," ",Symbol(),")");alertBar = Bars;}
}
else
{
ExtBuffer1[i]=current;
ExtBuffer2[i]=0.0;
if (i==0 && Bars>alertBar) {Alert("ForexTrend Changing Down on ",Period()," ",Symbol(),")");alertBar = Bars;}
}
}
return(0);
}
Comments