Retrieve 4-Hour Intraday Stock Data

The "fn_00991" function (internally called QM_GetIntradayDataFourHourDynamic) lets you pull 4-hour interval intraday stock data directly into Excel. It retrieves the data, handles sorting, and optionally limits the number of records displayed. This function is especially useful for traders or analysts who want to examine medium-term intraday trends without leaving Excel.

Why Use This Function?

  • Ideal for analyzing 4-hour price movements within the same trading day.
  • Enables sorting of returned data in ascending or descending order.
  • Lets you limit the number of records displayed for simpler analysis (or return all available by default).
  • Simplifies tracking of intraday patterns at multi-hour intervals without complex data scrapes.
  • Suitable for combining with other Excel calculations, charts, and trading strategies.

How to Use in Excel

QM_GetIntradayDataFourHourDynamic(Symbol, [RecordCount], [SortingOrder])

• Symbol is required.
• RecordCount is optional (default is 0, which returns all available records).
• SortingOrder is optional (default is "DESC").

Just type this function into a cell, specifying the parameters as shown. MarketXLS will retrieve the intraday data in 4-hour intervals and place the results in your Excel sheet below the cell containing the formula.

Parameters Explained

Parameter Description Example Values Notes
Symbol The ticker symbol of the security you want 4-hour data for. "AAPL", "TSLA" Must be a valid US market or supported security symbol.
RecordCount Number of 4-hour intervals to retrieve. 5, 10, 20 If set to 0 (the default), it returns all available data. If you specify 5, it returns only the latest 5 intervals (or fewer).
SortingOrder Sorting direction for the date column ("ASC" or "DESC"). "ASC", "DESC" "ASC" sorts from oldest to newest; "DESC" sorts from newest to oldest. Omit this parameter or use "DESC" for descending order.

Example Usage

Below are scenarios demonstrating how you might use this function in Excel:

Basic Examples

  1. Retrieve all available 4-hour data for AAPL, in descending order: • Formula:
    =QM_GetIntradayDataFourHourDynamic("AAPL")
    • Explanation:

    • Symbol is "AAPL".
    • RecordCount is omitted (so default is 0, meaning retrieve all data).
    • SortingOrder is omitted (so default is "DESC").
    • You will see rows of 4-hour data intervals, sorted from most recent to oldest.
  2. Retrieve only the latest 3 intervals of data for TSLA, in ascending order: • Formula:
    =QM_GetIntradayDataFourHourDynamic("TSLA", 3, "ASC")
    • Explanation:

    • Symbol is "TSLA".
    • RecordCount is 3, so only 3 intervals will appear.
    • SortingOrder is "ASC", which means the data will be listed starting from the earliest of the 3 intervals to the most recent.

Advanced Scenarios

• Combining with other Excel functions for charting:

  • After retrieving the 4-hour data, you can create a candlestick chart based on these rows. If you only need data for a certain number of intervals (e.g., last 8 intervals), set RecordCount=8 for a smaller dataset in your chart.

• Tracking partial-day data strategies:

  • Use "ASC" sorting to see how price and volume changed from the earliest 4-hour block to the latest, then apply Excel formulas (like AVERAGE or MAX) to quickly identify trends or price extremes.

• Preparing for multi-day intraday comparisons:

  • Even if more than one day’s data is returned, it will chunk the data into 4-hour increments. Sorting them in ascending order allows you to compare these blocks across multiple days easily.

Common Questions and Troubleshooting

  1. "Why do I see 'No Data Retrieved'?"

    • Possibly no intraday data is available for that symbol at the requested intervals, or the symbol is incorrect. Check your symbol and ensure it’s valid.
  2. "What if I see an error about licensing?"

    • MarketXLS checks that you have a valid license and correct data subscription. If these are not configured, you will see an error message. Go to MarketXLS settings to verify your subscription status.
  3. "How do I ensure the date/time columns convert properly in Excel?"

    • The function internally converts each time record to a datetime value. Double-check your cell formatting in Excel if you need a specific date/time format.
  4. "Is there a limit to how many intervals I can retrieve?"

    • If you do not specify RecordCount, the function attempts to return all available intervals. Be mindful that too much data may take extra time to appear. Setting a specific RecordCount can help.

By following these steps and examples, you’ll easily pull clean, sorted 4-hour intraday data into Excel for deeper analysis, charting, or integration into your trading strategies. This function is particularly helpful for traders or users who want to monitor price action without the complexity of requesting separate data sets multiple times.