I don't think comment() function needs chart redraw to update the text.
each time you change the inputs, the OnInit() gets called.
so put all your comment() operations inside OnInit
Comment() function doesn't need ChartRedraw() function to work. I've never used Comment() function on OnInit() try to put it in OnTick().
And also I want to note something
"\n Profit Target = $" + DoubleToString(eqplus,2)+ ", Minimal Profit per Trade = " + DoubleToString(iMinimalProfit,2)+ ", Trade Lot = " + DoubleToString(iStartLots,2)+ ", Slippage = " + DoubleToString(iSlippage*10,0)+ ", Spread = " + DoubleToString(Spread*10,0)+ "\n Equity: before: $" + DoubleToString(MaxEqu[0],2)+ ", Equity: Target to Close all: $" + DoubleToString(MaxEqu[2],2) );
I believe you want your comment to be like what you write above. Instead using enter to move to next line you need to add \n after + symbol at the end of the your code. If you don't add it, it will show everything in one single line like this example below (only equity will be place on next line),
Profit Target = $XXXX, Minimal Profit per Trade = XXXX, Trade Lot = XXXX, Slippage = XXXX, Spread = XXXX
, Equity: Target to Close all: $XXXX
I don't think comment() function needs chart redraw to update the text.
each time you change the inputs, the OnInit() gets called.
so put all your comment() operations inside OnInit
no. the comment does NOT get updated after I change the the inputs. This is my problem. The comment gets updated when I call the function from any other functions, but does NOT update when I change the inputs.
The only time that OnInit seems to update the osd/comment is when put the ea on the chart for the FIRST time.
But your comment does make sense to me regarding the ChartRedraw(). I was confused about its use, as I have already asked this question in past and response I always got was to use ChartRedraw(), but in documentation it only uses it when using objects, which makes a lot of sense. I think that past responders assumed that I was using objects, maybe?
Thank you for your response.Comment() function doesn't need ChartRedraw() function to work. I've never used Comment() function on OnInit() try to put it in OnTick().
And also I want to note something
I believe you want your comment to be like what you write above. Instead using enter to move to next line you need to add \n after + symbol at the end of the your code. If you don't add it, it will show everything in one single line like this example below (only equity will be place on next line),
thanks, but I have 2 lines there, the first line ends with +.
and 2 lines starting with \n. So, your example is how it looks AND exactly how i want it to look. (with the spaces before start of each line, to allow for trade lots to show).
But thank you for responding.
UPDATE
I have put in global
bool initOSD = false;
And then in OnTick() I have added
if(!initOSD)
osd();
and in the code I posted earlier, I added before the return
initOSD = true; return;
I, then, removed the call of osd() from the OnInit() since it seemed to be useless in there.
This -- i think -- will mean that when the globals are refreshed, or when OnInit is called, then, the osd/comment will be called.
Am i right?
I have not tested it yet, as I do not want to change the inputs while I have trades open. But i will report when i have tested it.you can detect the case of input parameters being changed by OnDeinit() reason.
let a global bool keep track of whether inputs are changed or not, if so, let the ontick (or onInit) perform the comment once and reset the global bool.
you can detect the case of input parameters being changed by OnDeinit() reason.
let a global bool keep track of whether inputs are changed or not, if so, let the ontick (or onInit) perform the comment once and reset the global bool.
Thanks I had already modified OnTick as you described, and done that before your comment, but thanks, it means that I am still thinking like a coder sometimes haha. great minds... and all that.
I have also found the reasons for OnDeinit and modified my OnDeinit() like so...
void OnDeinit(const int reason) { Comment(""); if(reason==REASON_PARAMETERS || reason==REASON_RECOMPILE) osd(); }
NOPE. the reasons for deinit has not worked either. the above code caused the osd to flicker so that I can see it refresh when I recompile, but the osd does not change when I change the ea inputs in ea properties.
the osd still refreshes when I open or close trades, as I call the osd after both when a trade closes or opens. But does not when I change ea settings.
NOTE that I have also checked this in both versions 4150 and 4233.
The global bool has not worked either. 100% same as desribed above. it works just like the OnDeinit reason did. works in all calls except when I change settings of the ea properties.what I meant is:
first on global scope at top of codes:
bool osd_to_be_called = true;
then inside Ontick and Oninit:
if(osd_to_be_called) { osd(); osd_to_be_called = false; }
then inside OnDeinit :
if(reason==REASON_PARAMETERS || reason==REASON_RECOMPILE) osd_to_be_called=true;
and inside ontrade... if you need to update the comment just call osd() without changing osd_to_be_called
what I meant is:
first on global scope at top of codes:
then inside Ontick and Oninit:
then inside OnDeinit :
and inside ontrade... if you need to update the comment just call osd() without changing osd_to_be_called
ok. will try this tonight in about 8 hours from now. thanks for your attention to the details.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have it
But the OSD/comment on the chart does not get updated after I change the inputs.
NOTE that I want these inputs Spread, iMinialProfit, iSlippage to change in the chart comment/osd when I change them in the ea inputs.
How do I make my OSD to change and update my OSD/chart comment to change and update when I change them in my ea settings?