下载MetaTrader 5
要添加评论,请登录注册
下载 MetaTrader 5并且今天就开始交易!
lflovesxx
6
lflovesxx 2010.08.11 14:58 

意思为显示指定周期的RSI指标,谢谢!可限制限制K线根数
#property copyright "Copyright ?2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern int intZhouQi=240; //显示RSI的周期
extern int RSIPeriod=14; //RSI参数
extern int intKNum=99999; //显示多少根K线内的
//---- buffers
double RSIBuffer[];
bool bolFrist = true;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- 2 additional buffers are used for counting.
IndicatorBuffers(1);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,RSIBuffer);
//---- name for DataWindow and indicator subwindow label
short_name="RSI("+RSIPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
SetIndexDrawBegin(0,RSIPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
int start()
{
int intCurrent=0, yy;
int i,counted_bars=IndicatorCounted();
datetime TimeArray_CurrentM[];
double rel;
//----
if(Bars<=RSIPeriod) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=RSIPeriod;i++) RSIBuffer[Bars-i]=0.0;
//----
i=Bars-RSIPeriod-1;
if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;

ArrayCopySeries(TimeArray_CurrentM,MODE_TIME,Symbol(),intZhouQi);
if(bolFrist==false)
{
intKNum=16;
}
for(i=0, intCurrent=0;i<intKNum;i++)
{
if (Time[i]<TimeArray_CurrentM[intCurrent]) intCurrent++;
RSIBuffer[i] = iRSI(NULL,intZhouQi,RSIPeriod,PRICE_CLOSE,intCurrent);
}

bolFrist=false;
//----
return(0);
}
//+------------------------------------------------------------------+

lflovesxx
6
lflovesxx 2010.08.11 15:00  

要能在MQ5里运行

/
要添加评论,请登录注册