- //+------------------------------------------------------------------+
- //| 指标举例.mq4 |
- //| Copyright ?2007, 520FX Corp. |
- //| http://www.520fx.com |
- //+------------------------------------------------------------------+
- #property copyright \"Copyright ?2007, 520FX Corp.\"
- #property link \"http://www.520fx.com\"
- #property indicator_chart_window
- #property indicator_buffers 5
- #property indicator_color1 White
- #property indicator_color2 Yellow
- #property indicator_color3 Yellow
- #property indicator_color4 Yellow
- #property indicator_color5 Yellow
- extern int Ma=12;
- extern int Ma1=36;
- double MaLine[],Ma1Line[],Up[],Dn[],Tmp[];
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- int init()
- {
- //---- indicators
- IndicatorBuffers(5);
- SetIndexStyle(0,DRAW_LINE);
- SetIndexStyle(1,DRAW_LINE);
- SetIndexStyle(2,DRAW_ARROW);
- SetIndexStyle(3,DRAW_ARROW);
- SetIndexStyle(4,DRAW_LINE);
- SetIndexBuffer(0,MaLine);
- SetIndexBuffer(1,Ma1Line);
- SetIndexBuffer(2,Up);
- SetIndexBuffer(3,Dn);
- SetIndexBuffer(4,Tmp);
- SetIndexArrow(2,233);
- SetIndexArrow(3,234);
- //CreatTrendLine(\"趋势线\",15,High[15],5,Low[5],Yellow);
- for(int i=0;i=0;i--)
- {
- MaLine=iMA(NULL,0,Ma,0,MODE_SMA,PRICE_CLOSE,i);
- Ma1Line=iMA(NULL,0,Ma1,0,MODE_SMA,PRICE_CLOSE,i);
- }
- for (i=limit-1;i>=0;i--)
- {
- if(MaLine[i+1]Ma1Line)
- {
- Up=Low-2*Point;
- }
- if(MaLine[i+1]>Ma1Line[i+1] && MaLine=0;i--)
- {
- Tmp=Low[iLowest(NULL,0,MODE_LOW,18,i)];
- }
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- void writetext(string Labelname,string data,int x,int y,color ColorValue,int FontSize)//通过Object写文字
- {
- ObjectDelete(Labelname);
- ObjectCreate(Labelname, OBJ_LABEL, 0, 0, 0);
- ObjectSetText(Labelname, data, FontSize, \"Arial\", ColorValue);
- ObjectSet(Labelname, OBJPROP_CORNER, 0);
- ObjectSet(Labelname, OBJPROP_XDISTANCE, x);
- ObjectSet(Labelname, OBJPROP_YDISTANCE, y);
- }
- void CreatText(string objName,int i,double data,string Chars)//画K线文字
- {
- ObjectDelete(objName);
- ObjectCreate(objName, OBJ_TEXT, 0, Time, data);
- ObjectSetText(objName, Chars, 10, \"Arial\",DodgerBlue);
- }
- void CreatLine(string objName,double Data,color Cl)
- {
- ObjectDelete(objName);
- ObjectCreate(objName,OBJ_HLINE,0,Time[0],Data);
- ObjectSet(objName,OBJPROP_COLOR,Cl);
- }
- void CreatTrendLine(string objName,int x,double Data,int y,double data1,color Cl)
- {
- ObjectDelete(objName);
- ObjectCreate(objName,OBJ_TREND,0,Time[x],Data,Time[y],data1);
- ObjectSet(objName,OBJPROP_COLOR,Cl);
- }
复制代码 |