Simple Moving Average (SMA)
Description
The Simple Moving Average (SMA) is a technical indicator used in financial analysis. It calculates the average price of an asset (usually based on closing prices) over a specified period of time. SMA smooths out price volatility, making it easier to identify trends. It helps traders and investors assess whether an asset is in an uptrend or downtrend.
How It Works
To compute the SMA, add up the closing prices for a given number of time periods (e.g., days) and then divide this total by the same number of periods.
Formula
//Aggregation 1 Day;
int periodMovingAverage = 14; //simple moving average for 14 days
double[] closePrices = new double[] { 22.0, 24.0, 25.0, 23.0, 26.0, 28.0, 26.0, 29.0, 27.0, 28.0, 30.0, 27.0, 29.0, 28.0 };
double totalPeriod = closePrices.Sum() / periodMovingAverage;
Chart Settings
* For common indicator properties please see Common Indicator Settings
"Period Moving Average"
double totalPeriod = (Aggregation * PeriodMovingAverage);
double totalPeriod = (1M * 14);
double totalPeriod = 14M;
Watchlist Settings
* For common indicator properties please see Common Indicator Settings
"Period Moving Average"
Chart View
Last modified: 27 November 2024