[MT4指标]请高手帮改一下指标
把移动平均Exponential改为Simple
源码如下:
//+------------------------------------------------------------------+
//| Copyright ?2005, [email protected]
//| http://man2078.home4u.china.com/|
//+------------------------------------------------------------------+
#property copyright "[email protected]"
#property link "http://man2078.home4u.china.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- buffers
double buy,sell;
extern int fast=5;
extern int slow=10;
double LastAlertTime=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,233);
SetIndexBuffer(0,buy);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,234);
SetIndexBuffer(1,sell);
SetIndexEmptyValue(1,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
for (int i=Bars-1;i>=0;i--)
{
if
(
(
iMA(NULL,0,fast,0,MODE_EMA,PRICE_CLOSE,i)iMA(NULL,0,slow,0,MODE_EMA,PRICE_CLOSE,i+1)
)
)
{
sell=High+2*Point;
if (i==1 && LastAlertTime!=Time[0])
{
Alert("Negative Cross");
LastAlertTime=Time[0];
}
}
if
(
(
iMA(NULL,0,fast,0,MODE_EMA,PRICE_CLOSE,i)>iMA(NULL,0,slow,0,MODE_EMA,PRICE_CLOSE,i)
&& iMA(NULL,0,fast,0,MODE_EMA,PRICE_CLOSE,i+1)
发表于:2011-04-15 17:09只看该作者
2楼
把文件中所有的 MODE_EMA,替换为 MODE_SMA
这样就可以了
发表于:2011-05-11 05:04只看该作者
3楼
源代码中有2个错误 sell=High+2*Point; buy=Low-2*Point; 已经修改
//+------------------------------------------------------------------+
//| 9J.mq4 |
//+------------------------------------------------------------------+
//| 505068266 |
//+------------------------------------------------------------------+
#property copyright "http:///sewenbin "
#property link "[email protected]"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- buffers
double buy,sell;
extern int fast=5;
extern int slow=10;
double LastAlertTime=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,233);
SetIndexBuffer(0,buy);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,234);
SetIndexBuffer(1,sell);
SetIndexEmptyValue(1,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
for (int i=Bars-1;i>=0;i--)
{
if
(
(
iMA(NULL,0,fast,0,MODE_EMA,PRICE_CLOSE,i)iMA(NULL,0,slow,0,MODE_EMA,PRICE_CLOSE,i+1)
)
)
{
sell=High+2*Point;
if (i==1 && LastAlertTime!=Time[0])
{
Alert("Negative Cross");
LastAlertTime=Time[0];
}
}
if
(
(
iMA(NULL,0,fast,0,MODE_EMA,PRICE_CLOSE,i)>iMA(NULL,0,slow,0,MODE_EMA,PRICE_CLOSE,i)
&& iMA(NULL,0,fast,0,MODE_EMA,PRICE_CLOSE,i+1)
韬客社区www.talkfx.co
发表于:2011-05-11 05:34只看该作者
4楼
sell=High+2*Point;
buy=Low-2*Point;
韬客社区www.talkfx.co
发表于:2011-05-11 05:37只看该作者
5楼
晕括号 不能显示 buy [ i ] = Low [ i ] - 2*Point;
韬客社区www.talkfx.co