SMA (Simple Moving Average)
The SMA (Simple Moving Average) is a trend-following indicator that calculates the average of a selected range of prices, usually closing prices, by the number of periods in that range. It is a lagging indicator as it is based on past prices. SMAs are used to identify the direction of a trend and to smooth out price data to filter out noise. See also Exponential Moving Average (EMA) and Moving Average concept.
Arguments
| Name | Description |
|---|---|
period | number of candles |
Useful Signal Expressions
1. Golden Cross
Signal:
close().sma(50).crosses_above(close().sma(200))
Explanation: The 50-period SMA crosses above the 200-period SMA. This is a classic bullish signal known as a "Golden Cross".
2. Death Cross
Signal:
close().sma(50).crosses_below(close().sma(200))
Explanation: The 50-period SMA crosses below the 200-period SMA. This is a classic bearish signal known as a "Death Cross".
3. Price above SMA
Signal:
close().gt(close().sma(20))
Explanation: The closing price is above the 20-period SMA, indicating a short-term uptrend.
