一个改进的Comment函数

2008年11月8日  |  19:13分类:MT4编程  |  标签:  |  2,802 views

这个函数是我在forexfactory.com论坛上看到的,主要作用是在图表上输出多行的Comment(注释),觉得挺有用,所以和大家分享一下:

//Determines how many of your previous comments are shown
extern int MaxCommentsToShow=25;
//An array to hold all of the comments
string allcomments[];
 
//+------------------------------------------------------------------+
//| Manage comments - Written by DMS                                           |
//+------------------------------------------------------------------+
void managecomments(string addcomment)
   {
   string tempcomments[];
   int commentscroll;
   string output;
   int CommentCount = ArrayRange(allcomments, 0);
   if(CommentCount<MaxCommentsToShow)
      {
      ArrayResize(tempcomments,CommentCount+1);
      ArrayCopy(tempcomments,allcomments,1,0,WHOLE_ARRAY);
      }
   else
      {
      ArrayResize(tempcomments,MaxCommentsToShow);
      ArrayCopy(tempcomments,allcomments,1,0,MaxCommentsToShow-1);
      }   
   tempcomments[0]=addcomment;
   CommentCount = ArrayRange(tempcomments, 0);
   ArrayResize(allcomments,CommentCount);
   ArrayCopy(allcomments,tempcomments,0,0,CommentCount);
 
   for(commentscroll=0;commentscroll<CommentCount;commentscroll++)
      {
      output = output + allcomments[commentscroll] +"\n";
      }    
   Comment(output);
   }

那么怎么用呢?很简单,直接调用行了:

managecomments("show this on my chart!");
喜欢本文,那就收藏到: Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪ViVi 365Key网摘 天极网摘 和讯网摘 博拉网 POCO网摘 添加到饭否 QQ书签 Digbuzz我挖网

2条评论 关于 “一个改进的Comment函数”

  1. Apria 发表于: 十二月 5th, 2008 05:52

    Good words.

  2. lnfa jhue 发表于: 二月 11th, 2009 06:18

    rwfdhgb gmvp yomgs ehtqx deikth mcjndwhq vcobn


发表您的评论