Simple Moving Average (SMA) with MarketXLS

The Simple Moving Average (SMA) is a widely used technical indicator that smooths out price data by calculating an average price over a specified number of periods. With MarketXLS, you can quickly generate SMA values directly in Excel, allowing you to focus on analysis and decision-making without manually crunching data. Whether you are a day trader, swing trader, or long-term investor, this function offers a versatile way to interpret market trends.

Why Use This Function?

  • Provides a straightforward measure of average price over a chosen time period.
  • Helps identify bullish and bearish trends by smoothing short-term fluctuations.
  • Assists in generating entry/exit signals for various trading strategies.
  • Ideal for comparing different stocks or assets on the same timescale.
  • Supports automated workflows in Excel without additional scripting or backend services.
  • Useful in many real-world scenarios, including daily price tracking, historical analysis, or backtesting a trading system.

How to Use in Excel

SMA1()
  1. Select or provide a data range in Excel containing at least 15 data points in a single column (or up to four columns if using MultiMode in MarketXLS).
  2. Enter the formula =SMA1() in a cell.
    • If you have configured “MultiMode” in MarketXLS, the function automatically uses the fourth column of your chosen OHLC range.
    • If “UseDefaultValuesforTech” is enabled, it will use a default time period (30 by default). Otherwise, you will be prompted to enter a custom time period.
  3. Press Enter. The SMA values will appear based on your selection and specified time period.

Parameters Explained

Although the function appears as SMA1() with no direct parameters in your worksheet, internally it handles:

Parameter Description Example Values Notes
Data Range The user-selected Excel range containing the price data (or the 4th column if MultiMode is on). A1:A100 (single column), A1:D100 (for OHLC) Must contain at least 15 rows of data; otherwise, you may receive an error or warning.
Time Period The number of periods over which to calculate the moving average. 30, 14, 50 Defaults to 30 if “UseDefaultValuesforTech” is enabled; a dialog box prompts input otherwise.

Note: If you are using “MultiMode,” the 4th column (e.g., Close prices in OHLC data) is automatically selected for the SMA calculation.

Example Usage

Basic Examples

  1. Single-Column Data (Default Time Period)

    • In Excel, highlight a column of at least 15 closing prices.
    • Type “=SMA1()” in the next column.
    • Press Enter. The function calculates a 30-period SMA by default and returns the smoothed values.
  2. Single-Column Data (Custom Time Period)

    • Select a column with daily closing prices where you have at least 15 rows.
    • Type “=SMA1()” in a blank cell.
    • A prompt appears; enter “20” for a 20-day SMA.
    • The resulting column displays 20-day average values, helping you track intermediate trends.

Advanced Scenarios

  1. MultiMode ON with OHLC Data

    • In MarketXLS settings, enable “MultiMode” and define your OHLC data range (e.g., A1:D100).
    • The function will automatically use the 4th column (D1:D100) for SMA calculations.
    • Type “=SMA1()” in a separate cell to see the SMA based on that range’s closing prices.
  2. Integration with Other Excel Functions

    • Combine the output from SMA1() with additional market indicators (like RSI, Bollinger Bands, or custom macros).
    • Build condition-based formulas to highlight where the SMA crosses other trend lines and set up alert triggers.
  3. Strategy Backtesting

    • Use historical data to generate a range of SMAs with different periods (10, 30, 50, etc.).
    • Compare them to price charts or other technical indicators to refine your trading strategies.

Common Questions and Troubleshooting

  • “Selected data is very less, more appropriate data needed.”
    ? You must select at least 15 rows of data in Excel. Check that your chosen range meets the minimum requirement.

  • “Incorrect number of columns, try again.”
    ? The function works with either a single-column range or a four-column OHLC range in MultiMode. Ensure your selection matches one of these formats.

  • “No output or unexpected results.”
    ? Verify that you do not have empty cells or non-numeric data in the selected range. Also, confirm you input a time period if prompted.

  • “Prompt for time period did not appear.”
    ? You may have “UseDefaultValuesforTech” enabled in MarketXLS settings, which sets a default of 30. Disable this setting if you want to be prompted every time.

  • Values not aligning correctly with your original data
    ? Remember that the function internally reverses and re-reverses arrays to ensure correct alignment. Your final SMA output should match the sequence of your input data.

With these guidelines, you can confidently use SMA1() in Excel for real-time or historical market data. This local calculation requires no extra backend services—just MarketXLS and your spreadsheet. By smoothing price fluctuations, SMA1() simplifies the process of identifying probable market trends and optimizing trading decisions.

Get Access to 1 Billion Usable Market data points IN YOUR EXCEL SHEETS WITH EASY TO USE EXCEL FUNCTIONS

Get started today
MarketXLS Excel Add-in Tutorial - How to Use Sma and Other Financial Formulas
How does MarketXLS work?