交易危机

 找回密码
 快捷注册(禁q号)

QQ登录

只需一步,快速开始

搜索
广告位
查看: 5495|回复: 9
打印 上一主题 下一主题

[其他] MACD变色双线指标

[复制链接]

29

主题

1223

积分

1

精华

初级操盘手

金钱
1223 美元
权重
14
跳转到指定楼层
楼主
发表于 2014-3-10 16:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
MACD变色双线指标
原作者:fycat,鸣谢





  1. //+------------------------------------------------------------------+
  2. //|                                                         MACD.mq4 |
  3. //|                                Copyright ?2005, David W. Thomas |
  4. //+------------------------------------------------------------------+
  5. // This is the correct computation and display of MACD.
  6. #property copyright "Copyright ?2005, David W. Thomas"
  7. #property indicator_separate_window
  8. #property indicator_buffers 3
  9. #property indicator_color1 Blue
  10. #property indicator_color2 Red
  11. #property indicator_color3 Green
  12. //---- input parameters
  13. extern int       FastMAPeriod=12;
  14. extern int       SlowMAPeriod=26;
  15. extern int       SignalMAPeriod=9;
  16. //---- buffers
  17. double MACDLineBuffer[];
  18. double SignalLineBuffer[];
  19. double HistogramBuffer[];
  20. //---- variables
  21. double alpha = 0;
  22. double alpha_1 = 0;
  23. //+------------------------------------------------------------------+
  24. //| Custom indicator initialization function                         |
  25. //+------------------------------------------------------------------+
  26. int init()
  27. {
  28.    IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
  29.    //---- indicators
  30.    SetIndexStyle(0,DRAW_LINE);
  31.    SetIndexBuffer(0,MACDLineBuffer);
  32.    SetIndexDrawBegin(0,SlowMAPeriod);
  33.    SetIndexStyle(1,DRAW_LINE,STYLE_DOT);
  34.    SetIndexBuffer(1,SignalLineBuffer);
  35.    SetIndexDrawBegin(1,SlowMAPeriod+SignalMAPeriod);
  36.    SetIndexStyle(2,DRAW_HISTOGRAM);
  37.    SetIndexBuffer(2,HistogramBuffer);
  38.    SetIndexDrawBegin(2,SlowMAPeriod+SignalMAPeriod);
  39.    //---- name for DataWindow and indicator subwindow label
  40.    IndicatorShortName("MACD("+FastMAPeriod+","+SlowMAPeriod+","+SignalMAPeriod+")");
  41.    SetIndexLabel(0,"MACD");
  42.    SetIndexLabel(1,"Signal");
  43.    //----
  44.         alpha = 2.0 / (SignalMAPeriod + 1.0);
  45.         alpha_1 = 1.0 - alpha;
  46.    //----
  47.    return(0);
  48. }
  49. //+------------------------------------------------------------------+
  50. //| Custor indicator deinitialization function                       |
  51. //+------------------------------------------------------------------+
  52. int deinit()
  53. {
  54.    //----
  55.    
  56.    //----
  57.    return(0);
  58. }
  59. //+------------------------------------------------------------------+
  60. //| Custom indicator iteration function                              |
  61. //+------------------------------------------------------------------+
  62. int start()
  63. {
  64.    int limit;
  65.    int counted_bars = IndicatorCounted();
  66.    //---- check for possible errors
  67.    if (counted_bars<0) return(-1);
  68.    //---- last counted bar will be recounted
  69.    if (counted_bars>0) counted_bars--;
  70.    limit = Bars - counted_bars;
  71.    for(int i=limit; i>=0; i--)
  72.    {
  73.       MACDLineBuffer[i] = iMA(NULL,0,FastMAPeriod,0,MODE_EMA,PRICE_CLOSE,i) - iMA(NULL,0,SlowMAPeriod,0,MODE_EMA,PRICE_CLOSE,i);
  74.       SignalLineBuffer[i] = alpha*MACDLineBuffer[i] + alpha_1*SignalLineBuffer[i+1];
  75.       HistogramBuffer[i] = MACDLineBuffer[i] - SignalLineBuffer[i];
  76.    }
  77.    
  78.    //----
  79.    return(0);
  80. }
  81. //+------------------------------------------------------------------+
复制代码

MACD双线变色.zip

5.62 KB, 下载次数: 64, 下载积分: 金钱 -8

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 转播转播 分享分享 分享淘帖 支持支持1 保留保留

6

主题

2064

积分

0

精华

中级操盘手

金钱
2064 美元
权重
4
沙发
发表于 2014-3-24 12:19 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:51 编辑

有源码吗?

点评

不好意思,木有~  发表于 2014-3-27 19:37

2

主题

758

积分

0

精华

初级操盘手

金钱
758 美元
权重
2
板凳
发表于 2014-3-28 11:31 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:51 编辑

重装了系统真麻烦,赶紧下点指标用,谢谢楼主

4

主题

244

积分

0

精华

见习操盘手

金钱
244 美元
权重
14
地板
发表于 2014-4-5 19:27 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:51 编辑

哥,我只是简单修改下分享出来。。。。。
我不是作者


0

主题

28

积分

0

精华

外汇入门

金钱
28 美元
权重
0
5
发表于 2014-4-7 17:09 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:51 编辑

谢谢分享!

29

主题

1223

积分

1

精华

初级操盘手

金钱
1223 美元
权重
14
6
 楼主| 发表于 2014-4-8 10:10 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 12:51 编辑

哥,我只是简单修改下分享出来。。。。。
我不是作者[/quote]
{:soso_e113:}                        

0

主题

137

积分

0

精华

见习操盘手

金钱
137 美元
权重
0
7
发表于 2017-1-12 15:56 | 只看该作者
,谢谢楼主,谢谢楼主

0

主题

137

积分

0

精华

见习操盘手

金钱
137 美元
权重
0
8
发表于 2017-1-12 16:03 | 只看该作者
谢谢楼主!谢谢楼主!

2

主题

373

积分

0

精华

见习操盘手

金钱
373 美元
权重
0
9
发表于 2018-12-7 22:12 | 只看该作者
图上没见变色啊 期待有双线能随上升和下降变色的MACD
您需要登录后才可以回帖 登录 | 快捷注册(禁q号)

本版积分规则

QQ|黄金吧|黄金论坛|手机版|指标下载|非农|目录|交易危机

版权所有: ©2014-2021 fx3q.com Powered by Discuz! X3
皖ICP备: 2024050410号-2

风险提示:杠杆风险高,交易要谨慎 声明:坛友发言和回复均为个人观点,不代表论坛立场。
若有侵权请联系fx3q@qq.com删除

快速回复 返回顶部 返回列表