当前位置:首页 > 学习资料 > EA那些事 > 正文

指标:显示每天开盘价

2020-02-04 18:22:48

显示每天开盘价,然后画线。代码: property indicator_chart_window property indicator_buffers 1 property indicator_color1 White

显示每天开盘价,然后画线。

 

代码:

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
#property indicator_chart_window#property indicator_buffers 1#property indicator_color1 White#property indicator_style1 2#property indicator_width1 1
double TodayOpenBuffer[];extern int TimeZoneOfData= 0;//+------------------------------------------------------------------+//| Custom indicator initialization function                         |//+------------------------------------------------------------------+int init(){  SetIndexStyle(0,DRAW_LINE);  SetIndexBuffer(0,TodayOpenBuffer);  SetIndexLabel(0,"Open");  SetIndexEmptyValue(0,0.0);  return(0);}//+------------------------------------------------------------------+//| Custor indicator deinitialization function                       |//+------------------------------------------------------------------+int deinit(){   ObjectsDeleteAll(0,OBJ_TEXT);  return(0);}//+------------------------------------------------------------------+//| Custom indicator iteration function                              |//+------------------------------------------------------------------+int start(){   int lastbar;   int counted_bars= IndicatorCounted();      if (counted_bars>0) counted_bars--;   lastbar = Bars-counted_bars;     DailyOpen(0,lastbar);      return (0);}//+------------------------------------------------------------------+//|                                                                  |//+------------------------------------------------------------------+int DailyOpen(int offset, int lastbar){   int shift;   int tzdiffsec= TimeZoneOfData * 3600;   double barsper30= 1.0*PERIOD_M30/Period();   bool ShowDailyOpenLevel= True;   // lastbar+= barsperday+2;  // make sure we catch the daily open        lastbar= MathMin(Bars-20*barsper30-1, lastbar);

  for(shift=lastbar;shift>=offset;shift--){    TodayOpenBuffer[shift]= 0;     if (ShowDailyOpenLevel)     {       if(TimeDay(Time[shift]-tzdiffsec) != TimeDay(Time[shift+1]-tzdiffsec)){      // day change         TodayOpenBuffer[shift]= Open[shift];         SetText(shift, Time[shift], Open[shift] - 30.0*Point,"                                       ["+TimeToStr(Time[shift]+(6*3600),TIME_DATE)+"星期"+TimeDayOfWeek(Time[shift])+"]", clrWhite,8);            TodayOpenBuffer[shift+1]= 0;                                                           // avoid stairs in the line       }       else{         TodayOpenBuffer[shift]= TodayOpenBuffer[shift+1];       }    }   }   return(0);}

void SetText(string name, int a_datetime_4, double a_price_8, string a_text_16, color a_color_24,int font_size){   ObjectCreate(name, OBJ_TEXT, 0, a_datetime_4, a_price_8);   ObjectSetText(name, a_text_16,font_size);   ObjectSet(name, OBJPROP_COLOR, a_color_24); }

 

关键词:

上一篇: 指标:小周期显示四小时蜡烛图

下一篇: 指标:自动画趋势线

声明本站分享的文章旨在促进信息交流,不以盈利为目的,本文观点与本站立场无关,不承担任何责任。部分内容文章及图片来自互联网或自媒体,版权归属于原作者,不保证该信息(包括但不限于文字、图片、图表及数据)的准确性、真实性、完整性、有效性、及时性、原创性等,如无意侵犯媒体或个人知识产权,请来电或致函告之,本站将在第一时间处理。未经证实的信息仅供参考,不做任何投资和交易根据,据此操作风险自担。本站拥有对此声明的最终解释权。