SymbolInfoSessionTrade - session_index,

 
Good morning
I see in the doc
SymbolInfoSessionTrade - Market Info - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

What is it for?


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

can I know the number of sessions by _symbol?
have a description?

It lacks detail
THANKS

Because otherwise I only see 0 as an argument to give

Documentation on MQL5: Market Info / SymbolInfoSessionTrade
Documentation on MQL5: Market Info / SymbolInfoSessionTrade
  • www.mql5.com
Allows receiving time of beginning and end of the specified trading sessions for a specified symbol and day of week. Parameters name [in]  ...
 
Gerard William G J B M Dinh Sy:
Good morning
I see in the doc
SymbolInfoSessionTrade - Market Info - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

What is it for?


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

can I know the number of sessions by _symbol?
have a description?

It lacks detail
THANKS

Because otherwise I only see 0 as an argument to give

there may be symbols with more sessions

int OnInit()
  {
  EventSetMillisecondTimer(44);
  return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason)
  {
  }
void OnTick()
  {
  }
void OnTimer()
  {
  EventKillTimer();
  int st=SymbolsTotal(false);
  for(int i=0;i<st;i++){
     string name=SymbolName(i,false);
     int sess=0;
     datetime from[],to[];ArrayResize(from,1,0);ArrayResize(to,1,0);
     while(SymbolInfoSessionQuote(name,WEDNESDAY,sess,from[sess],to[sess])){
          sess++;
          ArrayResize(from,sess+1,0);ArrayResize(to,sess+1,0);
          }
     if(sess>1){
       Print("Discovered symbol with more sessions:::>"+name);
       for(int j=0;j<sess;j++){
          Print("Session #"+IntegerToString(j));
          Print("---> ("+TimeToString(from[j],TIME_MINUTES|TIME_SECONDS)+")-("+TimeToString(to[j],TIME_MINUTES|TIME_SECONDS)+")");
          }
       break;
       }
     }
  Print("DONE");
  ExpertRemove();
  }
 
yes clearly
the pre-opening, the main session and then the fixing for example.

But you need to know the number of sessions in advance for an EA who only wants to work on the two sessions outside the main one, for example.
 
Gerard William G J B M Dinh Sy #:
yes clearly
the pre-opening, the main session and then the fixing for example.

But you need to know the number of sessions in advance for an EA who only wants to work on the two sessions outside the main one, for example.

yeah you must know the number of sessions.

or you can querry them once , after symbol loads , this way . keep scanning sessions until it returns false.

Or some other way i have not come across which is easier

 
I think I'll do it differently.
I'll keep the values:

datetime& from, // session start time
datetime& to // session end time

and depending on the EA and knowledge of the symbol and broker or the symbol type (futures, CFDs, etc.), it matches the session I want to use or ignore.
 
following your code

 void OnTimer ()
  {
   EventKillTimer ();
   int st= SymbolsTotal ( false );
   for ( int i= 0 ;i<st;i++){
     string name= SymbolName (i, false );
     int sess= 0 ;
     datetime from[],to[]; ArrayResize (from, 1 , 0 ); ArrayResize (to, 1 , 0 );
     while ( SymbolInfoSessionQuote (name, WEDNESDAY ,sess,from[sess],to[sess])){

Do you realize that the function doesn't take a date?
in fact it would only be necessary to load it once and put the result in a variable, structure
because in fact, it seems that the schedules for the, the Wednesday sessions will never change

The function considers from its constitution that the values are immutable
 
Gerard William G J B M Dinh Sy #:
following your code


Do you realize that the function doesn't take a date?
in fact it would only be necessary to load it once and put the result in a variable, structure
because in fact, it seems that the schedules for the, the Wednesday sessions will never change

The function considers from its constitution that the values are immutable

yeah it returns time only not a day

this is a good design choice actually as it returns the seconds the session starts from and the seconds it ends at

I take all the sessions of the day and consolidate them on a boolean array of trading minutes
 
This is how it will end for me

   //--- Structure for storing trading session details 
   struct struc_Session_Info {
     ENUM_DAY_OF_WEEK Day_of_week; // Day of the week for this session 
     uint Session_Index;           // The session number 
     datetime Time_Start;           // The session start time (seconds since midnight) 
     datetime Time_End;             // The session end time (seconds since midnight) 
  };

  struc_Session_Info        s_Session_Info[];


and fill it once and for all in an oninit or a constructor somewhere with a SymbolInfoSessionTrade() which will give me all the sessions on all the days of the symbol and presto
 

which gives for example for my s&p500 this
All that's left is to consult the structure to find out if I'm on the right schedule
and the value 100 is to indicate that the symbol is not available for the day

 
Gerard William G J B M Dinh Sy #:

which gives for example for my s&p500 this
All that's left is to consult the structure to find out if I'm on the right schedule
and the value 100 is to indicate that the symbol is not available for the day

nice 

where do you see this list btw ?


also how do you handle this ?


 
I don't understand your questions