MTF Candles

楼主  收藏   举报   帖子创建时间:  2019-05-05 05:15 回复:0 关注量:954
mtf-candles-forex.png

  1. //+------------------------------------------------------------------+
  2. //|                                                 #MTF Candles.mq4 |
  3. //|                                      Copyright ?2006, Eli Hayun |
  4. //|                                          http://www.elihayun.com |
  5. //+------------------------------------------------------------------+
  6. #property copyright "Copyright ?2006, Eli Hayun"
  7. #property link      "http://www.elihayun.com"

  8. #property indicator_chart_window
  9. //---- input parameters
  10. extern int       CandlesTF=240;
  11. extern color     UpCandleColor = LightBlue;
  12. extern color     DownCandleColor = Red;
  13. //+------------------------------------------------------------------+
  14. //| Custom indicator initialization function                         |
  15. //+------------------------------------------------------------------+
  16. int init()
  17.   {
  18. //---- indicators
  19. //----
  20.    return(0);
  21.   }
  22. //+------------------------------------------------------------------+
  23. //| Custom indicator deinitialization function                       |
  24. //+------------------------------------------------------------------+
  25. int deinit()
  26.   {
  27. //----
  28.    
  29. //----
  30.    return(0);
  31.   }
  32. //+------------------------------------------------------------------+
  33. //| Custom indicator iteration function                              |
  34. //+------------------------------------------------------------------+
  35. int start()
  36.   {
  37.    int    counted_bars=IndicatorCounted();
  38. //----
  39.    double dif = MathAbs(Time[1] - Time[2]);
  40.    
  41.    int ix = 0;
  42.    datetime dtStart = dif * 8 + Time[0];
  43.    for (int ii=0; ii<8; ii+=2)
  44.    {
  45.       ObjectDelete("rect"+ii); ObjectDelete("OTrnd"+ii); ObjectDelete("CTrnd"+ii);
  46.       ObjectCreate("rect"+ii,OBJ_TREND, 0, dtStart, iLow(NULL, CandlesTF,ix), dtStart, iHigh(NULL,CandlesTF,ix));
  47.       color clr = DownCandleColor; if (iOpen(NULL, CandlesTF,ix) < iClose(NULL, CandlesTF,ix)) clr = UpCandleColor;
  48.       ObjectSet("rect"+ii, OBJPROP_COLOR, clr);
  49.        ObjectSet("rect"+ii, OBJPROP_WIDTH, 3);
  50.       
  51.       ObjectSet("rect"+ii, OBJPROP_RAY, False);
  52.       
  53.      
  54.       ObjectCreate("OTrnd"+ii, OBJ_TREND, 0, dtStart, iOpen(NULL, CandlesTF,ix), dtStart-dif, iOpen(NULL,CandlesTF,ix));
  55.        ObjectSet("OTrnd"+ii, OBJPROP_WIDTH, 2);
  56.       ObjectSet("OTrnd"+ii, OBJPROP_RAY, False);
  57.       
  58.       ObjectSet("CTrnd"+ii, OBJPROP_WIDTH, 2);  
  59.       ObjectCreate("CTrnd"+ii, OBJ_TREND, 0, dtStart, iClose(NULL, CandlesTF,ix), dtStart+dif, iClose(NULL,CandlesTF,ix));
  60.       ObjectSet("CTrnd"+ii, OBJPROP_WIDTH, 2);  
  61.       ObjectSet("CTrnd"+ii, OBJPROP_RAY, False);
  62.       
  63.       dtStart -= dif * 2;
  64.       ix++;
  65.     }
  66.    
  67. //----
  68.    return(0);
  69.   }
  70. //+------------------------------------------------------------------+
打赏