Download MetaTrader 5
To add comments, please log in or register
Need mobile version of MetaTrader 5? Download it and trade!
Adrian Suarez
36
Adrian Suarez 2012.03.02 19:35 

Hello all,

I am wondering if there is a way to get multiple lines of text using Comment(). I have tried to search, but no luck so far.

Thanks in advance,

LW

minhae
47
minhae 2012.03.02 19:47  

EX)

bjectCreate("Line1",OBJ_HLINE,0,0,1.37240);

bjectCreate("Line2",OBJ_HLINE,0,0, );

bjectCreate("Line3",OBJ_HLINE,0,0, );

bjectCreate("Line4",OBJ_HLINE,0,0, );

ok?

dabbler
1103
dabbler 2012.03.02 20:04  
LeagueORobots:

Hello all,

I am wondering if there is a way to get multiple lines of text using Comment(). I have tried to search, but no luck so far.

Thanks in advance,

LW

You just need to include a newline character in your text string. The newline is "\n" as a string so you might say

Comment("Hello\nWorld");
Dan
220
Dan 2012.03.02 20:04  
LeagueORobots:

Hello all,

I am wondering if there is a way to get multiple lines of text using Comment(). I have tried to search, but no luck so far.

Thanks in advance,

LW


#define NL                 "\n"         // <--- add this at the top of your ea or subsitute \n for NL on all the lines

    
Comment("MagicNumber1 = " + MagicNumber1 + NL +            
        "MagicNumber2 = " + MagicNumber2 + NL +
        ".................................................................." + NL +
        "Total Number of Main Trades = " + MainTrade + NL + 
        "Total Number of Main Trades Profit = " + MWin + NL +
        "Total Number of Main Trades Loss = " +   MLoss + NL +
        ".................................................................." + NL +
        "Total Number of Sub Trades = " +  SubTrade + NL +
        "Total Number of Sub Profit = " +  SWin + NL +
        "Total Number of Sub Loss = " +    SLoss + NL +
        "......................................................................................................" + NL +
        "Sub Trades Win % (Sub Trade win vs total Sub Trades) = "+ (SWin*100)/SubTrade+"%"+ NL +
        "Main Trade win % (Main wins vs total Main Trade) =  "+ (MWin*100)/(MainTrade)+"%"+ NL +
        "Sub Trades % to Main Trades (Total Sub Trades vs Main Trades) = "+ (SubTrade*100)/(MainTrade)+"%"+ NL +
        "......................................................................................................");
whroeder1
13619
whroeder1 2012.03.02 20:04  
string line1 = "this is line one",
       line2 = "below that is line two",
       line3 = "you get the idea";
Comment(line1+"\n",
        line2+"\n",
        line3+"\n");
whroeder1
13619
whroeder1 2012.03.02 20:06  
Ha, 3 replies, in the same minute.
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2012.03.02 21:25  

Something I knocked up last week, I noticed Comment couldn't keep up in the Strategy Tester and was falling behind, in other words, it was slow in putting messages on screen and wasn't able to put the correct message on screen when I did an automatic Chart Grab . . . so I created this, it was a bit of a rush job but it did what I wanted.

void CommentLab(string CommentText)
   {
   string CommentLabel;
   int CommentIndex = 0;
   
   if (CommentText == "")
      {
      //  delete all Comment texts
      while(ObjectFind(StringConcatenate("CommentLabel", CommentIndex )) >= 0)
         {
         ObjectDelete(StringConcatenate("CommentLabel", CommentIndex ));
         CommentIndex++;
         }
      return;
      }
   
   while(ObjectFind(StringConcatenate("CommentLabel", CommentIndex )) >= 0)
      {
      CommentIndex++;
      }
      
   CommentLabel = StringConcatenate("CommentLabel", CommentIndex);  
   ObjectCreate(CommentLabel, OBJ_LABEL, 0, 0, 0 );
   ObjectSet(CommentLabel, OBJPROP_CORNER, 0);
   ObjectSet(CommentLabel, OBJPROP_XDISTANCE, 5);
   ObjectSet(CommentLabel, OBJPROP_YDISTANCE, 15 + (CommentIndex * 15) );
   ObjectSetText(CommentLabel, CommentText, 10, "Tahoma", Status_Color );   
   
   }
Adrian Suarez
36
Adrian Suarez 2012.03.27 16:26  
Thank you all for the help.
/
To add comments, please log in or register