How to Find End Time of Each Session

 

I need to know the end time of each trading session to close position.
I've imported historical data into MT5, and in reality, the end time of each session is not fixed. For example some sessions end at 20:00, while others end at 21:00.
Is there a way in MQL5 to determine the current session's end time in each session?

P.S.
The SymbolInfoSessionTrade() function doesn't work here because the end hours of each session are not fixed.


Chart

 

Allows receiving time of beginning and end of the specified trading sessions for a specified symbol and day of week.



https://www.mql5.com/en/docs/marketinformation/symbolinfosessiontrade

Documentation on MQL5: Market Info / SymbolInfoSessionTrade
Documentation on MQL5: Market Info / SymbolInfoSessionTrade
  • www.mql5.com
SymbolInfoSessionTrade - Market Info - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Mahdi Ebrahimzadeh #:

Allows receiving time of beginning and end of the specified trading sessions for a specified symbol and day of week.



https://www.mql5.com/en/docs/marketinformation/symbolinfosessiontrade

Your answer doesn't help.

As I mentioned, this chart is a custom symbol.

You must set the start and end time for custom symbol using the CustomSymbolSetSessionTrade() once and before backtest meaning that it is NOT possible to change end time of current session in tester mode.

I need to backtest my EA on this custom symbol which has different end time for some trade session.

Any idea how to find this end time ?
Documentation on MQL5: Custom Symbols / CustomSymbolSetSessionTrade
Documentation on MQL5: Custom Symbols / CustomSymbolSetSessionTrade
  • www.mql5.com
CustomSymbolSetSessionTrade - Custom Symbols - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
B.Moreno #:
Your answer doesn't help.

As I mentioned, this chart is a custom symbol.

You must set the start and end time for custom symbol using the CustomSymbolSetSessionTrade() once and before backtest meaning that it is NOT possible to change end time of current session in tester mode.

I need to backtest my EA on this custom symbol which has different end time for some trade session.

Any idea how to find this end time ?

This is not an MQL question. If you are importing data from an external source it's your responsibility to collect the trading sessions start and end time and set them for the custom symbol.

So you need to get the answer from your external source.

 
B.Moreno #:
Your answer doesn't help.

As I mentioned, this chart is a custom symbol.

You must set the start and end time for custom symbol using the CustomSymbolSetSessionTrade() once and before backtest meaning that it is NOT possible to change end time of current session in tester mode.

I need to backtest my EA on this custom symbol which has different end time for some trade session.

Any idea how to find this end time ?

you can use that function. 

compare result of that function in a csv file for couple of days to find out how session combination works.

for example may be there is start and end candle when BOTH symbols (included in your Custom Symbol) has data for that time. 

then you can make a function to find sessions start and end time based on your small R&D work.