下载MetaTrader 5
要添加评论,请登录注册
有问题询问应用程序开发者吗? - 在注释里提问
helan
6
helan 2010.03.13 03:57 

请老大版主或者高手帮帮忙,改一下


请版主和各位老大帮帮忙,下面这个公式导入MT4 ,图表显示不出来,不知道公式哪里有错误,请帮忙修改一下,多谢了!!!






//+-------------------------------------------------------------------+
//| ATR STOP .mq4 |
//| copyright ?2010, MetaQuotes Software Corp. |
//| http: www.metaquotes.net |
//+-------------------------------------------------------------------+
#property copyright "Copyright ?2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//----
extern int ATR = 20;
extern int Coeficient = 2;
//----
double Up[], Dn[];
string MODE;
bool first;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0, Up);
SetIndexStyle (0, DRAW_LINE, 0, 2);
SetIndexEmptyValue(0, 0.0);
SetIndexLabel (0, "Up");
//----
SetIndexBuffer(1, Dn);
SetIndexStyle (1, DRAW_LINE, 0, 2);
SetIndexEmptyValue(1, 0.0);
SetIndexLabel (1, "Dn");
//----
first=true;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
first = true;
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i, limit;
double REZ, md;
limit = Bars - ATR - 1;
//----
if(first)
{
md = 0;
for(i = 0; i < limit; i++)
md += iATR(NULL, 0, ATR, i);
REZ = Coeficient*iATR(NULL, 0, ATR, limit);
if(iATR(NULL, 0, ATR, limit) < md / limit)
{
Up[limit+1] = Low[limit+1] - REZ;
MODE = "UP";
}
if(iATR(NULL, 0, ATR, limit) > md / limit)
{
Dn[limit+1] = High[limit+1] + REZ;
MODE = "DN";
}
first = false;
}
//----
for(i = limit - 1; i >= 0; i--)
{
Dn = 0;
Up = 0;
REZ = Coeficient*iATR(NULL, 0, ATR, i);
//----
if(MODE == "DN" && Low[i+1] > Dn[i+1])
{
Up[i+1] = Low[i+1] - REZ;
MODE = "UP";
}
//----
if(MODE == "UP" && High[i+1] < Up[i+1])
{
Dn[i+1] = High[i+1] + REZ;
MODE = "DN";
}
//----
if(MODE=="UP")
{
if(Low[i+1] > Up[i+1] + REZ)
{
Up = Low[i+1] - REZ;
Dn = 0;
}
else
{
Up = Up[i+1];
Dn = 0;
}
}
//----
if(MODE=="DN")
{
if(High[i+1] < Dn[i+1] - REZ)
{
Dn = High[i+1] + REZ;
Up = 0;
}
else
{
Dn = Dn[i+1];
Up = 0;
}
}
}
return(0);
}
//+------------------------------------------------------------------+
trad
44
trad 2010.03.14 05:52  
你检查一下代码,有编译错误。
Dn = 0;
Up = 0;
这类的语句是不对的,数组清零不能这么干。
应该这么写:
for(i=0; i<limit; i++)
{
     Up[i] = EMPTY_VALUE;
     Dn[i] = EMPTY_VALUE;
}
/
要添加评论,请登录注册