|
换个方法,这样画均线也不错,这样可以在交易过程中手动调整均线的显示状态,做不到自动EA交易,做个手动交易的EA辅助工具使用还是不错的
- string MA_chu="O";
- string MA_xi="-";
- int fontsize=6;
- 形状_均线M5=MA_xi;
- 形状_均线M15=MA_xi;
- 形状_均线H1=MA_xi;
- 形状_均线H4=MA_xi;
- 形状_均线D1=MA_xi;
- 形状_均线W1=MA_xi;
- if(均线!=0)
- {
- string zfh_juli="";
- if(Close[0]<=iMA(Symbol(),0,均线,0,MODE_SMA,PRICE_WEIGHTED,0))
- {
- juli=iMA(Symbol(),0,均线,0,MODE_SMA,PRICE_WEIGHTED,0)-Bid;
- zfh_juli="-";
- }
- else
- {
- juli=Ask-iMA(Symbol(),0,均线,0,MODE_SMA,PRICE_WEIGHTED,0);
- zfh_juli="+";
- }
- if(均线==M5)
- {
- clr_均线=clrDeepPink;
- 形状_均线M5=MA_chu;
- }
- if(均线==M15)
- {
- clr_均线=clrDodgerBlue;
- 形状_均线M15=MA_chu;
- }
- if(均线==H1)
- {
- clr_均线=clrWhite;
- 形状_均线H1=MA_chu;
- }
- if(均线==H4)
- {
- clr_均线=clrRed;
- 形状_均线H4=MA_chu;
- }
- if(均线==D1)
- {
- clr_均线=clrDarkOrchid;
- 形状_均线D1=MA_chu;
- }
- text("均线系统_juli",ANCHOR_LEFT_LOWER,18,"Arial",clr_均线," "+zfh_juli+DoubleToStr(juli/pt,1),Time[0],Bid);
- if(休息观察==0 && 距离观察==1)
- label("均线系统_面板_juli_1", 0,ANCHOR_LEFT_UPPER,400,"Arial",clr_均线,zfh_juli+DoubleToStr(juli/pt,1),0, 32);
- }
- int bars=(int)ChartGetInteger(0,CHART_VISIBLE_BARS);
- for(int i=0; i<bars; i++)
- {
- text("均线系统_面板_均线M5"+(string)i,ANCHOR_CENTER,fontsize,"Arial",clrDeepPink,形状_均线M5,Time[i],iMA(NULL,0,M5,0,MODE_SMA,PRICE_WEIGHTED,i));
- text("均线系统_面板_均线M15"+(string)i,ANCHOR_CENTER,fontsize,"Arial",clrDodgerBlue,形状_均线M15,Time[i],iMA(NULL,0,M15,0,MODE_SMA,PRICE_WEIGHTED,i));
- text("均线系统_面板_均线H1"+(string)i,ANCHOR_CENTER,fontsize,"Arial",C'255,255,255',形状_均线H1,Time[i],iMA(NULL,0,H1,0,MODE_SMA,PRICE_WEIGHTED,i));
- text("均线系统_面板_均线H4"+(string)i,ANCHOR_CENTER,fontsize,"Arial",clrRed,形状_均线H4,Time[i],iMA(NULL,0,H4,0,MODE_SMA,PRICE_WEIGHTED,i));
- text("均线系统_面板_均线D1"+(string)i,ANCHOR_CENTER,fontsize,"Arial",clrDarkOrchid,形状_均线D1,Time[i],iMA(NULL,0,D1,0,MODE_SMA,PRICE_WEIGHTED,i));
- text("均线系统_面板_均线W1"+(string)i,ANCHOR_CENTER,fontsize,"Arial",C'255,128,64',形状_均线W1,Time[i],iMA(NULL,0,W1,0,MODE_SMA,PRICE_WEIGHTED,i));
- }
- if(id==CHARTEVENT_OBJECT_CLICK && ObjectGet(sparam,OBJPROP_TYPE)==OBJ_LABEL)
- {
- if(sparam=="均线系统_面板_均线m5")
- {
- if(Period()<=5)
- 均线=M5;
- }
- if(sparam=="均线系统_面板_均线m15")
- {
- if(Period()<=15)
- 均线=M15;
- }
- if(sparam=="均线系统_面板_均线h1")
- {
- if(Period()<=60)
- 均线=H1;
- }
复制代码 |
|