TZ Trend 30 min
Download scriptThis script is designed to analyze market trends by evaluating the relationship between three different Exponential Moving Averages (EMAs). By smoothing out price fluctuations, it helps traders identify the general direction of the market on a 30-minute timeframe.
How the Logic Works
The tool calculates three distinct moving averages based on specific time periods:
- Large EMA: A long-term average (set at 48 periods).
- Medium EMA: A medium-term average (set at 24 periods).
- Low EMA: A short-term average (set at 16 periods).
The script then compares the values of these three averages to determine the current market state. It categorizes the price action into one of three scenarios displayed directly on your chart:
1. UpTrend If the short-term average is higher than the medium-term average, and the medium-term average is in turn higher than the long-term average, the script identifies an "UpTrend." This suggests that recent price momentum is pushing upward more strongly than historical averages.
2. DownTrend If the long-term average is higher than the medium-term average, and the medium-term average is higher than the short-term average, the script identifies a "DownTrend." This indicates that price momentum is shifting downward relative to previous data.
3. Sideway (Neutral) If the averages do not follow a clear sequential order (for example, if they are intertwined or crossing each other), the script labels the market as "Sideway." This suggests that there is no strong directional trend and the market may be moving horizontally or experiencing consolidation.
Summary of Features
- Real-Time Monitoring: The script constantly updates the market status on the chart window based on the most recent completed candle.
- Data Transparency: Along with the trend description, the script displays the exact numerical values of all three EMAs, allowing you to see the precise data points behind the trend identification.
- Timeframe Specificity: The logic is specifically tuned to analyze price data from the 30-minute chart interval.
//+------------------------------------------------------------------+
//| TrendEMA.mq4 |
//| FxPars |
//| http://www.fxpars.com |
//+------------------------------------------------------------------+
#property copyright "FxPars"
#property link "http://www.fxpars.com"
#property indicator_chart_window
extern int LargeEMA=48;
extern int MediumEMA=24;
extern int LowEMA=16;
double Lma=0;
double Mma=0;
double Nma=0;
double pp=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
Lma=iMA(NULL,PERIOD_M30,LargeEMA,0,MODE_EMA,PRICE_CLOSE,1);
Mma=iMA(NULL,PERIOD_M30,MediumEMA,0,MODE_EMA,PRICE_CLOSE,1);
Nma=iMA(NULL,PERIOD_M30,LowEMA,0,MODE_EMA,PRICE_CLOSE,1);
if (Lma>Mma && Mma>Nma) {
Comment("DownTrend " + "\nLargeEMA= " + Lma + "\nMediumEMA= " + Mma + "\nLowEMA= " + Nma);
} else if (Lma<Mma && Mma<Nma) {
Comment("UpTrend " + "\nLargeEMA= " + Lma + "\nMediumEMA= " + Mma + "\nLowEMA= " + Nma);
} else {
Comment("Sideway " + "\nLargeEMA= " + Lma + "\nMediumEMA= " + Mma + "\nLowEMA= " + Nma);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments