w35260_Colored
Download scriptThis tool is designed as a visual analysis indicator for the MetaTrader platform, aimed at helping traders identify momentum shifts and trend directions by processing price data through multiple layers of calculation.
Core Logic Overview
The script works by comparing two different sets of market trends—one "fast" and one "slow"—to determine the underlying strength of the current price movement. By calculating the difference between these two speeds, the tool isolates the momentum of the market, filtering out minor noise to highlight significant directional changes.
How it Processes Data
The logic follows a three-step progression to arrive at its final visual output:
1. Momentum Calculation (The Difference) The script first looks at two separate trend lines. It subtracts the "slow" trend data from the "fast" trend data. This results in a raw momentum value. If the fast trend is moving significantly ahead of the slow trend, it indicates a surge in strength; if they are converging, the momentum is weakening.
2. Trend Directional Mapping Once the momentum values are calculated, the script analyzes whether those values are increasing or decreasing from one candle to the next. It categorizes this movement into two distinct visual components:
- Upward Momentum: When the current value is higher than the previous one, the script identifies this as a positive trend.
- Downward Momentum: When the current value drops, it identifies this as a negative trend.
These are displayed visually as histograms, allowing you to see the physical "weight" or size of the move in real-time.
3. The Signal Line (Smoothing) To prevent traders from reacting too quickly to every tiny fluctuation, the script applies a final smoothing layer. It takes all the momentum data gathered in the previous steps and runs it through a Moving Average. This creates a "Signal" line that acts as a stabilizer, helping to confirm whether the current momentum is sustained over time or just a momentary spike.
Summary of Visual Output
- Histograms: These provide a clear view of the current trend's strength and direction (up vs. down) based on the difference between fast and slow price actions.
- Signal Line: This serves as a reference point to help confirm the overall trend, providing a smoother perspective on the market's behavior compared to the raw data.
//+------------------------------------------------------------------+
//| w35260.mq4 |
//| IgorS |
//| igor.senych@gmail.com |
//+------------------------------------------------------------------+
#property copyright "IgorS"
#property link "igor.senych@gmail.com"
extern int p_fast = 21;
extern int t_fast = 3;
extern int pr_fast = 0;
extern int p_slow = 34;
extern int t_slow = 3;
extern int pr_slow = 0;
extern int Signal=5;
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Black
#property indicator_color2 Purple
#property indicator_color3 DarkOrange
#property indicator_color4 Red
#property indicator_width2 2
#property indicator_width3 2
//---- indicator buffers
double ExtBuffer0[];
double ExtBuffer1[];
double ExtBuffer2[];
double ExtBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexStyle(3,DRAW_LINE);
IndicatorDigits(Digits+1);
//---- 4 indicator buffers mapping
SetIndexBuffer(0,ExtBuffer0);
SetIndexBuffer(1,ExtBuffer1);
SetIndexBuffer(2,ExtBuffer2);
SetIndexBuffer(3,ExtBuffer3);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("w35260");
SetIndexLabel(1,"sdo");
SetIndexLabel(2,"sdo");
SetIndexLabel(3,"Signal");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Awesome Oscillator |
//+------------------------------------------------------------------+
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]=iCustom(Symbol(),0,"Slope_Direction_Line",p_fast,t_fast,pr_fast,2,i)-iCustom(Symbol(),0,"Slope_Direction_Line",p_slow,t_slow,pr_slow,2,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;
}
}
//---- signal line
for(i=0; i<limit; i++)
ExtBuffer3[i]=iMAOnArray(ExtBuffer0,Bars,Signal,0,MODE_SMA,i);
//---- done
return(0);
}
//+------------------------------------------------------------------+
Comments