Data Delay Issue with Multiple Pairs - Demo Account vs Live Account?

 

Hello everyone,

I hope you are all doing well.

I have been executing the following code to collect information from various currency pairs. However, I've noticed that the resulting data shows values with a 3-hour delay.

Could this delay be due to the fact that I am using a Demo account, or do I need to switch to a Live account to get real-time data?

# Login Parameters
login = 123456789
password = 'XXXXXXXXX'
server = 'MetaQuotes-Demo'

timeframe = mt5.TIMEFRAME_H1
start_date = datetime(2013, 1, 1)
end_date = datetime.now()

def fetch_mt5_data(login, password, server, symbol, timeframe, start_date, end_date):

    # Initialize connection to MetaTrader 5
    if not mt5.initialize(login=login, password=password, server=server):
        print("Initialization failed, error code =", mt5.last_error())
        return pd.DataFrame()  # Return an empty DataFrame in case of failure

    # Retrieve historical prices
    rates = mt5.copy_rates_range(symbol, timeframe, start_date, end_date)

    # Shutdown the connection with MT5
    mt5.shutdown()

    # Check if data was retrieved successfully
    if rates is None or len(rates) == 0:
        print("No data found.")
        return pd.DataFrame()

    # Convert the retrieved data into a DataFrame
    df = pd.DataFrame(rates)
    
    # Convert the timestamp to a readable format if the 'time' column exists
    if 'time' in df.columns:
        df['time'] = pd.to_datetime(df['time'], unit='s')
        df['time'] = df['time'].dt.strftime('%Y-%m-%d %H:%M:%S')  # Format the time
    
    return df

 
brunoropke: Could this delay be due to the fact that I am using a Demo account, or do I need to switch to a Live account to get real-time data?

On MT5: Unless the current chart is that specific pair/TF, you must synchronize the terminal Data from the Server before accessing candle/indicator values.
          Error 4806 while using CopyBuffer() - Expert Advisors and Automated Trading - MQL5 programming forum #10 (2020)
          Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum (2019)
          Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
          Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum #2 (2018)
          SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum (2019)

 
Everything makes sense now... Thank you sir