Introduction
Automation Platform
Botmain DAO
Building Trading Strategies
API References Dev Live Stream
@botmain/indicators / Class

SimpleMovingAverage

The Simple Moving Average (SMA) is a widely utilized indicator in technical analysis, offering a smoothed-out price average over a specific time period. It's calculated by adding up the closing prices of the asset for a set number of time periods, then dividing this total by the number of time periods.

  • Simplicity and Clarity: The SMA provides a clear view of the price trend by dampening the noise of daily price fluctuations.
  • Trend Identification: It helps in identifying the direction of the trend. A rising SMA indicates an uptrend, while a declining SMA suggests a downtrend.
  • Support and Resistance: Often, the SMA can act as a support or resistance level for price movements.
  • Crossovers: Traders pay close attention to SMA crossovers. When a short-term SMA crosses above a long-term SMA, it may signal a buying opportunity, known as a "golden cross." Conversely, when the short-term SMA crosses below, it may suggest a selling point, termed a "death cross."

Constructor

No documentation has been provided.
Presentation
constructor(
	period: number
): SimpleMovingAverage;
Parameters
NameTypeDescription
period
number

The period of the SMA. The default is 14

Properties

NameTypeDescription
historyCapacity
inherited from BaseIndicator
number

The maximum history held by the indicator. As new data comes in only this many points are kept.

historyCount
inherited from BaseIndicator
number

The number of historical points currently held by the indicator. Will never be larger than historyCapacity.

last
inherited from BaseIndicator
T
values
inherited from BaseIndicator
T[]

Methods

add()

No documentation has been provided.
Presentation
add(price: number): void;
Parameters
NameTypeDescription
price
number

Adds the latest price point to the indicator. Normally called for each indicator in onBarClose()

Returns

void