震荡行情最明显的特征就是价格在固定区间内反复波动。我常用的解决方案是结合布林通道和RSI指标来判断震荡区间。这里分享一个简单有效的文华财经指标公式:
```
//文华财经简语言指标
UPPER:MA(CLOSE,20)+2*STD(CLOSE,20);
LOWER:MA(CLOSE,20)-2*STD(CLOSE,20);
RSI:100*(SMA(MAX(CLOSE-REF(CLOSE,1),0),14,1)/SMA(ABS(CLOSE-REF(CLOSE,1)),14,1));
```
当价格触及布林上轨且RSI超过70时准备做空,触及下轨且RSI低于30时准备做多。这个策略我在实盘中使用多年,效果很稳定。
对于想用Python做量化的朋友,可以试试这个震荡策略代码:
```python
# Python量化策略
def initialize(context):
context.bollinger_window = 20
context.rsi_window = 14
def handle_data(context, data):
prices = data.history(context.symbol, 'close', context.bollinger_window, '1d')
upper = prices.mean() + 2*prices.std()
lower = prices.mean() - 2*prices.std()
deltas = np.diff(prices[-context.rsi_window:])
avg_gain = np.mean(deltas[deltas > 0])
avg_loss = -np.mean(deltas[deltas < 0])
rsi = 100 - (100 / (1 + avg_gain/avg_loss))
if prices[-1] >= upper and rsi > 70:
order_target(context.symbol, -1)
elif prices[-1] <= lower and rsi < 30:
order_target(context.symbol, 1)
```
期货交易,最难的就是看清方向并执行下去。不过别担心,这一年,我通过不断优化,实盘验证了一套完善的高级多空量化指标系统,帮助我精准识别信号,避开了过去容易犯的错误。现在,这套系统已经非常成熟,可以分享给更多和我一样在市场努力的朋友。如果想更快找到交易方向,可以微信搜索关注"量化刘百万"公众号,里面有专业量化入门资料和优质策略分享,免费好用。
发布于13小时前 北京



分享
注册
1分钟入驻>
关注/提问
18342365994
秒答
搜索更多类似问题 >
电话咨询
+微信


