|
画趋势线,系统会自动给趋势线命名,比如Trendline 29125
当线的数量较大时,会造成莫名其妙的丢线,即前面画的线零七八碎的丢掉
猜测有可能是趋势线的名称后的数字偶尔会重复
以下代码会遍历所有的趋势线,重新按照规范命名(开始时间,结束时间,颜色)
重命名.zip
(605 Bytes, 下载次数: 0)
- #property copyright "Copyright 2012, MetaQuotes Software Corp."
- #property link "http://www.metaquotes.net"
- #property indicator_chart_window
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- int init()
- {
- //---- indicators
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator deinitialization function |
- //+------------------------------------------------------------------+
- int deinit()
- {
- //----
-
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator iteration function |
- //+------------------------------------------------------------------+
- int start()
- {
- //----
- int obj_total=ObjectsTotal();
- string name;
- string ColorString;
- string strtime1,strtime2;
- int count=0;
- for(int i=0;i<obj_total;i++)
- {
- name = ObjectName(i);
- if(ObjectType(name)==OBJ_TREND){
- ColorString=ColorToString(ObjectGet(name, OBJPROP_COLOR));
- strtime1=TimeToString(ObjectGet(name, OBJPROP_TIME1));
- strtime2=TimeToString(ObjectGet(name, OBJPROP_TIME2));
- ObjectSetString(0,name,OBJPROP_NAME,"Trendline"+"_"+strtime1+"_"+strtime2+"_"+ColorString);
- count++;
- }
- }
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
复制代码 |
|