ObjectCreate ("AtOpen",OBJ_TEXT,0,0,0); ObjectCreate("AtOpen", OBJ_TEXT, 0,Time[1], Close[1] ); ObjectSetText ("AtOpen", "Opn:",10,"Calibri",clrWhite);
- The first created an object using time=0, it is on the extreme left, first bar of the chart.
- The second did nothing, you already have a object with that name.
- The third set the text.
Following your clue I inserted ObjectMove. Now I can see the "Opn:" text at the current bar using the CurrentTime variant.
I need the text to appear each day at 9am. Changing CurrentTime to 9 doesn't work. Please would you show me how to do that.
ObjectCreate ("AtOpen",OBJ_TEXT,0,0,0); ObjectMove( "AtOpen", 0, CurrentTime, High[1] ); ObjectSetText ("AtOpen", "Opn:",10,"Calibri",clrWhite);
#define HR0900 32400 // 9*3600 when = date() + HR0900; if(when > TimeCurrent() when = yesterday() + HR0900;Find bar of the same time one day ago - Simple Trading Strategies - MQL4 and MetaTrader 4 - MQL4 programming forum
I didn't want to sound ungrateful in any way as I appreciate the assistance offered.
As an absolute beginner I'm learning from those like whroeder1 who are generous enough to send help to folks in this forum.
Just in case it may ever be of any interest (though I doubt it) to someone like myself who knows so very little of MQL but is attempting to learn partly by writing their EA, I discovered adjusting the ObjectCreate places the text object to the 9am bar as follows
void OnTick() { int h=TimeHour(TimeCurrent()); int m=TimeMinute(TimeCurrent()); //Session Open if (h==9 && m==0) { ObjectCreate("AtOpen", OBJ_TEXT, 0, Time[0], High[0]); ObjectSetText ("AtOpen", "Opn:",10,"Calibri",clrWhite); } }
Thanks again for the help, much appreciated.
int h=TimeHour(TimeCurrent()); int m=TimeMinute(TimeCurrent()); if (h==9 && m==0)That only works if there is a tick during that minute, otherwise it fails. There can be minutes between ticks during the Asian session, think M1 chart.
"Free-of-Holes" Charts - MQL4 Articles
No candle if open = close ? - MQL4 and MetaTrader 4 - MQL4 programming forum
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Please would some kind person explain what I'm doing wrong here (MT4 EA).
Compile 0 errors and Charts/Objects/Object List confirms the object, but no text appears on the chart (background black for clrWhite).
Tried without the if condition also with Time[0], Close[0] but no difference.
Many thanks.