#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 White
#property indicator_color2 Yellow
#property indicator_color3 Silver
#property indicator_color4 C'0,45,0'
#property indicator_color5 FireBrick
#property indicator_width2 3
#property indicator_width4 3
#property indicator_width5 3
#property indicator_level1 0
#property indicator_levelstyle 0
#property indicator_levelcolor Silver
extern int Periods = 5;
extern int Periods2 = 9;
double buf1[];
double buf2[];
double buf3[];
double buf4[];
double buf5[];
int init(){
IndicatorBuffers(5);
SetIndexStyle (0,DRAW_LINE);
SetIndexBuffer(0,buf1);
SetIndexStyle (1,DRAW_LINE);
SetIndexBuffer(1,buf2);
SetIndexStyle (2,DRAW_LINE);
SetIndexBuffer(2,buf3);
SetIndexStyle (3,DRAW_LINE);
SetIndexBuffer(3,buf4);
SetIndexStyle (4,DRAW_LINE);
SetIndexBuffer(4,buf5);
SetIndexDrawBegin(1,Periods);
SetIndexDrawBegin(3,Periods2);
IndicatorShortName("BendCourse");
return(0);
}
int start(){
int i,limit;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(Bars<=Periods) return(0);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i=0; i<limit; i++)
buf2[i]=iMA(NULL,0,Periods2,0,MODE_EMA,PRICE_CLOSE,i);
for(i=0;i<limit; i++)
buf3[i]=iMAOnArray(buf2,Bars,Periods,0,MODE_EMA,i);
for(i=0;i<limit; i++)
buf2[i]=iMAOnArray(buf3,Bars,Periods,0,MODE_EMA,i);
for(i=0;i<limit-1; i++)
buf1[i] = (buf3[i]-buf3[i+1])/buf3[i+1]*50000;
for(i=0;i<limit-1;i++)
buf3[i]=(buf2[i]-buf2[i+1])/buf2[i+1]*50000;
for(i=0;i<limit-1;i++)
buf2[i]=iMAOnArray(buf3,Bars,Periods2,0,MODE_SMA,i);
for(i=0;i<limit-1;i++){
buf4[i]=buf1[i];
if(buf1[i] < buf1[i+1])
buf4[i] = EMPTY_VALUE;
buf5[i]=buf1[i];
if(buf1[i] > buf1[i+1])
buf5[i] = EMPTY_VALUE;
}
return(0);}