MQL4 Learning - page 120

 

Hi Mladen

see my screenshot. ForexSteam

This EA I see in the Trading Tab and in the History

mladen:
Yes. you are right. If I understood you correctly, you wanted it to be visible in experts tab and log file. If you want it in experts tab an log file you have to use Print(). If showing it on screen only is enough, then Comment() should be used, and then you should use it on every tick (in case if some other code is writing out a comment, your comment line will be lost). If you want them on both places (screen and experts tab/log file) then you have ti use both commands (there is no single command that will do that)
Files:
terminal.png  49 kb
 

That is the comment filed of an order. You specify it in the time of opening order

But, in cases when you do a partial close of an order, it is almost sure that it (the comment field of the order) is going to be lost and broker will write some values of his (interesting, but a user can not change the comment field of an order once it is opened , only brokers can).

Sorry, but there is really no perfect solution for that ...

Badguy:
Hi Mladen

see my screenshot. ForexSteam

This EA I see in the Trading Tab and in the History
 

Thanks a Lot

Hi Mladen

thanks one more time for your support.

I will try to insert the comment by open the order

Thanks

mladen:
That is the comment filed of an order. You specify it in the time of opening order

But, in cases when you do a partial close of an order, it is almost sure that it (the comment field of the order) is going to be lost and broker will write some values of his (interesting, but a user can not change the comment field of an order once it is opened , only brokers can).

Sorry, but there is really no perfect solution for that ...
 

How to: Alert every hour

I want to have an alert every hour, when the broker time is 10:00, 11:00, 12:00 so on.

How can i do that in mql4?

 
Georgebaker:
I want to have an alert every hour, when the broker time is 10:00, 11:00, 12:00 so on. How can i do that in mql4?

It can be down this way.

if(Minute()==0)

Alert("Its ", Hour(), " o clock ");

 
Georgebaker:
It can be down this way.

if(Minute()==0)

Alert("Its ", Hour(), " o clock ");

The above code is close but does have one problem. It'll alert for one whole minute every time you get a new tick first minute of the hour.

There are many ways to do it. One way is this:

datetime BarTime;

bool isNewHour() {

//----

bool res=false;

if (BarTime!=iTime(NULL,PERIOD_H1,0)) {

BarTime=iTime(NULL,PERIOD_H1,0);

res=true;

}

return(res);

}

Under start(), you use:

if (isNewHour()) Alert(...);

This way you will get alert the first tick in new hour and only once.

 
christinaLi:
The above code is close but does have one problem. It'll alert for one whole minute every time you get a new tick first minute of the hour.

There are many ways to do it. One way is this:

datetime BarTime;

bool isNewHour() {

//----

bool res=false;

if (BarTime!=iTime(NULL,PERIOD_H1,0)) {

BarTime=iTime(NULL,PERIOD_H1,0);

res=true;

}

return(res);

}

Under start(), you use:

if (isNewHour()) Alert(...);

This way you will get alert the first tick in new hour and only once.

Thank you for your reply.

Yeah i was struggeling with this problem.

Should this code be located in the 'Init' part like this.

int init()

{

ObjectsDeleteAll(); // clear the chart

Comment(""); // clear the chart

datetime BarTime;

bool isNewHour() {

//----

bool res=false;

if (BarTime!=iTime(NULL,PERIOD_H1,0)) {

BarTime=iTime(NULL,PERIOD_H1,0);

res=true;

}

return(res);

}

}

 
Georgebaker:
Thank you for your reply.

Yeah i was struggeling with this problem.

Should this code be located in the 'Init' part like this.

int init()

{

ObjectsDeleteAll(); // clear the chart

Comment(""); // clear the chart

datetime BarTime;

bool isNewHour() {

//----

bool res=false;

if (BarTime!=iTime(NULL,PERIOD_H1,0)) {

BarTime=iTime(NULL,PERIOD_H1,0);

res=true;

}

return(res);

}

}

There are several error in the code above.

 

...

isNewBar() should be removed outside the init()

int init()

{

ObjectsDeleteAll(); // clear the chart

Comment(""); // clear the chart

}

bool isNewHour()

{

datetime BarTime;

//----

bool res=false;

if (BarTime!=iTime(NULL,PERIOD_H1,0)) {

BarTime=iTime(NULL,PERIOD_H1,0);

res=true;

}

return(res);

}

But if you are looking for a new bar than you should call the isNewBar() from start() to find if a new bar is formed since this way it is doing nothing (it is not referenced or called from anywhere)

Georgebaker:
There are several error in the code above.

 
mladen:
isNewBar() should be removed outside the init()
int init()

{

ObjectsDeleteAll(); // clear the chart

Comment(""); // clear the chart

}

bool isNewHour()

{

datetime BarTime;

//----

bool res=false;

if (BarTime!=iTime(NULL,PERIOD_H1,0)) {

BarTime=iTime(NULL,PERIOD_H1,0);

res=true;

}

return(res);

}

But if you are looking for a new bar than you should call the isNewBar() from start() to find if a new bar is formed since this way it is doing nothing (it is not referenced or called from anywhere)

Thanks mladen for stepping in here and clear that out.

I'm not looking for at new bar to close, i want to do something every hour like(broker time) 10:00, 11:00, 12:00 ... Do some code..

Ok let me try what you have described above.

Reason: