[MT4指标]请高手将ADX指标中虚线手工改为实线后不能保持的错误纠正过来
请高手将ADX指标中虚线手工改为实线后,再次打开时还是虚线的错误纠正过来,谢谢!
//+------------------------------------------------------------------+
//| ADX_coloured.mq4 |
//| Piotr Lisowski |
//| [email protected] |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 LightSeaGreen // neutral
#property indicator_color2 YellowGreen
#property indicator_color3 Wheat
#property indicator_color4 Lime /// UP
#property indicator_color5 Red // DOWN
//---- input parameters
extern int ADXPeriod=14;
extern int colour_level=20;
//---- buffers
double ADXBuffer;
double ADXUpBuffer;
double ADXDownBuffer;
double PlusDiBuffer;
double MinusDiBuffer;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 3 additional buffers are used for counting.
IndicatorBuffers(5);
//---- indicator buffers
SetIndexBuffer(0,ADXBuffer);
SetIndexBuffer(1,PlusDiBuffer);
SetIndexBuffer(2,MinusDiBuffer);
SetIndexBuffer(3,ADXUpBuffer);
SetIndexBuffer(4,ADXDownBuffer);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("ADX("+ADXPeriod+")");
SetIndexLabel(0,"ADX");
SetIndexLabel(1,"+DI");
SetIndexLabel(2,"-DI");
SetIndexLabel(3,"ADXUp");
SetIndexLabel(4,"ADXDown");
//----
SetIndexDrawBegin(0,ADXPeriod);
SetIndexDrawBegin(1,ADXPeriod);
SetIndexDrawBegin(2,ADXPeriod);
SetIndexDrawBegin(3,ADXPeriod);
SetIndexDrawBegin(4,ADXPeriod);
SetIndexStyle(1, DRAW_LINE, STYLE_DOT);
SetIndexStyle(2, DRAW_LINE, STYLE_DOT);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Average Directional Movement Index |
//+------------------------------------------------------------------+
int start()
{
//----
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars<0) counted_bars=0;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
double adx_0,adx_1,dmip_0,dmip_1,dmim_0,dmim_1;
for(int i = 0 ;i < limit ;i++)
{
adx_0 = iADX(NULL,0,ADXPeriod,PRICE_CLOSE,0,i);
adx_1 = iADX(NULL,0,ADXPeriod,PRICE_CLOSE,0,i+1);
dmip_0 = iADX(NULL,0,ADXPeriod,PRICE_CLOSE,1,i);
dmip_1 = iADX(NULL,0,ADXPeriod,PRICE_CLOSE,1,i+1);
dmim_0 = iADX(NULL,0,ADXPeriod,PRICE_CLOSE,2,i);
dmim_1 = iADX(NULL,0,ADXPeriod,PRICE_CLOSE,2,i+1);
if(adx_0>adx_1&&dmip_0>dmim_0&&adx_0>=colour_level)
{//up
ADXBuffer = EMPTY_VALUE;
ADXUpBuffer = adx_0;
ADXDownBuffer = EMPTY_VALUE;
}
else if(adx_0>adx_1&&dmip_0=colour_level)
{//down
ADXBuffer = EMPTY_VALUE;
ADXUpBuffer = EMPTY_VALUE;
ADXDownBuffer = adx_0;
}
else
{
ADXBuffer = adx_0;
ADXUpBuffer = EMPTY_VALUE;
ADXDownBuffer = EMPTY_VALUE;
}
ADXBuffer = adx_0;
PlusDiBuffer = dmip_0;
MinusDiBuffer = dmim_0;
}
//----
return(0);
}
//+------------------------------------------------------------------+
[ 本帖最后由 管理员No.6 于 2006-6-26 09:35 编辑 ]虚线改为实线后.gif虚线改为实线.gif