有您的持续关注
我们会做得更好

指标 2MA_Cross



2MA_Cross 指标在图表中绘制两根均线并注释均线金叉和死叉状态。

2MA_Cross 指标图表效果:2MA_Cross 指标2MA_Cross 指标源码:

//+------------------------------------------------------------------+
//|                                                    2MA_Cross.mq4 |
//|                                  Copyright @2004, by konKop,wellx|
//+------------------------------------------------------------------+
*/
#property copyright "Copyright @2004, by konKop,wellx"
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_color2 White

extern int 均线周期1 = 10;
extern int 均线周期2 = 130;
extern int 类型 = 1;
extern string 类型说明 = "0-SMA; 1-EMA; 2-SMMA; 3-LWMA";
double g_ibuf_96[];
double g_ibuf_100[];
int gi_104;

int init() {
   IndicatorBuffers(2);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(0, g_ibuf_96);
   SetIndexBuffer(1, g_ibuf_100);
   gi_104 = 0;
   return (0);
}

void deinit() {
  Comment("www.125808047.com");
}

int start() {
   string ls_8;
   int li_16 = IndicatorCounted();
   if (li_16 < 0) return (-1);
   if (li_16 > 0) li_16--;
   int li_4 = Bars - li_16;
   for (int li_0 = li_4 - 1; li_0 >= 0; li_0--) {
      g_ibuf_96[li_0] = iMA(NULL, 0, 均线周期1, 0, 类型, PRICE_CLOSE, li_0);
      g_ibuf_100[li_0] = iMA(NULL, 0, 均线周期2, 0, 类型, PRICE_CLOSE, li_0);
      if (g_ibuf_96[li_0 + 1] < g_ibuf_100[li_0 + 1] && g_ibuf_96[li_0] > g_ibuf_100[li_0]) {
         ls_8 = "[MT4时间]" + TimeMonth(Time[li_0] + gi_104) + "月" + TimeDay(Time[li_0] + gi_104) + "日" + TimeHour(Time[li_0] + gi_104) + "点" + TimeMinute(Time[li_0] + gi_104) + "分 " + Symbol() + "在价格" + DoubleToStr(Close[li_0], 4) + "发生" + 均线周期1 + "均线上穿" + 均线周期2 + "均线";
         writetext("Up讯号", ls_8, 20, 40, Yellow, 14);
      }
      if (g_ibuf_96[li_0 + 1] > g_ibuf_100[li_0 + 1] && g_ibuf_96[li_0] < g_ibuf_100[li_0]) {
         ls_8 = "[MT4时间]" + TimeMonth(Time[li_0] + gi_104) + "月" + TimeDay(Time[li_0] + gi_104) + "日" + TimeHour(Time[li_0] + gi_104) + "点" + TimeMinute(Time[li_0] + gi_104) + "分 " + Symbol() + "在价格" + DoubleToStr(Close[li_0], 4) + "发生" + 均线周期1 + "均线下穿" + 均线周期2 + "均线";
         writetext("Up讯号", ls_8, 20, 40, Yellow, 14);
      }
   }
   return (0);
}

void writetext(string a_name_0, string a_text_8, int a_x_16, int a_y_20, color a_color_24, int a_fontsize_28) {
   ObjectDelete(a_name_0);
   ObjectCreate(a_name_0, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(a_name_0, a_text_8, a_fontsize_28, "Arial", a_color_24);
   ObjectSet(a_name_0, OBJPROP_CORNER, 0);
   ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_16);
   ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_20);
}

如您喜欢此文章请点下面分享按钮↴峰汇在线 » 指标 2MA_Cross
上一篇:
下一篇:
分享到:更多 ()