#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
extern int 变色均线=18;
double duo[];
double kong[];
int init()
{
SetIndexBuffer(0,duo);
SetIndexBuffer(1,kong);
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexDrawBegin(0,变色均线);
SetIndexDrawBegin(1,变色均线);
IndicatorDigits(Digits);
return(0);
}
int start()
{
double temp0,temp1;
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars0) counted_bars--;
limit=Bars-counted_bars;
for(int i=limit; i>=0; i--)
{
duo<i>=EMPTY_VALUE;
kong<i>=EMPTY_VALUE;
temp0=iMA(NULL,0,变色均线,0,MODE_SMA,PRICE_CLOSE,i);
temp1=iMA(NULL,0,变色均线,0,MODE_SMA,PRICE_CLOSE,i+1);
if(iClose(NULL,0,i)>=iMA(NULL,0,变色均线,0,MODE_SMA,PRICE_CLOSE,i))
{duo<i>=temp0; duo[i+1]=temp1;}
else {kong<i>=temp0; kong[i+1]=temp1;}
}
return(0);
}[/td][/tr] |