希望实现的是,当价格在18日均线上方且macd>0时,18日均线为红色,如果不加入MACD条件均线可以实现红绿变色,但是加入MACD条件后均线全为绿色,
以下是我的指标,望高手指点,哪里出了错误?谢谢
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
extern int 变色均线=18;
double duo[];
double kong[];
double macd11[];
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=0; 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)&&macd11<i>>0)
{duo<i>=temp0; duo[i+1]=temp1;}
else {kong<i>=temp0; kong[i+1]=temp1;}
}
return(0);
}[/td][/tr] |