Help on Symbol Info Properties

 

Hi

I am trying to get the Broker session times using symbol properties with below code. However I am getting compiler warnings.

Please let me know how to correct it. Documentation and search did not help much.

                // Variables for Symbol's other properties
                ENUM_SYMBOL_CALC_MODE  vCalcMode = SymbolInfoInteger(mSymbol,SYMBOL_TRADE_CALC_MODE);  // EURUSD = Forex        | XAUUSD = Forex
                ENUM_SYMBOL_SECTOR             vSector   = SymbolInfoString(mSymbol,SYMBOL_SECTOR_NAME);                               // EURUSD = Currency | XAUUSD = Commodities
                ENUM_SYMBOL_INDUSTRY   vIndustry = SymbolInfoString(mSymbol,SYMBOL_INDUSTRY_NAME);                     // EURUSD = None                 | XAUUSD = Precious Metal
                string vNameSVR  = AccountInfoString(ACCOUNT_SERVER);                                                                                                                                   // Get name of Broker's Server

implicit enum conversion        getFxSession.mqh        *47     37
implicit enum conversion        getFxSession.mqh        *48     35
implicit enum conversion        getFxSession.mqh        *49     36

regards

 
Good morning
Look over there
SymbolInfoSessionTrade - Market Info - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

Now I might as well tell you right away
The information from the broker is not always up to date and therefore the function does not return the correct result....
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 Willia G J B M Dinh Sy #:
Good morning
Look over there
SymbolInfoSessionTrade - Market Info - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

Now I might as well tell you right away
The information from the broker is not always up to date and therefore the function does not return the correct result....
@Gerard Willia G J B M Dinh Sy


Thanks a lot Gerard, so it is better I should not use them :)

 
Anil Varma # :
@Gerard Willia G J B M Dinh Sy


Thanks a lot Gerard, so it is better I should not use them :)

Good morning
That's not what I said, because perhaps only my broker did not provide the correct information for the return of this function.
Maybe yours is different

 
Gerard Willia G J B M Dinh Sy #:

Good morning
That's not what I said, because perhaps only my broker did not provide the correct information for the return of this function.
Maybe yours is different

I see, okay I will try to check if my Broker provide correct information or not. I have modified the code as below and it is working. Only problem I have now though I did set mNYCEnd as "23:59" it is returning value as "23:00" Hrs

//+-----------------------------------------------------------------------------------------------------------------------------+
//| METHOD:       CGetFxSession()
//+-----------------------------------------------------------------------------------------------------------------------------+
CGetFxSession::CGetFxSession(string pSymbol) {

                mSymbol          = pSymbol;
                cIsNewBar  = new CIsNewBar(mSymbol);

                // Variables for Symbol's other properties
                ENUM_SYMBOL_CALC_MODE calcMode = (ENUM_SYMBOL_CALC_MODE)SymbolInfoInteger(mSymbol,SYMBOL_TRADE_CALC_MODE);      // EURUSD = Forex        | XAUUSD = Forex
                ENUM_SYMBOL_SECTOR        sector         = (ENUM_SYMBOL_SECTOR)SymbolInfoInteger(mSymbol,SYMBOL_SECTOR);                                                        // EURUSD = Currency | XAUUSD = Commodities
                ENUM_SYMBOL_INDUSTRY  industry = (ENUM_SYMBOL_INDUSTRY)SymbolInfoInteger(mSymbol,SYMBOL_INDUSTRY);                                      // EURUSD = None                 | XAUUSD = Precious Metal
                string vNameSVR  = AccountInfoString(ACCOUNT_SERVER);                                                                   // Get name of Broker's Server

        string vMethod = (string)__FUNCTION__ + ":";
                PrintFormat("%s Broker's Server[%s] | for [%s] Calculation Mode[%s] sector[%s] industry[%s]",vMethod,vNameSVR,mSymbol,StringSubstr(EnumToString(calcMode),0),StringSubstr(EnumToString(sector),0),StringSubstr(EnumToString(industry),0));
        //+---------------------------------------------------------------------------------------------------------------------------+
        //| Broker [PepperStone]: Session Begin/End times are hard coded for given each session at initialization for Class
        //| Only symbols whoes calculation mode is 'Forex'
        //| Date is assigned as First Monday of back testing start. Only hh:mm will be used to actual session date.
        //+---------------------------------------------------------------------------------------------------------------------------+
                if(vNameSVR == "Pepperstone-Demo" && calcMode == SYMBOL_CALC_MODE_FOREX) {
                        // Market Forex e.g. Majors Currencies --> EURUSD, GBPUSD, USDJPY 
                        if(StringSubstr(EnumToString(sector),7) == "CURRENCY") {
                                mSYDBegin = "00:00";                                                    // Forex starts at Sunday 17:00 Hrs NYC Local time
                                mSYDEnd         = "09:59";                                                      // One minute before LON start time
                        }
                        // Market Commodities e.g. Precious Metal --> Gold --> XAUUSD, XAUEUR, XAUGBP
                        if(StringSubstr(EnumToString(sector),7) == "COMMODITIES" && StringSubstr(EnumToString(industry),9) == "COMMODITIES_PRECIOUS") {
                                mSYDBegin = "01:00";                                                    // Gold  starts at Sunday 18:00 Hrs NYC Local time (one hour later than Forex)
                                mSYDEnd         = "09:59";                                                      // One minute before LON start time
                        }
                        // London Forex session opens/ends at 08:00 Hrs/17:00 Hrs Local time from Mon to Fri through out the year (some week it change to 11:00 Hrs)
                        mLONBegin = "10:00";                                                            // London start hard coded at Monday 08:00 Hrs LON Local time
                        mLONEnd         = "19:00";                                                              // London session is 9 hours long
                        // New York Forex session opens/ends at 08:00 Hrs/17:00 Hrs Local time from Mon to Fri through out the year 
                        mNYCBegin = "15:00";                                                            // New York start hard coded at Monday 08:00 Hrs NYC Local time
                        mNYCEnd         = "23.59";                                                              // New York end         hard coded at Monday 17.00 Hrs NYC Local time (one minute earlier)
                }
        //+---------------------------------------------------------------------------------------------------------------------------+
                /*
                PrintFormat("%s SYD Begin[%s] End[%s] LON Begin[%s] End [%s] NYC Begin[%s] End[%s]",vMethod,TimeToString(mSYDBegin),TimeToString(mSYDEnd),TimeToString(mLONBegin),TimeToString(mLONEnd),TimeToString(mNYCBegin),TimeToString(mNYCEnd));
                Broker's Server[Pepperstone-Demo] | for [XAUUSD] vCalculationMode[SYMBOL_CALC_MODE_FOREX] sector[SECTOR_COMMODITIES] industry[INDUSTRY_COMMODITIES_PRECIOUS]
                SYD Begin[2017.01.02 01:00] End[2017.01.02 09:59] LON Begin[2017.01.02 10:00] End [2017.01.02 19:00] NYC Begin[2017.01.02 15:00] End[2017.01.02 23:59]
                */

} // End of constructor method CGetFxSession()
//+-----------------------------------------------------------------------------------------------------------------------------+
//| METHOD:       ~CGetFxSession()
//+-----------------------------------------------------------------------------------------------------------------------------+
CGetFxSession::~CGetFxSession(void) {

                delete cIsNewBar;

} // END Of deconstructor method ~CGetFxSession()
//+-----------------------------------------------------------------------------------------------------------------------------+
//| METHOD:       getFxSession()
//+-----------------------------------------------------------------------------------------------------------------------------+
void CGetFxSession::getFxSession(SFxSession     &pFxSession[][3],int count=21) {

                string vMethod = "[" + mSymbol + "] " + __FUNCTION__;

                ArrayFree(pFxSession);
                ArrayResize(pFxSession,count+1);

                for(int i = ArrayRange(pFxSession,0)-1; i >= 0 && !IsStopped(); i--) {
                        //PrintFormat("%s Size[%d] idx[%d]",vMethod,ArrayRange(pFxSession,0),i);
                        pFxSession[i][SYD].Begin = StringToTime(TimeToString(iTime(mSymbol,PERIOD_D1,i),TIME_DATE) + " " + mSYDBegin);
                        pFxSession[i][SYD].End   = StringToTime(TimeToString(iTime(mSymbol,PERIOD_D1,i),TIME_DATE) + " " + mSYDEnd);

                        pFxSession[i][LON].Begin = StringToTime(TimeToString(iTime(mSymbol,PERIOD_D1,i),TIME_DATE) + " " + mLONBegin);
                        pFxSession[i][LON].End   = StringToTime(TimeToString(iTime(mSymbol,PERIOD_D1,i),TIME_DATE) + " " + mLONEnd);

                        pFxSession[i][NYC].Begin = StringToTime(TimeToString(iTime(mSymbol,PERIOD_D1,i),TIME_DATE) + " " + mNYCBegin);
                        pFxSession[i][NYC].End   = StringToTime(TimeToString(iTime(mSymbol,PERIOD_D1,i),TIME_DATE) + " " + mNYCEnd);
                        PrintFormat("%s SDY Start[%s] End[%s] | LON Start[%s] End[%s] | NYC Start[%s] End[%s]",vMethod,t2s(pFxSession[i][SYD].Begin),t2s(pFxSession[i][SYD].End),t2s(pFxSession[i][LON].Begin),t2s(pFxSession[i][LON].End),t2s(pFxSession[i][NYC].Begin),t2s(pFxSession[i][NYC].End));
/*
[XAUUSD] CGetFxSession::getFxSession SDY Start[Thu, 2024.05.02 01:00] End[Thu, 2024.05.02 09:59] | LON Start[Thu, 2024.05.02 10:00] End[Thu, 2024.05.02 19:00] | NYC Start[Thu, 2024.05.02 15:00] End[Thu, 2024.05.02 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Fri, 2024.05.03 01:00] End[Fri, 2024.05.03 09:59] | LON Start[Fri, 2024.05.03 10:00] End[Fri, 2024.05.03 19:00] | NYC Start[Fri, 2024.05.03 15:00] End[Fri, 2024.05.03 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Mon, 2024.05.06 01:00] End[Mon, 2024.05.06 09:59] | LON Start[Mon, 2024.05.06 10:00] End[Mon, 2024.05.06 19:00] | NYC Start[Mon, 2024.05.06 15:00] End[Mon, 2024.05.06 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Tue, 2024.05.07 01:00] End[Tue, 2024.05.07 09:59] | LON Start[Tue, 2024.05.07 10:00] End[Tue, 2024.05.07 19:00] | NYC Start[Tue, 2024.05.07 15:00] End[Tue, 2024.05.07 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Wed, 2024.05.08 01:00] End[Wed, 2024.05.08 09:59] | LON Start[Wed, 2024.05.08 10:00] End[Wed, 2024.05.08 19:00] | NYC Start[Wed, 2024.05.08 15:00] End[Wed, 2024.05.08 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Thu, 2024.05.09 01:00] End[Thu, 2024.05.09 09:59] | LON Start[Thu, 2024.05.09 10:00] End[Thu, 2024.05.09 19:00] | NYC Start[Thu, 2024.05.09 15:00] End[Thu, 2024.05.09 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Fri, 2024.05.10 01:00] End[Fri, 2024.05.10 09:59] | LON Start[Fri, 2024.05.10 10:00] End[Fri, 2024.05.10 19:00] | NYC Start[Fri, 2024.05.10 15:00] End[Fri, 2024.05.10 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Mon, 2024.05.13 01:00] End[Mon, 2024.05.13 09:59] | LON Start[Mon, 2024.05.13 10:00] End[Mon, 2024.05.13 19:00] | NYC Start[Mon, 2024.05.13 15:00] End[Mon, 2024.05.13 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Tue, 2024.05.14 01:00] End[Tue, 2024.05.14 09:59] | LON Start[Tue, 2024.05.14 10:00] End[Tue, 2024.05.14 19:00] | NYC Start[Tue, 2024.05.14 15:00] End[Tue, 2024.05.14 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Wed, 2024.05.15 01:00] End[Wed, 2024.05.15 09:59] | LON Start[Wed, 2024.05.15 10:00] End[Wed, 2024.05.15 19:00] | NYC Start[Wed, 2024.05.15 15:00] End[Wed, 2024.05.15 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Thu, 2024.05.16 01:00] End[Thu, 2024.05.16 09:59] | LON Start[Thu, 2024.05.16 10:00] End[Thu, 2024.05.16 19:00] | NYC Start[Thu, 2024.05.16 15:00] End[Thu, 2024.05.16 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Fri, 2024.05.17 01:00] End[Fri, 2024.05.17 09:59] | LON Start[Fri, 2024.05.17 10:00] End[Fri, 2024.05.17 19:00] | NYC Start[Fri, 2024.05.17 15:00] End[Fri, 2024.05.17 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Mon, 2024.05.20 01:00] End[Mon, 2024.05.20 09:59] | LON Start[Mon, 2024.05.20 10:00] End[Mon, 2024.05.20 19:00] | NYC Start[Mon, 2024.05.20 15:00] End[Mon, 2024.05.20 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Tue, 2024.05.21 01:00] End[Tue, 2024.05.21 09:59] | LON Start[Tue, 2024.05.21 10:00] End[Tue, 2024.05.21 19:00] | NYC Start[Tue, 2024.05.21 15:00] End[Tue, 2024.05.21 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Wed, 2024.05.22 01:00] End[Wed, 2024.05.22 09:59] | LON Start[Wed, 2024.05.22 10:00] End[Wed, 2024.05.22 19:00] | NYC Start[Wed, 2024.05.22 15:00] End[Wed, 2024.05.22 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Thu, 2024.05.23 01:00] End[Thu, 2024.05.23 09:59] | LON Start[Thu, 2024.05.23 10:00] End[Thu, 2024.05.23 19:00] | NYC Start[Thu, 2024.05.23 15:00] End[Thu, 2024.05.23 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Fri, 2024.05.24 01:00] End[Fri, 2024.05.24 09:59] | LON Start[Fri, 2024.05.24 10:00] End[Fri, 2024.05.24 19:00] | NYC Start[Fri, 2024.05.24 15:00] End[Fri, 2024.05.24 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Mon, 2024.05.27 01:00] End[Mon, 2024.05.27 09:59] | LON Start[Mon, 2024.05.27 10:00] End[Mon, 2024.05.27 19:00] | NYC Start[Mon, 2024.05.27 15:00] End[Mon, 2024.05.27 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Tue, 2024.05.28 01:00] End[Tue, 2024.05.28 09:59] | LON Start[Tue, 2024.05.28 10:00] End[Tue, 2024.05.28 19:00] | NYC Start[Tue, 2024.05.28 15:00] End[Tue, 2024.05.28 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Wed, 2024.05.29 01:00] End[Wed, 2024.05.29 09:59] | LON Start[Wed, 2024.05.29 10:00] End[Wed, 2024.05.29 19:00] | NYC Start[Wed, 2024.05.29 15:00] End[Wed, 2024.05.29 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Thu, 2024.05.30 01:00] End[Thu, 2024.05.30 09:59] | LON Start[Thu, 2024.05.30 10:00] End[Thu, 2024.05.30 19:00] | NYC Start[Thu, 2024.05.30 15:00] End[Thu, 2024.05.30 23:00]
[XAUUSD] CGetFxSession::getFxSession SDY Start[Fri, 2024.05.31 01:00] End[Fri, 2024.05.31 09:59] | LON Start[Fri, 2024.05.31 10:00] End[Fri, 2024.05.31 19:00] | NYC Start[Fri, 2024.05.31 15:00] End[Fri, 2024.05.31 23:00]
*/
                }

} // END Of method getFxSession()
 

Hi

You have a mistake here:
 mNYCEnd         = "23.59";

There should be
 mNYCEnd         = "23:59";

A colon instead of dot, if you use even slightly wrong format for date and time the whole result might be very wrong.

Best Regards