外汇论坛 外兔财经

开启左侧

求助,请帮忙在这条均线上加上报警

[复制链接]
发表于 2008-3-4 14:26 | 显示全部楼层 |阅读模式
https://www.y2cn.com
这是一条变色均线,希望各位大哥帮忙加个k现触碰到能报警,并加个标记指示,谢谢!
  1. //+------------------------------------------------------------------+
  2. //|  MegaTrend   HMA.mq4
  3. //| Copyright ?2006 WizardSerg <wizardserg@mail.ru>, ?? ??????? ForexMagazine #104
  4. //| wizardserg@mail.ru
  5. //| Revised by IgorAD,igorad2003@yahoo.co.uk |   
  6. //|                                         
  7. //| Personalized by iGoR for the Trend Slope Trading method (T_S_T)
  8. //| Link: http://www.strategybuilderfx.com/forums/showthread.php?t=16507
  9. //| contact: igor@igor.cc                                 
  10. //+------------------------------------------------------------------+
  11. #property copyright "MT4 release WizardSerg <wizardserg@mail.ru>, ?? ??????? ForexMagazine #104"
  12. #property link      "wizardserg@mail.ru"

  13. #property indicator_chart_window
  14. #property indicator_buffers 2
  15. #property indicator_color1 Lime
  16. #property indicator_color2 Red
  17. //---- input parameters
  18. extern int       period=15;
  19. extern int       method=3;                         // MODE_SMA
  20. extern int       price=0;                          // PRICE_CLOSE
  21. //---- buffers
  22. double Uptrend[];
  23. double Dntrend[];
  24. double ExtMapBuffer[];


  25. //+------------------------------------------------------------------+
  26. //| Custom indicator initialization function                         |
  27. //+------------------------------------------------------------------+
  28. int init()
  29. {
  30.     IndicatorBuffers(3);  
  31.     SetIndexBuffer(0, Uptrend);
  32.     //ArraySetAsSeries(Uptrend, true);
  33.     SetIndexBuffer(1, Dntrend);
  34.     //ArraySetAsSeries(Dntrend, true);
  35.     SetIndexBuffer(2, ExtMapBuffer);
  36.     ArraySetAsSeries(ExtMapBuffer, true);
  37.    
  38.     SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
  39.     SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
  40.    
  41.     IndicatorShortName("MegaTrend("+period+")");
  42.     return(0);
  43. }

  44. //+------------------------------------------------------------------+
  45. //| Custor indicator deinitialization function                       |
  46. //+------------------------------------------------------------------+
  47. int deinit()
  48. {
  49.     // ???? ????? ?????? ??????
  50.     return(0);
  51. }

  52. //+------------------------------------------------------------------+
  53. //| ?????????? ???????                                               |
  54. //+------------------------------------------------------------------+
  55. double WMA(int x, int p)
  56. {
  57.     return(iMA(NULL, 0, p, 0, method, price, x));   
  58. }

  59. //+------------------------------------------------------------------+
  60. //| Custom indicator iteration function                              |
  61. //+------------------------------------------------------------------+
  62. int start()
  63. {
  64.     int counted_bars = IndicatorCounted();
  65.    
  66.     if(counted_bars < 0)
  67.         return(-1);
  68.                   
  69.     int x = 0;
  70.     int p = MathSqrt(period);              
  71.     int e = Bars - counted_bars + period + 1;
  72.    
  73.     double vect[], trend[];
  74.    
  75.     if(e > Bars)
  76.         e = Bars;   

  77.     ArrayResize(vect, e);
  78.     ArraySetAsSeries(vect, true);
  79.     ArrayResize(trend, e);
  80.     ArraySetAsSeries(trend, true);
  81.    
  82.     for(x = 0; x < e; x++)
  83.     {
  84.         vect[x] = 2*WMA(x, period/2) - WMA(x, period);        
  85. //       Print("Bar date/time: ", TimeToStr(Time[x]), " close: ", Close[x], " vect[", x, "] = ", vect[x], " 2*WMA(p/2) = ", 2*WMA(x, period/2), " WMA(p) = ",  WMA(x, period));
  86.     }

  87.     for(x = 0; x < e-period; x++)
  88.      
  89.         ExtMapBuffer[x] = iMAOnArray(vect, 0, p, 0, method, x);        
  90.    
  91.     for(x = e-period; x >= 0; x--)
  92.     {     
  93.         trend[x] = trend[x+1];
  94.         if (ExtMapBuffer[x]> ExtMapBuffer[x+1]) trend[x] =1;
  95.         if (ExtMapBuffer[x]< ExtMapBuffer[x+1]) trend[x] =-1;
  96.    
  97.     if (trend[x]>0)
  98.     { Uptrend[x] = ExtMapBuffer[x];
  99.       if (trend[x+1]<0) Uptrend[x+1]=ExtMapBuffer[x+1];
  100.       Dntrend[x] = EMPTY_VALUE;
  101.     }
  102.     else              
  103.     if (trend[x]<0)
  104.     {
  105.       Dntrend[x] = ExtMapBuffer[x];
  106.       if (trend[x+1]>0) Dntrend[x+1]=ExtMapBuffer[x+1];
  107.       Uptrend[x] = EMPTY_VALUE;
  108.     }              
  109.    
  110.     //Print( " trend=",trend[x]);
  111.     }
  112.    
  113.     return(0);
  114. }
  115. //+------------------------------------------------------------------+
复制代码
发表于 2008-8-22 07:59 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽

本版积分规则

QQ|手机版 Mobile Version|Archiver|关于我们 About Us|联系我们 Contact Us|Y2外汇论坛 外兔财经

GMT+8, 2024-5-5 08:06 , Processed in 0.040946 second(s), 23 queries .

Powered by Discuz! X7.2

Copyright © 2001-2021, Tencent Cloud.

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