下载MetaTrader 5
要添加评论,请登录注册
通过您的移动电话订购程序开发并追踪其状态。
aeetes king
18
aeetes king 2008.10.13 08:01 

我直接用公式里的EMA()函数调用SMA()发现不能够自动更新且数据运算量过大,应该是全局变量和局部变量的定义有问题吧?怎么解决呢?请教各位高手

hongzhen zou
131
hongzhen zou 2008.10.15 16:51  

double ma[i]=iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, i )
double ema=iMAOnArray( ma[i], int total, int period, int ma_shift, int ma_method, int shift)

aeetes king
18
aeetes king 2008.10.15 19:57  
big_one 写道 >>

double ma[i]=iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, i )
double ema=iMAOnArray( ma[i], int total, int period, int ma_shift, int ma_method, int shift)

你有试验过吗?我做了一次不能通过,能否做成一个完整的我测试一下?谢谢:)

hongzhen zou
131
hongzhen zou 2008.10.16 02:43  

//+------------------------------------------------------------------+
//| aeetes.mq4 |
//| Copyright ?2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 MediumBlue
//---- input parameters
extern int Ext1=5;
extern int Ext2=10;
//---- buffers
double MaBuffer[];
double EmaBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,MaBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,EmaBuffer);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
if(Bars<=50) return(0);
//---- 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;

//---- ma
for(int i=0; i<limit; i++)
{
MaBuffer[i]=iMA(NULL,0,Ext1,0,MODE_EMA, PRICE_MEDIAN, i) ;
}
//---- ema
for(i=0; i<limit; i++)
{
EmaBuffer[i]=iMAOnArray(MaBuffer, 0, Ext2, 0, MODE_SMA, i);
}
//----
return(0);
}

aeetes king
18
aeetes king 2008.10.16 11:29  
big_one 写道 >>

//+------------------------------------------------------------------+
//| aeetes.mq4 |
//| Copyright ?2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 MediumBlue
//---- input parameters
extern int Ext1=5;
extern int Ext2=10;
//---- buffers
double MaBuffer[];
double EmaBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,MaBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,EmaBuffer);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
if(Bars<=50) return(0);
//---- 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;

//---- ma
for(int i=0; i<limit; i++)
{
MaBuffer[i]=iMA(NULL,0,Ext1,0,MODE_EMA, PRICE_MEDIAN, i) ;
}
//---- ema
for(i=0; i<limit; i++)
{
EmaBuffer[i]=iMAOnArray(MaBuffer, 0, Ext2, 0, MODE_SMA, i);
}
//----
return(0);
}

这个写法有问题,因为会同时出现两条线,事实上,我们只需要其中的一条,也就是EmaBuffer[i]输出的图像,另外一条则是干扰,必须去掉才行,这里是否有命令可以不输出那条线呢?

aeetes king
18
aeetes king 2008.10.16 12:23  

这个双线的问题已经解决,谢谢你。现在有个更进一步的问题,对布林带的优化。我希望布林带的上中下轨均可以通过上述类似双周期定义来优化他,在优化的过程中经常会出现不显示线条的问题,这个是什么原因呢?

附加的文件:
bands.mq4 3 kb
/
要添加评论,请登录注册