myeatrade

社区

求解版主,为什么指标只显示了一年的柱线图??

hsj37 hsj37 2013-01-14 14:55
我有一个常用的双线MACD,但是MT4安装了十年数据后,其他指标都正常,就这个指标显示只有一年的数据,前面都是空白的,该如何使它能正常显示十年数据呢,大家帮帮我
如图
QQ截图20130114145415.png



双线MACD指标公式如下
代码: 全选

//+------------------------------------------------------------------+
//| MAPOD System |
//| http://www.alxus.com/|
//+------------------------------------------------------------------+
#property copyright "MAPOD System 1.0 Copyright 2006~"
#property link "http://www.alxus.com/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Green
#property indicator_color2 White //Black
#property indicator_color3 Red
#property indicator_color4 Coral


#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 2
#property indicator_width4 2

#property indicator_level1 45
#property indicator_level2 30
#property indicator_level3 15
#property indicator_level4 -15
#property indicator_level5 -30
#property indicator_level6 -45
#property indicator_levelcolor CLR_NONE
#property indicator_levelwidth 1
#property indicator_levelstyle STYLE_SOLID //STYLE_DOT

//---- indicator parameters
extern int TimeFrame=0;
extern int FastEMA=12; //5; //12;
extern int SlowEMA=26; //34; //26;
extern int SignalSMA=9; //5; ///9;

int StartBarsCounts=5000;
int EndBarsCounts=0;
int EnableAlerts=0;


//---- indicator buffers
double ind_buffer1[];
double ind_buffer2[];
double ind_buffer3[];
double ind_buffer4[];

double alpha = 0;
double alpha_1 = 0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{

IndicatorBuffers(4);

SetIndexBuffer(0,ind_buffer1);
SetIndexBuffer(1,ind_buffer2);
SetIndexBuffer(2,ind_buffer3);
SetIndexBuffer(3,ind_buffer4);

//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexStyle(3,DRAW_HISTOGRAM);

//---- name for DataWindow and indicator subwindow label
switch(TimeFrame)
{
case 1 : string TimeFrameStr="Period_M1"; break;
case 5 : TimeFrameStr="Period_M5"; break;
case 15 : TimeFrameStr="Period_M15"; break;
case 30 : TimeFrameStr="Period_M30"; break;
case 60 : TimeFrameStr="Period_H1"; break;
case 240 : TimeFrameStr="Period_H4"; break;
case 1440 : TimeFrameStr="Period_D1"; break;
case 10080 : TimeFrameStr="Period_W1"; break;
case 43200 : TimeFrameStr="Period_MN1"; break;
default : TimeFrameStr="Current Timeframe";
}
IndicatorShortName("M");//ACD("+FastEMA+","+SlowEMA+","+SignalSMA+","+TimeFrame+")");
SetIndexLabel(0,"DIFF"); //OsMA
SetIndexLabel(1,"DEA");
SetIndexLabel(2,"MACD"); //MACD
//SetIndexLabel(3,"3"); //Signal

IndicatorDigits(Digits+2);

//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence |
//+------------------------------------------------------------------+
int start()
{
datetime TimeArray[];
int trend_direction=0; //1为升,2为降,0不明
int i=0,y=0;
if(Bars<=0) return(0); //没有柱则退出
if(StartBarsCounts>Bars) StartBarsCounts=Bars;
i=StartBarsCounts; //Bars-counted_bars;

ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);

for(i=EndBarsCounts,y=0;i<StartBarsCounts;i++)
{
if (Time<TimeArray[y]) y++;

ind_buffer3=iOsMA(NULL,TimeFrame,FastEMA,SlowEMA,SignalSMA,PRICE_TYPICAL,y)*3;
ind_buffer4=0;//iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);

ind_buffer1 = iMACD(NULL, TimeFrame, FastEMA, SlowEMA, SignalSMA, PRICE_TYPICAL, 0, y); //main
ind_buffer2 = iMACD(NULL, TimeFrame, FastEMA, SlowEMA, SignalSMA, PRICE_TYPICAL, 1, y); //sig
if(ind_buffer1>ind_buffer2) //买多
{
ind_buffer3=ind_buffer3;
}
else if(ind_buffer1<ind_buffer2) //卖空
{
ind_buffer4=ind_buffer3;
}

//Comment(MarketInfo(Symbol(),MODE_BID)," ; ",MarketInfo(Symbol(),MODE_ASK));
//MODE_BID<MODE_ASK

}


//---- done
return(0);
}
附件: QQ截图20130114145415.png


myeatrade myeatrade 2013-01-15 00:37
找到如下代码
代码: 全选

int StartBarsCounts=5000;


后面的数字5000代表只计算5000个K线的指标数值,修改这个数字就可以了
Page 1 of 1 1

请登录后发表回复,如果你还没有账户你可以 免费注册

回到 交易系统 & 指标
menu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loadermenu image pre-loader