That is incorrect! SymbolInfoSessionTrade works for any symbol. That is why it has a parameter to identify the symbol...
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 );
That is incorrect! SymbolInfoSessionTrade works for any symbol. That is why it has a parameter to identify the symbol...
I changed the symbol name, but I am getting "false"
It works for me just for symbol in the chart
If I change the symbol in the chart like in parameter, it works
I don't know why
I tried some code I saw here, nothing help
here is example:
bool IsMarketOpen(const string symbol) { datetime from, to; datetime serverTime = TimeTradeServer(); MqlDateTime dt; TimeToStruct(serverTime,dt); const ENUM_DAY_OF_WEEK day_of_week = (ENUM_DAY_OF_WEEK) dt.day_of_week; const int time = (int) MathMod(serverTime,PeriodSeconds(PERIOD_D1)); int session = 0; while (SymbolInfoSessionQuote (symbol, day_of_week, session, from, to)) { if(time >=from && time <= to ) { return true; } session++; } return false; }
and another
bool isTradingDay(string symbol) { datetime time=TimeTradeServer(); MqlDateTime struct_time; // create MqlDateTime variable TimeToStruct(time, struct_time); // convert 'time' variable to a structure datetime fromTime; // dont need to be initialised datetime toTime; // dont need to be initialised return SymbolInfoSessionQuote(symbol, (ENUM_DAY_OF_WEEK)struct_time.day_of_week, 0, fromTime, toTime); } // NOTE: 0 session is the FIRST session for that day (i.e. if 0 = NO TRADING DAY) // Checks if market is currently open for specified symbol
Is the other symbol enabled and active in the Market Watch?
EDIT: Is there any error code when it is false?
Here is my test results with the following Script code ... (try running it on your end and report the results please).
string sSymbols[] = { "EURUSD", // Enabled on Market Watch "GBPUSD", // Disabled on Market Watch "EURGBP", // Enabled on Market Watch "USDJPY", // Disabled on Market Watch "XAUUSD", // Enabled on Market Watch "NotExist" // Non-existing symbol }; void OnStart( void ) { for( int i = 0; i < (int) sSymbols.Size(); i++ ) { datetime dtFrom = WRONG_VALUE, dtTo = WRONG_VALUE; ResetLastError(); if( SymbolInfoSessionQuote( sSymbols[i], TUESDAY, 0, dtFrom, dtTo ) ) Print( i, ") ", sSymbols[i], ": Tuesday from ", dtFrom, " to ", dtTo ); else Print( i, ") ", sSymbols[i], ": Error ", _LastError ); }; };
2023.11.20 21:24:00.783 Test (EURUSD,H1) 0) EURUSD: Tuesday from 1970.01.01 00:00:00 to 1970.01.01 23:59:00 2023.11.20 21:24:00.783 Test (EURUSD,H1) 1) GBPUSD: Tuesday from 1970.01.01 00:00:00 to 1970.01.01 23:59:00 2023.11.20 21:24:00.783 Test (EURUSD,H1) 2) EURGBP: Tuesday from 1970.01.01 00:00:00 to 1970.01.01 23:59:00 2023.11.20 21:24:00.783 Test (EURUSD,H1) 3) USDJPY: Tuesday from 1970.01.01 00:00:00 to 1970.01.01 23:59:00 2023.11.20 21:24:00.783 Test (EURUSD,H1) 4) XAUUSD: Tuesday from 1970.01.01 01:00:00 to 1970.01.01 23:55:00 2023.11.20 21:24:00.783 Test (EURUSD,H1) 5) NotExist: Error 4301
EDIT: Made a correction to include XAUUSD so you could see a different session time.
ERR_MARKET_UNKNOWN_SYMBOL
4301
Unknown symbol
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
SymbolInfoSessionTrade works only for the symbol of the current chart
How can I get info about other symbols?