StratCraft

简单移动平均线 (SMA)

SMA 的 QuantNexus 指标页面。

Route: /quantnexus/indicators/sma/

作用

SMA 是最简单的移动平均线。它通过平均过去 n 次观察结果来平滑价格。

公式

SMA = (P1 + P2 + ... + Pn) / n

参数

  • period - 默认 30

C++23 API

#include <nonabt/indicators/sma.hpp>
auto sma = std::make_unique<nonabt::SMA>(data().close(), 30);

常见用法

  • 使用 SMA 作为基准趋势线。
  • 使用 SMA 交叉构建简单的趋势系统。
  • 使用 SMA 作为通道指标的中心线。

实际模式

SMA 比 EMA 慢,但在确认较长周期的趋势时通常更清晰。