分享一个指标--MA_Shade

0
回复
10520
查看
[复制链接]

209

主题

26

回帖

1424

积分

超级版主

积分
1424
来源: 2022-6-2 15:38:21 显示全部楼层 |阅读模式
  1. //+------------------------------------------------------------------+
  2. //|                                                     MA_Shade.mq4 |
  3. //|                                                         quant001 |
  4. //|                                               www.geekquant.com  |
  5. //+------------------------------------------------------------------+
  6. #property copyright "www.geekquant.com"
  7. #property link      "www.geekquant.com"
  8. #property indicator_chart_window
  9. #property indicator_buffers 2
  10. #property indicator_color1 DarkGreen
  11. #property indicator_color2 FireBrick
  12. #property indicator_width1 3
  13. #property indicator_width2 3

  14. extern int MA1_Period=25;
  15. extern int MA2_Period=100;
  16. extern string MA_Method_Help="0-SMA, 1-EMA, 2-SMMA, 3-LWMA";
  17. extern int MA_Method=1;

  18. double MA1, MA2;
  19. double MA1_Buffer[], MA2_Buffer[];
  20. //+------------------------------------------------------------------+
  21. //| Custom indicator initialization function                         |
  22. //+------------------------------------------------------------------+
  23. int init()
  24.   {
  25.    SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_DOT);
  26.    SetIndexBuffer(0,MA1_Buffer);
  27.    
  28.    SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_DOT);
  29.    SetIndexBuffer(1,MA2_Buffer);
  30. //---- indicators
  31. //----
  32.    return(0);
  33.   }
  34. //+------------------------------------------------------------------+
  35. //| Custom indicator deinitialization function                       |
  36. //+------------------------------------------------------------------+
  37. int deinit()
  38.   {
  39. //----
  40.    
  41. //----
  42.    return(0);
  43.   }
  44. //+------------------------------------------------------------------+
  45. //| Custom indicator iteration function                              |
  46. //+------------------------------------------------------------------+
  47. int start()
  48.   {
  49.    int    counted_bars=IndicatorCounted();
  50.    
  51.    int limit=Bars-counted_bars;
  52.    if(counted_bars>0) limit++;
  53.    
  54.    for(int i=1; i<limit; i++)
  55.    {
  56.       MA1=iMA(NULL,0,MA1_Period,0,MA_Method,PRICE_CLOSE,i);
  57.       MA2=iMA(NULL,0,MA2_Period,0,MA_Method,PRICE_CLOSE,i);
  58.    
  59.       MA1_Buffer[i]=MA1;
  60.       MA2_Buffer[i]=MA2;
  61.    }
  62. //----
  63.    
  64. //----
  65.    return(0);
  66.   }
  67. //+------------------------------------------------------------------+
复制代码
0602008.png


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 免费注册
关注微信