求教数组循环

 
#property copyright "Copyright "
#property link "XUE"
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots 4

extern int n1=10;
extern int n2=60;
extern int aa=0;

double ma1Buffer[];
double ma2Buffer[];
double upBuffer[];
double downBuffer[];
//double macdBuffer[];
int OnInit()
{
SetIndexBuffer(0,ma1Buffer);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,clrWhite);
SetIndexLabel(0,"ma1");
SetIndexBuffer(1,ma2Buffer);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2,clrRed);
SetIndexLabel(1,"ma2");
SetIndexBuffer(2,upBuffer);
SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID,3,clrMagenta);
SetIndexLabel(2,"up");
SetIndexArrow(2,225);
SetIndexBuffer(3,downBuffer);
SetIndexStyle(3,DRAW_ARROW,STYLE_SOLID,3,clrYellow);
SetIndexLabel(3,"down");
SetIndexArrow(3,226);
return(INIT_SUCCEEDED);
}
void deinit()
{
ObjectsDeleteAll();
}
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
int i,limit;
if(rates_total<n1 || rates_total<n2)
{
return(0);
}

limit=rates_total-prev_calculated;
if(prev_calculated>0) limit++;
for(i=0;i<limit;i++)
{
double xiao1=iMA(NULL,0,n1,0,MODE_SMA,PRICE_CLOSE,i);
double xiao2=iMA(NULL,0,n1,0,MODE_SMA,PRICE_CLOSE,i+1);
double da1=iMA(NULL,0,n2,0,MODE_SMA,PRICE_CLOSE,i);
double da2=iMA(NULL,0,n2,0,MODE_SMA,PRICE_CLOSE,i+1);
ma1Buffer[i]=xiao1;
ma2Buffer[i]=da1;
bool condition 1;
Condition 1=xiao1>da1 && xiao2<da2;//Golden Cha condition
double s[];
int p=0;
if(condition 1==true)
{
printf("Each time the distance meets the condition"+i);//Print the number of k-lines each time the condition meets to the present
s[p]=i;//
printf(s[p]); //Cannot print
}
}
return(rates_total);

}

问题:求条件成立到现在的K线数量,想实现第p次成立到现在的K先数量,但把符合条件的序号赋值给数组,但始终打印不出来。求教!

 
写法有问题
 
Wen Tao Xiong:
写法有问题

求教下,该怎么写。谢谢!

原因: