期货交易必备高级量化指标,带多空加减仓,信号过滤
发布时间:2025-1-17 11:44阅读:462
咱做期货量化交易的朋友,肯定都有过这样的苦恼。市场行情就像六月的天,说变就变。有时候,看着多空信号做交易,可这些信号乱七八糟的,假信号一堆,进去就被套,钱哗哗地往外流。而且啊,加仓减仓也没个靠谱的依据,加早了,成本拉高,后面行情突然反转,亏得更惨;减仓早了,又错过后面一大截利润。真的是左右为难,心里苦啊。
这个指标是这样工作的。它基于 MACD 指标来判断多空,不过不是简单地看 MACD 交叉,而是加入了一个过滤阈值 filter_threshold 。当 MACD 柱状图在零轴附近,并且满足特定的交叉条件,同时这个条件又经过过滤阈值筛选后,才会给出多空信号,这就大大减少了假信号。加仓条件呢,除了满足多空信号,还要求价格在 20 周期简单移动平均线之上(多头加仓)或之下(空头加仓),这样能保证加仓时趋势更稳定。减仓条件是价格在 10 周期简单移动平均线之下(多头减仓)或之上(空头减仓),帮助我们及时锁定利润。
你要是觉得这个指标对你有用,想在期货量化交易里更轻松地赚钱,那就加我微信,我把这个指标完整地发给你,还会教你怎么安装,怎么结合自己的交易策略来用,让你在期货市场里如鱼得水。
下面我给你分享一个能解决这些问题的指标源码案例,这个指标带多空加减仓,还能过滤信号,可实用了。
// 多空信号过滤
bullish_condition = macd_hist[1] < -filter_threshold and macd_hist > 0 and crossover(macd, macd_signal)
bearish_condition = macd_hist[1] > filter_threshold and macd_hist < 0 and crossunder(macd, macd_signal)
// 加仓条件
bullish_add_condition = bullish_condition and close > sma(close, 20)
bearish_add_condition = bearish_condition and close < sma(close, 20)
// 减仓条件
bullish_reduce_condition = bullish_condition and close < sma(close, 10)
bearish_reduce_condition = bearish_condition and close > sma(close, 10)
// 绘制信号
plotshape(bullish_condition, style=shape.labelup, location=location.belowbar, color=color.green, text="多")
plotshape(bearish_condition, style=shape.labeldown, location=location.abovebar, color=color.red, text="空")
plotshape(bullish_add_condition, style=shape.labelup, location=location.belowbar, color=color.lime, text="多加")
plotshape(bearish_add_condition, style=shape.labeldown, location=location.abovebar, color=color.maroon, text="空加")
plotshape(bullish_reduce_condition, style=shape.labeldown, location=location.belowbar, color=color.yellow, text="多减")
plotshape(bearish_reduce_condition, style=shape.labelup, location=location.abovebar, color=color.purple, text="空减")


温馨提示:投资有风险,选择需谨慎。