#property copyright "#Copyright ฉ 2008, XrustSolution.#"
#property link "#http://www.xrust.ucoz.net#"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Aqua
#property indicator_color3 Red
extern int period=12;
extern int porog =3;
extern int metod =1;
extern int metod2=1;
extern int prise =0;
extern bool _Color=true;
//---- buffers
double Signal[];
double Up[];
double Dn[];
bool up=false,dn=false;
//+------------------------------------------------------------------+
void init(){
SetIndexStyle(0,DRAW_LINE);
SetIndexDrawBegin(0,0);
SetIndexBuffer(0,Signal);
SetIndexStyle(1,DRAW_LINE);
SetIndexDrawBegin(0,0);
SetIndexBuffer(1,Up);
SetIndexStyle(2,DRAW_LINE);
SetIndexDrawBegin(0,0);
SetIndexBuffer(2,Dn);
IndicatorShortName("Xma_color"+period+porog);
return;}
//+------------------------------------------------------------------+
int start() {
int limit;
//bool up,dn;
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=tmp2;
}else{
Signal=Signal[i+1];
}
}
if (_Color) {
for (i = limit;i>=0;i--) {
Up=EMPTY_VALUE;
Dn=EMPTY_VALUE;
if (Signal>Signal[i+1]) {Up=Signal;Up[i+1]=Signal[i+1];up=true;dn=false;}
if (Signal<Signal[i+1]) {Dn=Signal;Dn[i+1]=Signal[i+1];dn=true;up=false;}
if (Signal==Signal[i+1] && up) Up=Signal;
else if (Signal==Signal[i+1] && dn) Dn=Signal;
}
}
return(0);}
//+------------------------------------------------------------------+