诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4指标 > 正文

交易日波动标识指标 Coloured_Days_on_Chart.mq4

Coloured_Days_on_Chart指标用两种颜色的背景方块标识每个交易日的波动范围。

图表:Coloured_Days_on_Chart指标

源码:

//+------------------------------------------------------------------+
//|                                        Coloured_Days_on_Chart.mq4|
//|                    Copyright @2008, Jason Robinson (jnrtrading). |
//+------------------------------------------------------------------+
#property copyright "Copyright @2008, Jason Robinson (jnrtrading)."
#property link      "http://www.125808047.com"

#property indicator_chart_window
extern int No_of_days_to_colour = 20;
extern color Colour1 = LightGray;
extern color Colour2 = DarkGray;
double Days[][6];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
 ArrayCopyRates(Days,Symbol(),PERIOD_D1);
   Comment("www.125808047.com");
 return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
   void OnDeinit(const int reason)
  {
   for (int i = No_of_days_to_colour; i >= 0; i--) {
      ObjectDelete("Day"+i);
   }
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  { 
   for (int i = 0; i <= No_of_days_to_colour; i++) {
      ObjectCreate("Day"+i,OBJ_RECTANGLE,0,Days[i][0]+86400,Days[i][3],Days[i][0],Days[i][2]);
      if (i % 2 == 0)
         ObjectSet("Day"+i,OBJPROP_COLOR,Colour1);
      else
         ObjectSet("Day"+i,OBJPROP_COLOR,Colour2);
   }
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 交易日波动标识指标 Coloured_Days_on_Chart.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏