How to get market closing time

 

There is a situation very specific for BM&F Bovespa (Brazilian market). During US daylight savings, market hours change +1 hour (I will not get into the reason). My EA must end profitable positions during the last 10 minutes of market run (in fact, before closing auction starts). Now it is hard coded:

if (TimeSession(16,45,16,54,TimeCurrent()))

I am trying to make this more reliable and soft coded. Even when I run a back-test, this hard code will not be last 10 minutes if US daylight is going on. Can lead to wrong conclusions.

Using SymbolInfoSessionTrade() is always returning 1970.01.01 00:00, which I believe is because of trade session hours for symbol:

I was thinking of getting the closing time of previous day, but this will lead to wrong time on 2 days per year.

Any idea?

Thanks in advance.

Reason: