诚信为本
量力而为
当前位置:首页MetaTrader 4MT4指标日线开盘及支撑阻力 DOSR.mq4

日线开盘及支撑阻力 DOSR.mq4

DOSR 指标绘制日线开盘及支撑阻力线。

图表:DOSR 指标

源码:

//+------------------------------------------------------------------+
//|                                                         DOSR.mq4 |
//|                                              Developed by mqldev |
//+------------------------------------------------------------------+
#property copyright "Developed by mqldev"
#property link      "http://www.125808047.com"

#property indicator_chart_window

extern color   ResistanceColor = Red;
extern color   SupportColor    = Blue;
extern color   TodayOpenColor  = Yellow;

int OnInit(void)
{
   DelObjs();
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
   DelObjs();
}

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[])
  {
   double c = iClose(NULL,PERIOD_D1,1);
   double o = iOpen(NULL,PERIOD_D1,1);
   double h = iHigh(NULL,PERIOD_D1,1);
   double l = iLow(NULL,PERIOD_D1,1);
   double to = iOpen(NULL,PERIOD_D1,0);
   
   Print("close:",c," open:",o," high:",h," low:",l);
   if (c>=o)
   {
      DrawLine(h,"Resistance",ResistanceColor);
      DrawLine(o,"Support",SupportColor);
   }
   else
   {
      DrawLine(o,"Resistance",ResistanceColor);
      DrawLine(l,"Support",SupportColor);
   }
      DrawLine(to,"Today Open",TodayOpenColor);
return(rates_total);
}

int DrawLine(double price  , string Obj , color clr)
{

   int objs = ObjectsTotal();
   string name;
   for(int cnt=ObjectsTotal()-1;cnt>=0;cnt--)
   {
      name=ObjectName(cnt);
      if (StringFind(name,Obj,0)>-1) 
      {
         ObjectMove(Obj,0,Time[0],price);
         ObjectsRedraw();
         return(1);
      }
   }
   ObjectCreate(Obj,OBJ_HLINE,0,0,price);
   ObjectSet(Obj,OBJPROP_COLOR,clr);
   WindowRedraw();
   return(0);
}

void DelObjs()
{
   int objs = ObjectsTotal();
   string name;
   for(int cnt=ObjectsTotal()-1;cnt>=0;cnt--)
   {
      name=ObjectName(cnt);
      if (StringFind(name,"L",0)>-1) ObjectDelete(name);
      WindowRedraw();
   }
}
版权所有转载请注明标题及链接:峰汇在线 » 日线开盘及支撑阻力 DOSR.mq4
上一篇:
下一篇:
分享到: 更多 (0)