SymbolInfoSessionQuote

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

bool  SymbolInfoSessionQuote(
   string            name,                // symbol name
   ENUM_DAY_OF_WEEK  day_of_week,         // day of the week
   uint              session_index,       // session index
   datetime&         from,                // time of the session beginning
   datetime&         to                   // time of the session end
   );

Parameters

name

[in]  Symbol name.

ENUM_DAY_OF_WEEK

[in]  Day of the week, value of enumeration ENUM_DAY_OF_WEEK.

uint

[in]  Ordinal number of a session, whose beginning and end time we want to receive. Indexing of sessions starts with 0.

from

[out]  Session beginning time in seconds from 00 hours 00 minutes, in the returned value date should be ignored.

to

[out]  Session end time in seconds from 00 hours 00 minutes, in the returned value date should be ignored.

Return Value

If data for the specified session, symbol and day of the week are received, returns true, otherwise returns false.

Example:

#define SYMBOL_NAME   Symbol()
#define SESSION_INDEX 0
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- print the header with a symbol and SESSION_INDEX and
//--- in a loop by day of the week from Mon to Fri, print the start and end times of the quote session in the journal
   PrintFormat("Symbol %s, Quote session %d:"SYMBOL_NAMESESSION_INDEX);
   for(int i=MONDAYi<SATURDAYi++)
      SymbolInfoSessionQuotePrint(SYMBOL_NAME, (ENUM_DAY_OF_WEEK)iSESSION_INDEX);
   /*
   result:
   Symbol RU000A103661Quote session 0:
   - Monday     06:45 - 00:00
   - Tuesday    06:45 - 00:00
   - Wednesday  06:45 - 00:00
   - Thursday   06:45 - 00:00
   - Friday     06:45 - 00:00
   */
  }
//+------------------------------------------------------------------+
//| Send the start and end times of the specified quote session      |
//| for the specified symbol and day of the week to the journal      |
//+------------------------------------------------------------------+
void SymbolInfoSessionQuotePrint(const string symbolconst ENUM_DAY_OF_WEEK day_of_weekconst uint session_index)
  {
//--- declare variables to record the beginning and end of the quote session
   datetime date_from;  // session start time
   datetime date_to;    // session end time
   
//--- get data from the quotation session by symbol and day of the week
   if(!SymbolInfoSessionQuote(symbolday_of_weeksession_indexdate_fromdate_to))
     {
      Print("SymbolInfoSessionQuote() failed. Error "GetLastError());
      return;
     }
     
//--- create the week day name from the enumeration constant
   string week_day=EnumToString(day_of_week);
   if(week_day.Lower())
      week_day.SetChar(0ushort(week_day.GetChar(0)-32));
 
//--- send data for the specified quote session to the journal
   PrintFormat("- %-10s %s - %s"week_dayTimeToString(date_fromTIME_MINUTES), TimeToString(date_toTIME_MINUTES));
  }

See also

Symbol Properties, TimeToStruct, Data Structures