/
#property strict
#property indicator_chart_window
extern int 连续K线数=4;//连续k线数
int mark=0,i;//报警标记
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
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[])
{
//---
//mark=0;
int 连续阴数=0,连续阳数=0;
for(i=0;i<连续K线数;i++)
{
if(iOpen(NULL,0,i)-iClose(NULL,0,i)>0) 连续阴数++;
}
for(i=0;i<连续K线数;i++)
{
if(iOpen(NULL,0,i)-iClose(NULL,0,i)<0) 连续阳数++;
}
Comment("\n",连续K线数,"根K线范围内的阴线数:",连续阴数,"根 阳线数:",连续阳数,"根");
if(连续K线数==连续阳数 && mark!=1)
{
//PlaySound("连续阳线.wav");
Alert(Symbol(),"-",Period()" 连续出现",连续阳数,"根阳线");
mark=1;
}
if(连续K线数==连续阴数 && mark!=2)
{
// PlaySound("连续阴线.wav");
Alert(Symbol(),"-",Period()" 连续出现",连续阴数,"根阴线");
mark=2;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
|