下载MetaTrader 5

编了一个货币强弱指标 运行的时候只出现一个货币对的数据,请版主和各位高手给看看指正修改,谢谢!

要添加评论,请登录注册
您既不出售信号也不出售apps?没问题,每个人都可以获利
liuxiaodong
282
liuxiaodong 2007.11.26 11:06 
//+------------------------------------------------------------------+
//|                                                  Custom MACD.mq4 |
//|                      Copyright ?2004, MetaQuotes Software Corp. |
//|                                       [url]http://www.metaquotes.net/[/url] |
//+------------------------------------------------------------------+
#property  copyright "Copyright ?2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 7
#property  indicator_color1  Blue
#property  indicator_color2  Yellow
#property  indicator_color3  Red
#property  indicator_color4  Green
#property  indicator_color5  DarkOrchid
#property  indicator_color6  PaleGreen
#property  indicator_color7  Magenta
//int indicator_color3;
#define EURUSD 0
#define GBPUSD 1
#define AUDUSD 2
#define USDJPY 3
#define USDCHF 4
#define USDCAD 5
#define EURJPY 6
#define EURGBP 7
#define EURCHF 8
#define EURAUD 9
#define GBPJPY 10
#define GBPCHF 11
 
#define USD 0
#define EUR 1
#define GBP 2
#define CHF 3
#define CAD 4
#define AUD 5
#define JPY 6
//---- indicator parameters
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
//---- indicator buffers
double     ind_buffer1[];
double     ind_buffer2[];
double     ind_buffer3[];
double     ind_buffer4[];
double     ind_buffer5[];
double     ind_buffer6[];
double     ind_buffer7[];
double     temp;
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,1);
   SetIndexStyle(6,DRAW_LINE,STYLE_SOLID,1);
   SetIndexDrawBegin(1,SignalSMA);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- indicator buffers mapping
   if(!SetIndexBuffer(0,ind_buffer1) && !SetIndexBuffer(1,ind_buffer2)&& !SetIndexBuffer(2,ind_buffer3)&& !SetIndexBuffer(3,ind_buffer4)&& !SetIndexBuffer(4,ind_buffer5)&& !SetIndexBuffer(5,ind_buffer6))
      Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("-USD-7-QIANGRUO");
   SetIndexLabel(0,"EURUSD");
   SetIndexLabel(1,"GBPUSD");
   SetIndexLabel(2,"AUDUSD");
   SetIndexLabel(3,"USDJPY");
   SetIndexLabel(4,"USDCHF");
   SetIndexLabel(5,"USDCAD");
   SetIndexLabel(6,"USDX");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
   for(int i=0; i<limit; i++)
      ind_buffer1[i]=-1*(iMA(EURUSD,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(EURUSD,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i));
      ind_buffer2[i]=-1*(iMA(GBPUSD,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(GBPUSD,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i));
      ind_buffer3[i]=-1*(iMA(AUDUSD,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(AUDUSD,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i));
      ind_buffer4[i]=iMA(USDJPY,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(USDJPY,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
      ind_buffer5[i]=iMA(USDCHF,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(USDCHF,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
      ind_buffer6[i]=iMA(USDCAD,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(USDCAD,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
      ind_buffer7[i]=(ind_buffer1[i]+ind_buffer2[i]+ind_buffer3[i]+ind_buffer4[i]+ind_buffer5[i]+ind_buffer6[i])/6;
//---- signal line counted in the 2-nd buffer  
//---- done
   return(0);
  }
liuxiaodong
282
liuxiaodong 2007.11.27 05:54  

请 rosh 给看看 谢谢了

okwh
1631
okwh 2007.11.27 08:20  

可能是坐标问题,1.4的欧元如何和110的日元在同一坐标系下绘制?

MT可能要求8 个数组的数组在近似的范围,以便绘制

Rashid Umarov
管理员
11928
Rashid Umarov 2007.11.27 09:25  
Whera are the fuctions SetIndexBuffer()?


  SetIndexBuffer(0,ind_buffer1);
  SetIndexBuffer(1,ind_buffer2);
  SetIndexBuffer(2,ind_buffer3);
  SetIndexBuffer(3,ind_buffer4);
  SetIndexBuffer(4,ind_buffer5);
  SetIndexBuffer(5,ind_buffer6);
  SetIndexBuffer(6,ind_buffer7);
liuxiaodong
282
liuxiaodong 2007.11.27 15:44  

Dxdcn 数据不一致的问题解决了 在usdjpy 的数据后处以200

ind_buffer4[i]=(iMA(USDJPY,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(USDJPY,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i))/200;

rosh
Whera are the fuctions SetIndexBuffer()?
上面的我加上了。

我这个指标是从macd摘抄的 具体看看如何在一个分离窗口下实现多种货币对的数据显示 谢谢!


其实思路很简单 就是把几个不同货币对的macd放到一个分离的窗口下,本人这个是美元的,为和美元走势配合,EUR/USD;GBP/USD;AUD/USD 这三个指标做了翻转 一共六个货币对 第七个指标是六个货币对指标加起来(没考虑权重比例)这样就可以通过观察几种货币对美元的走势判断趋势。

现在问题是显示的时候只能显示打开指标之后的数据,而且不全 最后一个加起来的美元指数无法显示 请教高手 指点

谢谢!!!!!!

但是还是有问题 !

请看图片 以前的不能显示!

liuxiaodong
282
liuxiaodong 2007.11.27 15:54  

我把修改以后的指标发上去 请ROCH 和Dxdcn 看看

基本能用了 要是没计算上的错误应该分析各种货币走势是比较准确的。呵呵

附加的文件:
liuxiaodong
282
liuxiaodong 2007.11.27 15:56  

请ROCH 和Dxdcn 看看

以前的数据如何显示

再就是 美元的数据我是各个货币对值简单加起来计算的 是不是用美元指数更科学 或者是用各个对美元的货币对的不同权重进行加权计算

谢谢啦 !

Rashid Umarov
管理员
11928
Rashid Umarov 2007.11.27 15:58  
If you want to get various data from other Symbols and/or time ftames you must to have the historical quotes on these Symbils/Timerames. Download needed rates on each Symbol (EURUSD, GBPUSD, AUDUSD etc.). Open the chart witn each Symbol to obtain these historical rates. Then you can close opened charts.
liuxiaodong
282
liuxiaodong 2007.11.27 16:44  

ROSH

每次启动都是能显示以后的数据,以前的无法显示,能不能换一种思路,把几个不同货币对的macd放到一个大的界面下,省的我这样调来调去。

这样

主界面

1 EURUSD 的macd

2GBPUSD 的macd

3AUDUSD 的macd

4 USDJPY的macd

5USDCHF 的macd

6 USDCAD 的macd

能不能实现 如何实现 请指教!

谢谢!

Rashid Umarov
管理员
11928
Rashid Umarov 2007.11.27 17:58  
Where are the brakets in for loop?
附加的文件:
liuxiaodong
282
liuxiaodong 2007.11.27 19:11  

Rosh

非常感谢!

thank you very much!

也对Dxdcn表示掌心的感谢!

顺利 平安

12
要添加评论,请登录注册