Comment() not refreshing ?

 

Hello all:

I am using Comment() function to display a text on screen, but it seems to me that it only works the first time. My code (resumed) goes like this


// Start

Comment ( "Text 1");

if ( a == 1) { Print(" a = 1 "); Comment( " a = 1"); }

// End


... and for some reason, when a = 1 the Print command is executed but the Comment on screen remains the same. Can Comment() function be used only once in a program?


Thanks for your hints.

Roberto Valbuena

Madrid, Spain

 
I don't know if there's a way around it. But thats how it was for me also. Only one Comment() is allowed.
 

Comment() shows a single string on the chart, and I believe (but is 100% not true) that the string can by of any length.

However your code says this:

1) tick comes in...

2) start activates

3) Comment tekst1. tekst says bla bla, I'm Roberto, best forex coder in Spain. Forex, give me your best!

4) Immediatley after that you ask the computer whether a is 1. This is probably inside a for or while loop with "a" being looped from 1/0 to N.

5) So on the cycle where a == 1 you ask the MT4 to remind you that a == 1. This happens so fast that you don't have the time to see (3).

This happens on every tick.

Comment shows you both comments, your eyes are not fast enough to catch that. And chances are that even your display is not fast enough to print both.

 

Comments and objects are painted to the screen when start() returns. On the next tick you're updating comment again and can't see it.

Also remember that comments can be multiline

string cmnt="Text 1";
if ( a == 1) { Print(" a = 1 "); cmnt=cmnt+"\na = 1"); }
Comment(cmnt);
 
WHRoeder:

Comments and objects are painted to the screen when start() returns. On the next tick you're updating comment again and can't see it.

Also remember that comments can be multiline


All right now. I have re-arranged the places where I put the Comments, so that one does not get rolled over by the next.

Thanks a lot!


Anyway, I guess that there is some other way to get things on the screen. If any of you has seen LeoTraderPro in action, you know what I mean; that EA shows the hour (with or without ticks) and a moving bar graph similar to that of a hi-fi system. How do they that?

Roberto

 

Nice Plug. From what I saw, it's using Line-Breaks. Thats easy to do using Comments by just adding "\n" to form new lines. Those kinds of commenting are nice for limited usage and de-bugging but long drawn-out sentences makes the chart look sloppy IMO. A much better professional look would be using indicators and separate windows. No limitation on art and display with that.

The bar graph is created using indicators/objects. It looks very similar to the free versions in our code base.

Reason: