Dzani9_Minor_in_Major_Elliott_Wave
Download scriptThis tool is designed to help traders visualize the relationship between broader market momentum and short-term price movements. It functions by identifying whether a "minor" trend is moving in harmony with or against a "major" trend, helping users distinguish between true momentum shifts and temporary fluctuations.
How the Logic Works
1. Establishing the Momentum Baseline The script first calculates a momentum value by comparing two different types of moving averages. By looking at a very fast average (representing immediate price action) and subtracting a much slower average (representing the broader market trend), the tool generates a raw momentum score. This difference tells us how quickly the price is accelerating relative to its long-term history.
2. Identifying Directional Flow Once the momentum score is established, the script analyzes whether that score is currently increasing or decreasing compared to the previous moment. It tracks these changes in real-time to determine the "flow" of the market:
- When the momentum score rises, it signals upward pressure.
- When the momentum score falls, it signals downward pressure.
3. Visual Classification (Color Coding) The logic then categorizes these movements into a visual format to make the data easier to read at a glance. Instead of showing a single continuous line, it splits the data into two distinct components:
- Positive Momentum: When the momentum is moving upward, the script highlights this activity in green. This suggests that the immediate price action is strengthening.
- Negative Momentum: When the momentum begins to dip or turn downward, the script highlights this activity in red. This signals that the current price movement is losing steam or reversing.
Summary for the User
Essentially, this indicator acts as a filter. It takes complex momentum calculations and simplifies them into a clear, color-coded histogram. By looking at the transition between green and red areas, you can see exactly where the "minor" short-term moves are gaining strength or starting to weaken against the backdrop of the overall market trend.
//+------------------------------------------------------------------+
//| dzani9_Minor_in_major_trend.mq4 |
//| MetaQuotes Software Corp. |
//| dzani9@yahoo.co.uk |
//+------------------------------------------------------------------+
#property copyright "dzani9_Minor_in_major_trend.mq4."
#property link "dzani9@yahoo.co.uk"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Black
#property indicator_color2 Green
#property indicator_color3 Red
//---- indicator buffers
double ExtBuffer0[];
double ExtBuffer1[];
double ExtBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_HISTOGRAM);
IndicatorDigits(Digits+1);
SetIndexDrawBegin(0,34);
SetIndexDrawBegin(1,34);
SetIndexDrawBegin(2,34);
//---- 3 indicator buffers mapping
SetIndexBuffer(0,ExtBuffer0);
SetIndexBuffer(1,ExtBuffer1);
SetIndexBuffer(2,ExtBuffer2);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("dzani9_Minor_in_major_trend");
SetIndexLabel(1,NULL);
SetIndexLabel(2,NULL);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| dzani9_Minor_in_major_trend |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
double prev,current;
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd
for(int i=0; i<limit; i++)
ExtBuffer0[i]=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,i);
//---- dispatch values between 2 buffers
bool up=true;
for(i=limit-1; i>=0; i--)
{
current=ExtBuffer0[i];
prev=ExtBuffer0[i+1];
if(current>prev) up=true;
if(current<prev) up=false;
if(!up)
{
ExtBuffer2[i]=current;
ExtBuffer1[i]=0.0;
}
else
{
ExtBuffer1[i]=current;
ExtBuffer2[i]=0.0;
}
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
Comments