查看完整版本: 求助求助\~~~~

gty4466 2008-6-15 15:54

求助求助\~~~~

大家好,本人学习外汇交易不旧,最近迷上MT4编写指标,相信大家对均线交易系统了如指掌了,以前一直是用招商银行的外汇软件看盘,设置均线交易系统,最近小弟模仿别人写的均线交易系统在MT4使用,发现大致的设置参数跟之前招商的一样,但是两个软件给出的信号位置却有不同,以下是小弟写的均线系统:
//+------------------------------------------------------------------+
//|                       Copyright ?2008, [email=gty4466@126.com]gty4466@126.com[/email]
//|                          [url=http://www.alpari.cn/]http://www.alpari.cn[/url]|
//+------------------------------------------------------------------+
#property copyright "[email=gty4466@126.com]gty4466@126.com[/email]"
#property link      "[url=http://www.alpari.cn/]www.alpari.cn[/url]"
#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)
         && iMA(NULL,0,fast,0,MODE_EMA,PRICE_CLOSE,i+1)>iMA(NULL,0,slow,0,MODE_EMA,PRICE_CLOSE,i+1)
      )
   )
   {
      sell[i]=High[i]+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)<iMA(NULL,0,slow,0,MODE_EMA,PRICE_CLOSE,i+1)
      )
   )
   {
      buy[i]=Low[i]-2*Point;
      if (i==1 && LastAlertTime!=Time[0])  
      {
         Alert("Positive Cross");
         LastAlertTime=Time[0];
      }
   }

}
//----
   return(0);
  }
//+------------------------------------------------------------------+
[/i][/i][/i][/i]
[i][/i]
MT4的



[i]招商的[/i]
[i]参数都是7和63,究竟是什么地方错了,请高手指点~~~[/i]
[i][/i]
[i][i][i][i][url=http://photo.qq.com/portal/albumMain.shtml?%23uin=18397122#uin=18397122&albumid=103853224&lloc=3508c592-efda-4db7-a851-4fe2e3f7bc4f][i][/i][/url][/i][/i][/i][/i]

[[i] 本帖最后由 gty4466 于 2008-6-15 16:01 编辑 [/i]]

xfxyldj 2008-6-16 21:59

应该是均线类型不同。
招商银行默认的均线类型时SMA
你在MQL程序中用的是EMA类型。
页: [1]
查看完整版本: 求助求助\~~~~