Any mt4/mql4/etc. function for 'market closing in x minutes/hours'

 

hi,


lets say that i want to close any open order if the market is about to close (e.g. friday 21pm).


Is there any way i can determine if the market is about to close already? e.g. 1 hr before.

 
jcadong5 wrote >>

hi,

lets say that i want to close any open order if the market is about to close (e.g. friday 21pm).

Is there any way i can determine if the market is about to close already? e.g. 1 hr before.

Take a look to your watch .... *lol

No, sorry, there are lot of time/date functions in mql here https://docs.mql4.com/dateandtime

Rest depends what you want to do .. a Comment in the chart, Play some sound, Show an alert ...?

if (DayOfWeek()==5 && Hour() >= 21)

{

do something ...

}

 

There is no "announcement" or "closing tick". The ticks will just cease arriving and this can happen at various times within that window, depending upon market conditions and broker etc.

One way of dealing with this is to check the time with each incoming tick (as suggested above) and if it is after a pre-configured time (that you think is safely before ticks will dry up) then your EA acts accordingly. This approach takes a little trial and error, and variations in the time you exit the market on a Fri night may have a significant effect on your profitability, so make sure to test well.


CB


 
cloudbreaker:

There is no "announcement" or "closing tick". The ticks will just cease arriving and this can happen at various times within that window, depending upon market conditions and broker etc.

One way of dealing with this is to check the time with each incoming tick (as suggested above) and if it is after a pre-configured time (that you think is safely before ticks will dry up) then your EA acts accordingly. This approach takes a little trial and error, and variations in the time you exit the market on a Fri night may have a significant effect on your profitability, so make sure to test well.


CB


Thanks for the reply.


Ya I noticed that Fridays and leaving it out at the end of Fridays made just the same performance as the other days, at least on one EA that I tested just now.