I'm having trouble figuring out which tradings session any particular time is in.
There are four possible sessions, show in this picture taken from ForexFactory.com
I have this method that I need to check is currentTime is during the specified trading session.
public bool IsTradingSession(TradingSession tradingSession, DateTime currentTime)
{
//Regular session is 5PM - next day 5PM, this is the session in the picture.
//Irregular sessions also occur for example late open (3AM - same day 5PM) or early close (5PM - next day 11AM)
DateTime sessionStart = Exchange.CurrentSessionOpen;
DateTime sessionEnd = Exchange.CurrentSessionClose;
if(tradingSession == TradingSession.Sydney)
return ....... ? true : false;
if(tradingSession == TradingSession.Tokyo)
return ....... ? true : false;
if(tradingSession == TradingSession.London)
return ....... ? true : false;
if (tradingSession == TradingSession.NewYork)
return ....... ? true : false;
return false;
}
Use:
bool isSydneySession = IsTradingSession(TradingSession.Sydney, CurrentTime);
bool isTokyoSession = IsTradingSession(TradingSession.Tokyo, CurrentTime);
bool isLondonSession = IsTradingSession(TradingSession.London, CurrentTime);
bool isNewYorkSession = IsTradingSession(TradingSession.NewYork, CurrentTime);
Thanks for any help