//---- indicator line SetIndexStyle(0,DRAW_LINE); //---- //---- name for DataWindow and indicator subwindow label // short_name="RSI("+IntegerToString(RSIPeriod)+")"; short_name="RSI("+RSIPeriod+")"; IndicatorShortName(short_name); SetIndexLabel(0,short_name);
return(0); } //+------------------------------------------------------------------+ //| Relative Strength Index | //+------------------------------------------------------------------+ int start() { int i,counted_bars=IndicatorCounted(); double rel,negative,positive,sma,x,y,Pos,Neg; //---- if(Bars<=RSIPeriod) return(0); if(TF!=0) { string name=WindowExpertName(); for(i=0; i<Bars-counted_bars+1; i++) { int barIndex=iBarShift(NULL,TF,Time[i],false); MABuffer[i]=iCustom(Symbol(),TF,name,RSIPeriod,Levl,0,0,barIndex); } return(0); }
我正在努力弄清它的意义。所以在你看来,正确的选项是SVA_03,对吗?
是的,我想是的。但_02肯定是错的。
嗯......发现自己有一个错误,现在几乎没有差异了,这里是原文
//| SVA_04.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
//---- input parameters
extern int RSIPeriod=14;
extern int Levl=50;
extern int TF=0;
//---- buffers
double MABuffer[];
double PosBuffer[];
double NegBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
IndicatorBuffers(1);
SetIndexBuffer(0,MABuffer);
SetIndexBuffer(1,PosBuffer);
SetIndexBuffer(2,NegBuffer);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
//----
//---- name for DataWindow and indicator subwindow label
// short_name="RSI("+IntegerToString(RSIPeriod)+")";
short_name="RSI("+RSIPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
SetIndexLabel(1,"U");
SetIndexLabel(2,"D");
return(0);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
double rel,negative,positive,sma,x,y,Pos,Neg;
//----
if(Bars<=RSIPeriod) return(0);
if(TF!=0)
{
string name=WindowExpertName();
for(i=0; i<Bars-counted_bars+1; i++)
{
int barIndex=iBarShift(NULL,TF,Time[i],false);
MABuffer[i]=iCustom(Symbol(),TF,name,RSIPeriod,Levl,0,0,barIndex);
}
return(0);
}
i=Bars-RSIPeriod-1;
if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
double sumn=0.0,sump=0.0;
if(i==Bars-RSIPeriod-1)
{
int k=Bars-2;
//---- initial accumulation
while(k>=i)
{
rel=Close[k]-Close[k+1];
if(rel>0) sump+=rel;
else sumn-=rel;
k--;
}
positive=sump/RSIPeriod;
negative=sumn/RSIPeriod;
}
else
{
//---- smoothed moving average
rel=Close[i]-Close[i+1];
if(rel>0) sump=rel;
else sumn=-rel;
positive=(PosBuffer[i+1]*(RSIPeriod-1)+sump)/RSIPeriod;
negative=(NegBuffer[i+1]*(RSIPeriod-1)+sumn)/RSIPeriod;
}
PosBuffer[i]=positive;
NegBuffer[i]=negative;
i--;
}
i=Bars-RSIPeriod-1;
if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
x=PosBuffer[i+1];
y=NegBuffer[i+1];
if(x>0)sma=Close[i+1]+x;
else sma=Close[i+1]-y;
MABuffer[i]=sma;
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
这是SVA_03的更正版本
//| SVA_03.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property strict
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- input parameters
extern int RSIPeriod=14;
extern int Levl=50;
extern int TF=0;
//---- buffers
double MABuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
IndicatorBuffers(1);
SetIndexBuffer(0,MABuffer);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
//----
//---- name for DataWindow and indicator subwindow label
// short_name="RSI("+IntegerToString(RSIPeriod)+")";
short_name="RSI("+RSIPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
return(0);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
double rel,negative,positive,sma,x,y,Pos,Neg;
//----
if(Bars<=RSIPeriod) return(0);
if(TF!=0)
{
string name=WindowExpertName();
for(i=0; i<Bars-counted_bars+1; i++)
{
int barIndex=iBarShift(NULL,TF,Time[i],false);
MABuffer[i]=iCustom(Symbol(),TF,name,RSIPeriod,Levl,0,0,barIndex);
}
return(0);
}
i=Bars-RSIPeriod-1;
if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
double sumn=0.0,sump=0.0;
if(i==Bars-RSIPeriod-1)
{
int k=Bars-2;
//---- initial accumulation
while(k>=i)
{
rel=Close[k]-Close[k+1];
if(rel>0) sump+=rel;
else sumn-=rel;
k--;
}
positive=sump/RSIPeriod;
negative=sumn/RSIPeriod;
}
else
{
//---- smoothed moving average
rel=Close[i]-Close[i+1];
if(rel>0) sump=rel;
else sumn=-rel;
positive=(Pos*(RSIPeriod-1)+sump)/RSIPeriod;
negative=(Neg*(RSIPeriod-1)+sumn)/RSIPeriod;
}
x=Pos;
y=Neg;
Pos=positive;
Neg=negative;
if(x>0)sma=Close[i+1]+x;
else sma=Close[i+1]-y;
MABuffer[i]=sma;
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
替换了
y=negative;
到 。
y=Neg;
下午好!
帮助!我需要代码来打开一个挂单。在订单打开后的20分钟内,如果没有关闭,它将改变SL为50点。谢谢你!
下午好
请帮助解决一个非常简单(可能)的问题。有一个标准的功能。
const void &"是什么意思,如何使用它??即使是简单地尝试写一个类似的函数,也会导致编译错误。
return ArraySize(array);
}
编译错误:'const' - 非法使用'void'类型
我 在写自己的代码时,如何正确使用 "const void &"?这到底能不能做到?
下午好
请帮助解决一个非常简单(可能)的问题。有一个标准的功能。
const void &"是什么意思,如何使用它??即使是简单地尝试写一个类似的函数,也会导致编译错误。
return ArraySize(array);
}
编译错误:'const' - 非法使用'void'类型
我 在写自己的代码时,如何正确使用 "const void &"?或者说,它到底能不能用?
用应该存储数组的数据类型代替void。标准功能被设计成一个模板。
事实上,这个系统函数是一个重载函数,这种重载的整个实现对MQL4开发者来说是隐藏的。
intArraySize(
void&array[]// 要检查的阵列
)。
MQL4编译器实际上为这个函数的每次调用替换了一个需要的实现,例如,对于像这样的整数类型的数组来说
intArraySize(
int&array[]// 含有int类型元素的数组
)。
而对于一个用于处理历史数据格式的报价的MqlRates类型的数组,ArraySize()函数可以表示如下
intArraySize(
MqlRates&array[]//数组中充满了MqlRates类型的值
);
下午好!
帮助!我需要代码来打开一个挂单。在订单打开后的20分钟内,如果没有关闭,它将改变SL为50点。谢谢你!
用应该存储数组的数据类型代替void。标准功能被设计成一个模板。
事实上,这个系统函数是一个重载函数,这种重载的整个实现对MQL4中的程序开发人员是隐藏的。
我的理解是否正确,在MQL4/MQL5中,"const void &"结构- 实际上是引用的符号化符号,实际上不能写在自己的函数中?
预先感谢
我的理解是否正确,在MQL4/MQL5中,"const void &"结构- 实际上是参考书上的一个符号符号,实际上不能用于自己的函数中?
预先谢谢你