管理帮忙加个CMO指标 | |
---|---|
![]() |
andy468 2012-12-07 21:17
#property copyright \"520FX 程序化策略交流社区\"
#property link \"http://www.520FX.com\" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 LightBlue #property indicator_width1 2 #property indicator_level1 0 #property indicator_level2 50 #property indicator_level3 -50 #property indicator_maximum 100 #property indicator_minimum -100 //---- input parameters extern int Length = 14; // Period of evaluation extern int Price = 0; // Price mode : 0-Close,1-Open,2-High,3-Low,4-Median,5-Typical,6-Weighted //---- buffers double CMO[]; double Bulls[]; double Bears[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() {DrawLogo();//加载Logo //---- indicators IndicatorBuffers(3); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,CMO); SetIndexBuffer(1,Bulls); SetIndexBuffer(2,Bears); //---- name for DataWindow and indicator subwindow label string short_name=\"CMO(\"+Length+\",\"+Price+\")\"; IndicatorShortName(short_name); SetIndexLabel(0,\"CMO\"); //---- SetIndexDrawBegin(0,Length); return(0); } int deinit() { DeleteLogo();//删除Logo } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int shift, limit, counted_bars=IndicatorCounted(); double Price1, Price2; //---- if ( counted_bars < 0 ) return(-1); if ( counted_bars ==0 ) limit=Bars-Length-1; if ( counted_bars < 1 ) for(int i=1;i<Length;i++) { Bulls[Bars-i]=0; Bears[Bars-i]=0; CMO[Bars-i]=0; } if(counted_bars>0) limit=Bars-counted_bars; limit--; for( shift=limit; shift>=0; shift--) { Price1 = iMA(NULL,0,1,0,0,Price,shift); Price2 = iMA(NULL,0,1,0,0,Price,shift+1); Bulls[shift] = 0.5*(MathAbs(Price1-Price2)+(Price1-Price2)); Bears[shift] = 0.5*(MathAbs(Price1-Price2)-(Price1-Price2)); double SumBulls = 0, SumBears=0; for (i=0;i<Length;i++) { SumBulls += Bulls[shift+i]; SumBears += Bears[shift+i]; } CMO[shift] = (SumBulls-SumBears)/(SumBulls+SumBears)*100; } /* for( shift=limit; shift>=0; shift--) { double AvgBulls=iMAOnArray(Bulls,0,Length,0,0,shift); double AvgBears=iMAOnArray(Bears,0,Length,0,0,shift); CMO[shift] = (AvgBulls-AvgBears)/(AvgBulls+AvgBears)*100; } */ //---- return(0); } //+------------------------------------------------------------------+ void writetext(string Labelname,string data,int x,int y,int Corner,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_CORNER,Corner); ObjectSet(Labelname, OBJPROP_XDISTANCE, x); ObjectSet(Labelname, OBJPROP_YDISTANCE, y); } void DrawLogo() { int Corner=2; int x=10; int y=10; color ColorValue=White; color LogoColor=Yellow; writetext(\"左下角\",\"┗\",0+x,0+y,Corner,ColorValue,10); for(int i=0;i<=10;i++) writetext(\"上横线\"+i,\"━\",9+x+i*13,0+y,Corner,ColorValue,10); writetext(\"右下角\",\"┛\",0+x+i*13+9,0+y,Corner,ColorValue,10); for(int j=0;j<=1;j++) writetext(\"左竖线\"+j,\"|\",0+x,14+y+j*13,Corner,ColorValue,10); for(j=0;j<=1;j++) writetext(\"左竖线1\"+j,\"|\",0+x+1,14+y+j*13,Corner,ColorValue,10); writetext(\"左上角\",\"┏\",0+x,14+y+j*13,Corner,ColorValue,10); writetext(\"文字1\",\"www.520FX.com\",35+x,10+y,Corner,LogoColor,10); writetext(\"文字2\",\"程序交易策略社区\",20+x,25+y,Corner,ColorValue,10); for(int k=0;k<=10;k++) writetext(\"下横线\"+k,\"━\",9+x+k*13,14+y+j*13,Corner,ColorValue,10); writetext(\"右上角\",\"┓\",9+x+k*13,14+y+j*13,Corner,ColorValue,10); for(int r=0;r<=1;r++) writetext(\"右竖线\"+r,\"|\",9+x+k*13,14+y+(j-(r+1))*13,Corner,ColorValue,10); for(r=0;r<=1;r++) writetext(\"右竖线1\"+r,\"|\",9+x+k*13+1,14+y+(j-(r+1))*13,Corner,ColorValue,10); } void DeleteLogo() { ObjectDelete(\"左下角\"); for(int i=0;i<=10;i++) ObjectDelete(\"上横线\"+i); ObjectDelete(\"右下角\"); for(int j=0;j<=1;j++) ObjectDelete(\"左竖线\"+j); for(j=0;j<=1;j++) ObjectDelete(\"左竖线1\"+j); ObjectDelete(\"左上角\"); ObjectDelete(\"文字1\"); ObjectDelete(\"文字2\"); for(int k=0;k<=10;k++) ObjectDelete(\"下横线\"+k); ObjectDelete(\"右上角\"); for(int r=0;r<=1;r++) ObjectDelete(\"右竖线\"+r); for(r=0;r<=1;r++) ObjectDelete(\"右竖线1\"+r); } 网上下的 把里面的LOGO代码之类的删掉 我不会弄 我现在的系统需要这个指标 谢谢 |
![]() |
myeatrade 2012-12-07 22:23
将指标用附件上传即可,不用复制代码,上面代码直接复制下来是无法直接编译和使用的~
|
![]() |
andy468 2012-12-07 23:06
传了
|
![]() |
myeatrade 2012-12-08 10:23
已经在 “其他指标” 下面增加,名称为CMO,需重新下载使用
|
![]() |
andy468 2013-03-06 19:21 myeatrade 写道:已经在 “其他指标” 下面增加,名称为CMO,需重新下载使用 指标无法使用 没有填写参数的地方 建议指标参数可以自己填写 |
![]() |
myeatrade 2013-03-07 18:06
已经修复
|
Page 1 of 1
1
请登录后发表回复,如果你还没有账户你可以 免费注册
回到 交易系统 & 指标