Bollinger Bands
定义
public static IEnumerable<BollingerBandsResult> GetBollingerBands( int lookbackPeriods = 20, double standardDeviations = 2)
描述
Bollinger Bands的核心思想是:价格应该在特定统计规律定义的上下边界内波动,而边界本身会随着市场波动性的变化而动态调整。
参数
| 参数名 |
类型 |
描述 |
| lookbackPeriods |
Int |
回溯周期 |
| standardDeviations |
Int |
标准差倍数 |
返回值
| 返回值 |
类型 |
描述 |
| Date |
DateTime |
时间戳 |
| Sma |
decimal? |
简单移动平均线。 |
| UpperBand |
decimal? |
上轨 |
| LowerBand |
decimal? |
下轨 |
| PercentB |
decimal? |
百分比B |
| ZScore |
decimal? |
Z值。统计指标 |
| Width |
decimal? |
带宽 |
///清洗股票数据 天数据
QuoteHistoryDay(10, (dic) =>
{
if (dic.Count > 0)
{
foreach (var item in dic.Keys)
{
///获取指标结果
var resp = dic[item].GetBollingerBands(20,2);
Console.WriteLine(resp.ToJson());
}
}
});
# 创建布林带指标(20期,2个标准差)
self.bb = self.BB(stock_list[0].Symbol, 20, 2, MovingAverageType.Simple)
# 或者使用别名
# self.bb = self.BollingerBands(self.symbol, 20, 2)
# 设置布林带数据更新
self.RegisterIndicator(stock_list[0].Symbol, self.bb, Resolution.Daily)
current_price = 0
middle_band = self.bb.MiddleBand.Current.Value # 中轨(SMA)
upper_band = self.bb.UpperBand.Current.Value # 上轨
lower_band = self.bb.LowerBand.Current.Value # 下轨
bandwidth = self.bb.BandWidth.Current.Value # 带宽
percent_b = self.bb.PercentB.Current.Value # %B指标