Xma_Coloured[1]
Download scriptThis tool is designed to provide traders with a visual representation of price trends by smoothing out market noise and highlighting specific directional shifts. Rather than just following the raw, erratic movements of price, it uses a logic centered on "stability thresholds" to determine when a trend has actually changed.
How the Logic Works
1. Smoothing the Data The script starts by calculating moving averages based on a user-defined timeframe (the period). By doing this, it filters out minor fluctuations, creating a smoother line that represents the underlying direction of the market.
2. The Sensitivity Threshold One of the key features of this logic is the "threshold" system. Instead of reacting to every tiny wiggle in price, the script compares two different moving averages. It only acknowledges a trend change if the gap between these averages exceeds a specific size (the threshold). This prevents the indicator from flickering or giving false signals during sideways markets where the price is hovering without a clear direction.
3. Dynamic Trend Coloring The indicator uses three distinct visual layers to communicate market sentiment:
- Trend Continuity: When the price moves in alignment with the smoothed average, the indicator maintains its current flow. If the movement is too small to trigger a shift, it carries over the previous value to ensure a continuous, unbroken line on your chart.
- Bullish/Bearish Identification: The script constantly checks the relationship between the current closing price and the calculated signal level.
- If the price is consistently above the signal level, it identifies an upward movement (represented by one color).
- If the price falls below the signal level, it identifies a downward movement (represented by a different color).
Summary for the Trader
In simple terms, this script acts as a "smart" trend follower. It ignores "noise" by requiring a significant enough move to occur before it changes its mind about the market's direction. For the user, this results in a cleaner chart where the colors change only when a meaningful shift in momentum is detected, helping to identify whether the current environment is bullish, bearish, or transitioning between the two.
//+------------------------------------------------------------------+
//| Xma_Coloured.mq4 |
//| Copyright © 2009, XrustSolution. Toys from Vinin.|
//| http://www.xrust.ucoz.net http://www.vinin.ucoz.ru |
//| xrust@land.ru xrust@gmail.com xrust@mksat.net |
//| ???? ?????? ????????? ? ???????? ???????? ????????????????, |
//| ?????????? ?? ??? ???????? ?? ????????????? ????????? |
//-------------------------------------------------------------------+
#property copyright "#Copyright © 2008, XrustSolution.#"
#property link "#http://www.xrust.ucoz.net#"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color2 Yellow
#property indicator_color3 Blue
#property indicator_color4 Red
extern int period=12;
extern int porog =3;
extern int metod =1;
extern int metod2=1;
extern int prise =0;
//---- buffers
double Signal[];
double Up[];
double Dn[];
double Fl[];
//+------------------------------------------------------------------+
void init(){
SetIndexStyle(0,DRAW_NONE);
SetIndexDrawBegin(0,0);
SetIndexBuffer(0,Signal);
SetIndexStyle(1,DRAW_LINE);
SetIndexDrawBegin(1,0);
SetIndexBuffer(1,Fl);
SetIndexStyle(2,DRAW_LINE);
SetIndexDrawBegin(2,0);
SetIndexBuffer(2,Up);
SetIndexStyle(3,DRAW_LINE);
SetIndexDrawBegin(3,0);
SetIndexBuffer(3,Dn);
IndicatorShortName("Xma"+period+porog);
return;}
//+------------------------------------------------------------------+
int start() {
int limit;
double tmp1,tmp2;
int counted_bars=IndicatorCounted();
int i;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for (i = limit;i>=0;i--){
tmp1=iMA(Symbol(),0,period,0,metod,prise,i);
tmp2=iMA(Symbol(),0,period,1,metod2,prise,i);
if(MathAbs(tmp1-tmp2)>=porog*Point){
Signal[i]=tmp2;
if(i>0){
if(Close[i]<=Signal[i]){Dn[i]=Signal[i];}else{Fl[i]=Signal[i];}
if(Close[i] >=Signal[i]){Up[i]=Signal[i];}else{Fl[i]=Signal[i];}
}else{Fl[i]=Signal[i];}
}else{
Signal[i]=Signal[i+1];
Fl[i]=Signal[i];
}
}
return(0);}
//+------------------------------------------------------------------+
Comments