[MT4指标]Coppock指标
附图指标,
mt4指标类型:趋势指标
是否能用在mt4手机版上:否
是否含有未来函数:无
//+------------------------------------------------------------------+
//| Coppock .mq4 |
//| Copyright ? 2007, Robert Hill |
//+------------------------------------------------------------------+
#property copyright "Copyright ? 2007, Robert Hill"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- indicator parameters
extern string strROC="ROC Period for lookback";
extern int RPeriod1=80;
extern string strType1="Moving Average Types" ;
extern string str10="0 = SMA, 1 = EMA";
extern string str11="2 = SMMA, 3 = LWMA";
extern int RMAMode1=0;
extern string sep0="----------------------------------";
extern int RPeriod2=10;
extern string strType2="Moving Average Types" ;
extern string str20="0 = SMA, 1 = EMA";
extern string str21="2 = SMMA, 3 = LWMA";
extern int RMAMode2=0;
extern string sep1="----------------------------------";
extern string strMA="MA input parameters";
extern int MAPeriod=20;
extern string strType="Moving Average Types" ;
extern string strm0="0 = SMA, 1 = EMA";
extern string strm1="2 = SMMA, 3 = LWMA";
extern int MAType=0;
extern string sep2="----------------------------------";
extern bool UsePercent=false;
//---- indicator buffers
double Coppock;
double RateOfChange1;
double RateOfChange2;
double RateOfChange3;
//---- variables
int MAMode;
string strMAType;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
IndicatorBuffers(4);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexDrawBegin(0,MAPeriod);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- indicator buffers mapping
SetIndexBuffer(0,Coppock);
SetIndexBuffer(1,RateOfChange1);
SetIndexBuffer(2,RateOfChange2);
SetIndexBuffer(3,RateOfChange3);
switch(MAType)
{
case 1: strMAType="EMA"; MAMode=MODE_EMA; break;
case 2: strMAType="SMMA"; MAMode=MODE_SMMA; break;
case 3: strMAType="LWMA"; MAMode=MODE_LWMA; break;
default: strMAType="SMA"; MAMode=MODE_SMA; break;
}
IndicatorShortName( "Coppock (" + RPeriod1 + "," + RPeriod2 + ") " + strMAType+ " (" +MAPeriod + ") ");
//---- name for DataWindow and indicator subwindow label
SetIndexLabel(0,"Coppock");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Coppock |
//+------------------------------------------------------------------+
int start()
{
int limit, i;
double MA_Cur1, MA_Prev1;
double MA_Cur2, MA_Prev2;
double ROC1, ROC2;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- ROC calculations
for( i=0; iCoppock.jpg