MT4授课11月19日 趋势线对象的应用 课堂实例代码
[*]//+------------------------------------------------------------------+
[*]//| 指标举例.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,5,Low,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(MaLineMa1Line)
[*]{
[*]Up=Low-2*Point;
[*]}
[*]if(MaLine>Ma1Line && MaLine=0;i--)
[*]{
[*]Tmp=Low;
[*]}
[*]//----
[*]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,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,Data,Time,data1);
[*]ObjectSet(objName,OBJPROP_COLOR,Cl);
[*]}
复制代码 不错,支持下 我的啦嘿嘿 唉,悲催的外汇。。 真的有么 好人一个 #无语 做一个,做好了,请看 我帮你 喝喝 路过。。看下先。