|
- //+------------------------------------------------------------------+
- //| Vegas channel.mq4 ProjectName |
- //| Copyright 2012, CompanyName |
- //| http://www.companyname.net |
- //+------------------------------------------------------------------+
- #property copyright ""
- #property link ""
- #property indicator_chart_window
- #property indicator_buffers 7
- #property indicator_color1 Red
- #property indicator_color2 Yellow
- #property indicator_color3 DeepSkyBlue
- #property indicator_color4 SpringGreen
- #property indicator_color5 Magenta
- #property indicator_color6 Silver
- #property indicator_color7 MediumPurple
- #property indicator_color8 clrNONE
- extern string 版权="By Annie Sun";
- extern int MA1_Per=5;
- extern int MA2_Per=10;
- extern int MA3_Per=20;
- extern int MA4_Per=40;
- extern int MA5_Per=60;
- extern int MA6_Per=80;
- extern int MA7_Per=100;
- extern ENUM_MA_METHOD MA1_平滑模式=MODE_EMA;
- extern ENUM_MA_METHOD MA2_平滑模式=MODE_EMA;
- extern ENUM_MA_METHOD MA3_平滑模式=MODE_EMA;
- extern ENUM_MA_METHOD MA4_平滑模式=MODE_EMA;
- extern ENUM_MA_METHOD MA5_平滑模式=MODE_EMA;
- extern ENUM_MA_METHOD MA6_平滑模式=MODE_EMA;
- extern ENUM_MA_METHOD MA7_平滑模式=MODE_EMA;
- extern int MA1_平移=0;
- extern int MA2_平移=0;
- extern int MA3_平移=0;
- extern int MA4_平移=0;
- extern int MA5_平移=0;
- extern int MA6_平移=0;
- extern int MA7_平移=0;
- extern ENUM_APPLIED_PRICE MA1_应用于=PRICE_CLOSE;
- extern ENUM_APPLIED_PRICE MA2_应用于=PRICE_CLOSE;
- extern ENUM_APPLIED_PRICE MA3_应用于=PRICE_CLOSE;
- extern ENUM_APPLIED_PRICE MA4_应用于=PRICE_CLOSE;
- extern ENUM_APPLIED_PRICE MA5_应用于=PRICE_CLOSE;
- extern ENUM_APPLIED_PRICE MA6_应用于=PRICE_CLOSE;
- extern ENUM_APPLIED_PRICE MA7_应用于=PRICE_CLOSE;
- extern int 均线粗细1=1;
- extern int 均线粗细2=2;
- extern int 箭头距离1=5;
- extern int 图标大小2=2;
- extern int 箭头距离2=10;
- extern bool 显示主图文字=true;
- extern bool 报警开关=false;
- extern int 报警K线=1;
- double ccc;
- int b=0;
- double x1[];
- double x2[];
- double x3[];
- double x4[];
- double x5[];
- double x6[];
- double x7[];
- double x8[];
- double x9[];
- double x10[];
- //+------------------------------------------------------------------+
- //| |
- //+------------------------------------------------------------------+
- int init()
- {
- SetIndexBuffer(0,x1);
- SetIndexStyle(0,DRAW_LINE,0,均线粗细1);
- SetIndexDrawBegin(0,0);
- SetIndexBuffer(1,x2);
- SetIndexStyle(1,DRAW_LINE);
- SetIndexDrawBegin(1,0);
- SetIndexBuffer(2,x3);
- SetIndexStyle(2,DRAW_LINE);
- SetIndexDrawBegin(2,0);
- SetIndexBuffer(3,x4);
- SetIndexStyle(3,DRAW_LINE);
- SetIndexDrawBegin(3,0);
- SetIndexBuffer(4,x5);
- SetIndexStyle(4,DRAW_LINE);
- SetIndexDrawBegin(4,0);
- SetIndexBuffer(5,x6);
- SetIndexStyle(5,DRAW_LINE,2,均线粗细1);
- SetIndexDrawBegin(5,0);
- SetIndexBuffer(6,x7);
- SetIndexStyle(6,DRAW_LINE,2,均线粗细1);
- SetIndexDrawBegin(6,0);
- SetIndexBuffer(7,x8);
- SetIndexStyle(7,DRAW_ARROW,2,均线粗细1);
- SetIndexDrawBegin(7,0);
- SetIndexLabel(0,"MA"+DoubleToString(MA1_Per,0));
- SetIndexLabel(1,"MA"+DoubleToString(MA2_Per,0));
- SetIndexLabel(2,"MA"+DoubleToString(MA3_Per,0));
- SetIndexLabel(3,"MA"+DoubleToString(MA4_Per,0));
- SetIndexLabel(4,"MA"+DoubleToString(MA5_Per,0));
- SetIndexLabel(5,"MA"+DoubleToString(MA6_Per,0));
- SetIndexLabel(6,"MA"+DoubleToString(MA7_Per,0));
- IndicatorDigits(Digits+1);
- return(0);
- }
- //+------------------------------------------------------------------+
- //| |
- //+------------------------------------------------------------------+
- int deinit()
- {
- ObjectDelete(0,"MA_ALARM_0401");
- ObjectDelete(0,"MA_ALARM_0401_V");
- ObjectDelete(0,"MA1_ALARM_0401");
- ObjectDelete(0,"MA1_ALARM_0401_V");
- ObjectDelete(0,"MA2_ALARM_0401");
- ObjectDelete(0,"MA2_ALARM_0401_V");
- ObjectDelete(0,"MA3_ALARM_0401");
- ObjectDelete(0,"MA3_ALARM_0401_V");
- ObjectDelete(0,"MA4_ALARM_0401");
- ObjectDelete(0,"MA4_ALARM_0401_V");
- ObjectDelete(0,"MA5_ALARM_0401");
- ObjectDelete(0,"MA5_ALARM_0401_V");
- ObjectDelete(0,"MA6_ALARM_0401");
- ObjectDelete(0,"MA6_ALARM_0401_V");
- ObjectDelete(0,"MA7_ALARM_0401");
- ObjectDelete(0,"MA7_ALARM_0401_V");
- ObjectDelete(0,"MA8_ALARM_0401");
- ObjectDelete(0,"MA8_ALARM_0401_V");
- ObjectDelete(0,"MA9_ALARM_0401");
- ObjectDelete(0,"MA9_ALARM_0401_V");
- return 0;
- }
- //+------------------------------------------------------------------+
- //| |
- //+------------------------------------------------------------------+
- int start()
- {
- int limit;
- int counted_bars=IndicatorCounted();
- if(counted_bars<0) return(-1);
- if(counted_bars>0) counted_bars--;
- limit=Bars-counted_bars;
- if(ccc!=Close[1]) b=1;
- else b=0;
- for(int i=limit+1; i>=0; i--)
- {
- if(MA1_平移>=0)
- {
- x1[i]=iMA(NULL,0,MA1_Per,MA1_平移,MA1_平滑模式,MA1_应用于,i);
- }
- else if(i>=MathAbs(MA1_平移))
- x1[i]=iMA(NULL,0,MA1_Per,MA1_平移,MA1_平滑模式,MA1_应用于,i);
- if(MA2_平移>=0)
- {
- x2[i]=iMA(NULL,0,MA2_Per,MA2_平移,MA2_平滑模式,MA2_应用于,i);
- }
- else if(i>=MathAbs(MA2_平移))
- x2[i]=iMA(NULL,0,MA2_Per,MA2_平移,MA2_平滑模式,MA2_应用于,i);
- if(MA3_平移>=0)
- {
- x3[i]=iMA(NULL,0,MA3_Per,MA3_平移,MA3_平滑模式,MA3_应用于,i);
- }
- else if(i>=MathAbs(MA3_平移))
- x3[i]=iMA(NULL,0,MA3_Per,MA3_平移,MA3_平滑模式,MA3_应用于,i);
- if(MA4_平移>=0)
- {
- x4[i]=iMA(NULL,0,MA4_Per,MA4_平移,MA4_平滑模式,MA4_应用于,i);
- }
- else if(i>=MathAbs(MA4_平移))
- x4[i]=iMA(NULL,0,MA4_Per,MA4_平移,MA4_平滑模式,MA4_应用于,i);
- if(MA5_平移>=0)
- {
- x5[i]=iMA(NULL,0,MA5_Per,MA5_平移,MA5_平滑模式,MA5_应用于,i);
- }
- else if(i>=MathAbs(MA5_平移))
- x5[i]=iMA(NULL,0,MA5_Per,MA5_平移,MA5_平滑模式,MA5_应用于,i);
- if(MA6_平移>=0)
- {
- x6[i]=iMA(NULL,0,MA6_Per,MA6_平移,MA6_平滑模式,MA6_应用于,i);
- }
- else if(i>=MathAbs(MA6_平移))
- x6[i]=iMA(NULL,0,MA6_Per,MA6_平移,MA6_平滑模式,MA6_应用于,i);
-
-
- if(MA7_平移>=0)
- {
- x7[i]=iMA(NULL,0,MA7_Per,MA7_平移,MA7_平滑模式,MA7_应用于,i);
- }
- else if(i>=MathAbs(MA7_平移))
- x7[i]=iMA(NULL,0,MA7_Per,MA7_平移,MA7_平滑模式,MA7_应用于,i);
-
-
-
-
-
- }
- if(报警开关)
- {
- if(x1[报警K线]>x2[报警K线] && x1[报警K线+1]<x2[报警K线+1] && b)
- {
- ccc=Close[1];
- Alert(Symbol()," "+PeriodToText()+" "+DoubleToString(MA1_Per,0)+"均线 金叉 "+DoubleToString(MA2_Per,0)+"均线 做多");
- }
- if(x1[报警K线]<x2[报警K线] && x1[报警K线+1]>x2[报警K线+1] && b)
- {
- ccc=Close[1];
- Alert(Symbol()," "+PeriodToText()+" "+DoubleToString(MA1_Per,0)+"均线 死叉 "+DoubleToString(MA2_Per,0)+"均线 做空");
- }
- if(x1[报警K线]>x3[报警K线] && x1[报警K线+1]<x3[报警K线+1] && b)
- {
- ccc=Close[1];
- Alert(Symbol()," "+PeriodToText()+" "+DoubleToString(MA1_Per,0)+"均线 金叉 "+DoubleToString(MA3_Per,0)+"均线 做多");
- }
- if(x1[报警K线]<x3[报警K线] && x1[报警K线+1]>x3[报警K线+1] && b)
- {
- ccc=Close[1];
- Alert(Symbol()," "+PeriodToText()+" "+DoubleToString(MA1_Per,0)+"均线 死叉 "+DoubleToString(MA3_Per,0)+"均线 做空");
- }
- }
- ObjectDelete(0,"MA_ALARM_0401");
- ObjectDelete(0,"MA_ALARM_0401_V");
- ObjectDelete(0,"MA1_ALARM_0401");
- ObjectDelete(0,"MA1_ALARM_0401_V");
- ObjectDelete(0,"MA2_ALARM_0401");
- ObjectDelete(0,"MA2_ALARM_0401_V");
- ObjectDelete(0,"MA3_ALARM_0401");
- ObjectDelete(0,"MA3_ALARM_0401_V");
- ObjectDelete(0,"MA4_ALARM_0401");
- ObjectDelete(0,"MA4_ALARM_0401_V");
- ObjectDelete(0,"MA5_ALARM_0401");
- ObjectDelete(0,"MA5_ALARM_0401_V");
- ObjectDelete(0,"MA6_ALARM_0401");
- ObjectDelete(0,"MA6_ALARM_0401_V");
- ObjectDelete(0,"MA7_ALARM_0401");
- ObjectDelete(0,"MA7_ALARM_0401_V");
- ObjectDelete(0,"MA8_ALARM_0401");
- ObjectDelete(0,"MA8_ALARM_0401_V");
- ObjectDelete(0,"MA9_ALARM_0401");
- ObjectDelete(0,"MA9_ALARM_0401_V");
- if(显示主图文字)
- {
- writetext("MA_ALARM_0401","MA"+DoubleToString(MA1_Per,0)+":",10,30,Red,12,1);
- writetext("MA_ALARM_0401_V",DoubleToString(x1[0],Digits),70,30,Red,12,1);
- writetext("MA1_ALARM_0401","MA"+DoubleToString(MA2_Per,0)+":",10,55,Yellow,12,1);
- writetext("MA1_ALARM_0401_V",DoubleToString(x2[0],Digits),70,54,Yellow,12,1);
- writetext("MA2_ALARM_0401","MA"+DoubleToString(MA3_Per,0)+":",10,77,DodgerBlue,12,1);
- writetext("MA2_ALARM_0401_V",DoubleToString(x3[0],Digits),70,75,DodgerBlue,12,1);
- writetext("MA3_ALARM_0401","MA"+DoubleToString(MA4_Per,0)+":",10,99,SpringGreen,12,1);
- writetext("MA3_ALARM_0401_V",DoubleToString(x4[0],Digits),70,100,SpringGreen,12,1);
- writetext("MA4_ALARM_0401","MA"+DoubleToString(MA5_Per,0)+":",10,120,Magenta,12,1);
- writetext("MA4_ALARM_0401_V",DoubleToString(x5[0],Digits),70,120,Magenta,12,1);
- writetext("MA5_ALARM_0401","MA"+DoubleToString(MA6_Per,0)+":",10,140,Silver,12,1);
- writetext("MA5_ALARM_0401_V",DoubleToString(x6[0],Digits),70,140,Silver,12,1);
-
- writetext("MA6_ALARM_0401","MA"+DoubleToString(MA7_Per,0)+":",10,160,MediumPurple,12,1);
- writetext("MA6_ALARM_0401_V",DoubleToString(x7[0],Digits),70,160,MediumPurple,12,1);
-
-
- }
- return(0);
- }
- //+------------------------------------------------------------------+
- //| |
- //+------------------------------------------------------------------+
- void writetext(string Labelname,string data,int x,int y,color ColorValue,int FontSize,int window)//通过Object写文字
- {
- ObjectDelete(Labelname);
- ObjectCreate(Labelname,OBJ_LABEL,window,0,0);
- ObjectSetText(Labelname,data,FontSize,"Arial00",ColorValue);
- ObjectSet(Labelname,OBJPROP_CORNER,0);
- ObjectSet(Labelname,OBJPROP_XDISTANCE,x);
- ObjectSet(Labelname,OBJPROP_YDISTANCE,y);
- }
- //+------------------------------------------------------------------+
- //| |
- //+------------------------------------------------------------------+
- string PeriodToText()
- {
- switch(Period())
- {
- case 1:
- return("M1");
- break;
- case 5:
- return("M5");
- break;
- case 15:
- return("M15");
- break;
- case 30:
- return("M30");
- break;
- case 60:
- return("H1");
- break;
- case 240:
- return("H4");
- break;
- case 1440:
- return("D1");
- break;
- case 10080:
- return("W1");
- break;
- case 43200:
- return("MN1");
- break;
- }
- }
- //+------------------------------------------------------------------+
复制代码
帮帮忙 把附图的均线价格 移动到右边来 这样 看价格就清楚一点了 拜托了 |
|