easytrendvisualizer
Download scriptThis script is a custom technical analysis tool designed for the MetaTrader platform. Its primary purpose is to identify specific market trends and potential entry points by analyzing momentum and directional strength across multiple timeframes simultaneously.
Core Logic and Functionality
Multi-Layered Trend Analysis The script utilizes a specialized indicator known as the ADX (Average Directional Index), which measures the strength of a trend regardless of its direction. Rather than looking at just one setting, this tool calculates three different versions of this indicator at once, using different periods (for example, 10, 14, and 20). By monitoring three distinct layers, the script can better filter out "market noise" and identify when a trend is gaining significant and consistent strength.
Trend Confirmation Rules For the tool to signal a valid market movement, it looks for a "triple confirmation." It checks if all three of the multi-layered indicators are currently rising. Additionally, it verifies that these indicators have crossed specific intensity thresholds. This ensures that the tool only highlights movements where there is high conviction in the current price direction.
Visual Signals and Directional Detection Once the trend strength is confirmed, the script looks at the relationship between "Plus" and "Minus" directional values to determine the market's bias:
- Bullish Bias: If the positive directional momentum is stronger, the tool identifies an upward potential.
- Bearish Bias: If the negative directional momentum is stronger, it identifies a downward potential.
On-Chart Visuals The script translates these mathematical calculations into visual elements on your trading chart:
- Arrows: It places specific arrow markers to notify you of new directional shifts (Up or Down).
- Price Boundaries: It plots high and low price levels based on the identified trend.
- Trend Tracking: It can draw lines that persist during a trend to help visualize how far the price has moved from its origin point.
Alert System To help traders who cannot watch their screens constantly, the script includes an optional notification system. Based on your settings, it can trigger real-time alerts (pop-ups) for:
- New directional arrows appearing on the chart.
- Changes in specific price levels or trend boundaries.
Summary for the User
In simple terms, this tool acts as a "trend filter." It looks at the market's momentum through three different lenses at once; when all three agree that a strong movement is happening, it paints arrows and lines on your chart to highlight where the trend is going, providing you with clear visual cues for potential trading opportunities.
//KurlFX 23/6/09
//+------------------------------------------------------------------+
//| TADX.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright (c) 2009,KurlFX"
#define Alvl 35.0
#define Alvl2 30.0
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Red
#property indicator_color2 SteelBlue
#property indicator_width1 2
#property indicator_width2 2
#property indicator_color3 Indigo
#property indicator_color4 Indigo
#property indicator_color5 Indigo
#property indicator_width3 1
#property indicator_width4 1
//---- indicator parameters
extern int ADXperiod1 = 10;
extern int ADXperiod2 = 14;
extern int ADXperiod3 = 20;
extern bool UseAlertHorizontalLine=false;
extern bool UseAlertUpDownArrows=false;
//---
string Unq="TASSKlT",Label;
int MxP,MnP,MdP;
double was_alert_hl = EMPTY_VALUE; // Horizontal line
double was_alert_au = EMPTY_VALUE; // Arrow up
double was_alert_ad = EMPTY_VALUE; // Arrow down
//---- buffers
double To[];
double Tc[];
double ADX1[];
double ADX2[];
double ADX3[];
double Up[];
double Dn[];
double Ex[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- name for DataWindow and indicator subwindow label
MxP=MathMax(MathMax(ADXperiod1,ADXperiod2),ADXperiod3);
MnP=MathMin(MathMin(ADXperiod1,ADXperiod2),ADXperiod3);
if(MxP==ADXperiod1)MdP=MathMax(ADXperiod2,ADXperiod3);
else if(MxP==ADXperiod2)MdP=MathMax(ADXperiod1,ADXperiod3);
else MdP=MathMax(ADXperiod2,ADXperiod1);
Label=Unq+"("+MnP+"/"+MdP+"/"+MxP+")";
IndicatorBuffers(8);
SetIndexBuffer(0,To);
SetIndexBuffer(1,Tc);
SetIndexBuffer(2,Up);
SetIndexBuffer(3,Dn);
SetIndexBuffer(4,Ex);
SetIndexBuffer(5,ADX1);
SetIndexBuffer(6,ADX2);
SetIndexBuffer(7,ADX3);
SetIndexLabel(0,NULL);
SetIndexLabel(1,NULL);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexLabel(2,"Up");
SetIndexLabel(3,"Dn");
SetIndexLabel(4,"end");
SetIndexStyle(2,DRAW_ARROW);
SetIndexStyle(3,DRAW_ARROW);
SetIndexStyle(4,DRAW_LINE);
SetIndexArrow(2,225);
SetIndexArrow(3,226);
Comment(Label);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
Comment("");
return(0);
}
//+------------------------------------------------------------------+
//| main |
//+------------------------------------------------------------------+
int start()
{
int cntbar=IndicatorCounted();
int limit=Bars-cntbar;
if(cntbar==0)limit-=MxP;
for(int i=limit-1;i>=0;i--)
{
ADX1[i]=iADX(NULL,0,MnP,PRICE_CLOSE,MODE_MAIN,i);
ADX2[i]=iADX(NULL,0,MdP,PRICE_CLOSE,MODE_MAIN,i);
ADX3[i]=iADX(NULL,0,MxP,PRICE_CLOSE,MODE_MAIN,i);
}
if(cntbar==0)limit--;
for(i=limit-1; i>=0; i--)
{
bool f1=false,f2=false,f3=false;
To[i]=EMPTY_VALUE;Tc[i]=EMPTY_VALUE;
Up[i]=EMPTY_VALUE;Dn[i]=EMPTY_VALUE;Ex[i]=EMPTY_VALUE;
if(ADX1[i+1]<ADX1[i])f1=true;
if(ADX2[i+1]<ADX2[i])f2=true;
if(ADX3[i+1]<ADX3[i])f3=true;
if(f1 && f2 && f3 && ADX1[i]>Alvl && ADX2[i]>Alvl2)
{
double di=iADX(NULL,0,MnP,PRICE_CLOSE,MODE_PLUSDI,i)
-iADX(NULL,0,MnP,PRICE_CLOSE,MODE_MINUSDI,i);
double hi=MathMax(Open[i],Close[i]);
double lo=MathMin(Open[i],Close[i]);
double op=Open[i];
if(di>0)
{
To[i]=lo;Tc[i]=hi;
if(To[i+1]==EMPTY_VALUE)Up[i]=op;
}
else
{
To[i]=hi;Tc[i]=lo;
if(To[i+1]==EMPTY_VALUE)Dn[i]=op;
}
}
else
{
if(To[i+1]!=EMPTY_VALUE)Ex[i]=Close[i+1];
else Ex[i]=Ex[i+1];
}
}
//---
string DateTime=TimeYear(Time[0])+"-"+FormatDateTimeDigit(TimeMonth(Time[0]))+"-"+FormatDateTimeDigit(TimeDay(Time[0]))+" "+FormatDateTimeDigit(TimeHour(Time[0]))+":"+FormatDateTimeDigit(TimeMinute(Time[0]));
string PerStr=PeriodToString(Period());
if(UseAlertHorizontalLine)
{
if((Ex[1]!=EMPTY_VALUE) && (Ex[1]!=was_alert_hl) && (Ex[1]!=Ex[2]))
{
Alert("ETV-HL "+DateTime+" "+Symbol()+" @ "+PerStr);
was_alert_hl=Ex[1];
}
}
if(UseAlertUpDownArrows)
{
if((Up[0]!=EMPTY_VALUE) && (Up[0]!=was_alert_au))
{
Alert("ETV-AU "+DateTime+" "+Symbol()+" @ "+PerStr);
was_alert_au=Up[0];
}
if((Dn[0]!=EMPTY_VALUE) && (Dn[0]!=was_alert_ad))
{
Alert("ETV-AD "+DateTime+" "+Symbol()+" @ "+PerStr);
was_alert_ad=Dn[0];
}
}
//---
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
string FormatDateTimeDigit(int Input)
{
if(Input < 10) return("0" + Input);
else return(Input);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
string PeriodToString(int per)
{
switch(per)
{
case 60:
return("H1");
case 240:
return("H4");
case 1440:
return("D1");
case 10080:
return("W1");
case 43200:
return("MN1");
case 30:
return("M30");
case 15:
return("M15");
case 5:
return("M5");
case 1:
return("M1");
}
return("");
}
//+------------------------------------------------------------------+
Comments