I want to move the EA comment from left to right corner ? - page 2

 
Thank you
 
string blankspaces="                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ";

   Comment(
           blankspaces,essechart,"/",qteCharts
           ,"\n",blankspaces,Bars(_Symbol,_Period)
           ,"\n",blankspaces,"Trade Autorizado: ",tradeAutorizado
           ,"\n",blankspaces,iTime(_Symbol,PERIOD_M1,0)
           ,"\n",blankspaces,TimeCurrent()
           ,"\n",blankspaces,TimeLocal()
           ,"\n",blankspaces,"qte: ",qteTrade
           ,"\n",blankspaces,"ChartID: ",ChartID()
           ,"\n",blankspaces,"TICK_VALUE: ",SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE)
           ,"\n",blankspaces,"SYMBOL_DIGITS: ",SymbolInfoInteger(_Symbol,SYMBOL_DIGITS)
           ,"\n",blankspaces,"spread: ",DoubleToString(spreadPoints,0)
           ,"\n",blankspaces,"ask: ",ask
           ,"\n",blankspaces,"bid: ",bid
           ,"\n",blankspaces,"contaSubida: ",contaSubida
           ,"\n",blankspaces,"contaDescida: ",contaDescida
           );
pradit thongget
:

I want to move the EA comment from left to right corner ? Ask for advice as well. Get help


Just had the same problem. My solution is: create a string "blankspaces" at the beginning of the code with dozens of blank spaces, then at the comment function you do like:

PS: desconsider my variables in the Comment function.

 

I think this is a good and easy solution, I added it to my Include Script:

int numOfLinesInRightSideComment = 0;
void commentRight(string _text, int _fontSize = 7, color _color = clrWhiteSmoke, string _name = "rightSideComment")
{
   StringReplace(_text, "\n", "·");
   ushort separator = StringGetCharacter("·",0);
   string _textArray[];
   int numLines = StringSplit(_text, separator, _textArray);
   int lineHeight = _fontSize + 6;
   if(numLines > numOfLinesInRightSideComment) numOfLinesInRightSideComment = numLines;
   
   for(int i=0;i<numLines;i++)
   {
      string lineText = _textArray[i];
      string objName = _name + string(i);
      ObjectCreate(objName, OBJ_LABEL, 0, 0, 0);
      ObjectSet(objName, OBJPROP_CORNER, CORNER_RIGHT_UPPER);
      ObjectSet(objName, OBJPROP_XDISTANCE, 10);
      ObjectSet(objName, OBJPROP_YDISTANCE, 10 + (lineHeight * i));
      ObjectSetText(objName, lineText, _fontSize, "Tahoma", _color);      
   }
}

void clearCommentRight(string _name = "rightSideComment")
{
   ObjectDelete(_name);
   for(int i=0;i<numOfLinesInRightSideComment;i++) ObjectDelete(_name + string(i));
}

Now you can call it like this:

//ADD COMMENTS TO THE RIGHT SIDE
string comment = "First Line\n";
comment += "Second Line\n";
comment += "Third Line\n";
commentRight(comment);

//CLEAR THE RIGHT SIDE COMMENTS
clearCommentRight();

And the result looks something like this:

MQL4 Right Side Comment
 
Alain Temis Rodriguez Acuna #: I think this is a good and easy solution, I added it to my Include Script
   StringReplace(_text, "\n", "·");
   ushort separator = StringGetCharacter("·",0);
   ⋮
   int numLines = StringSplit(_text, separator, _textArray);

Why change all the New Line characters to a Centered Dot only to separate by the Centered Dot?

 
William Roeder #:

Why change all the New Line characters to a Centered Dot only to separate by the Centered Dot?

Because I want to use the StringSplit function to split the comment's "\n" line breaks to an array. And StringSplit requires a ushort letter for separator.

"\n" is 2 letters, that's why I change it to the ushort "·"

 
Alain Temis Rodriguez Acuna #:

Because I want to use the StringSplit function to split the comment's "\n" line breaks to an array. And StringSplit requires a ushort letter for separator.

"\n" is 2 letters, that's why I change it to the ushort "·"

    "\n"
    is a string of one letter. The backslash is an escape. Character Constants - Integer Types - Data Types - Language Basics - MQL4 Reference
    '\n'
    is the integer 10, which is what you need to pass to StringSplit.