帮转一程序,从MQ4到MQ5,相仿也可,要我能懂!谢谢!!! 新评论 [删除] 2010.08.11 14:58 意思为显示指定周期的RSI指标,谢谢!可限制限制K线根数 #property copyright "Copyright ?2004, MetaQuotes Software Corp." #property link "https://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); } //+------------------------------------------------------------------+ 新人对MQL4和MQL5的任何问题,对算法和代码的帮助和讨论 如何编码? 求教,高手进来看一下 [删除] 2010.08.11 15:00 #1 要能在MQ5里运行 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
意思为显示指定周期的RSI指标,谢谢!可限制限制K线根数
#property copyright "Copyright ?2004, MetaQuotes Software Corp."
#property link "https://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);
}
//+------------------------------------------------------------------+