本策略通过Awesome Oscillator(AO)指标判断趋势方向,并结合移动平均线进行趋势确认,属于趋势跟踪策略。当AO指标上穿0轴线并且快速线上穿慢速线时做多,当AO指标下穿0轴线并且快速线下穿慢速线时做空,利用趋势的方向性来获利。
本策略主要基于AO指标来判断趋势方向。AO指标是根据}-{线的中点和5周期、34周期的简单移动平均线的差计算得到的,属于 Momentum 类别指标。当 AO 指标为正时,代表着短期移动平均线高于长期移动平均线,Should be interpreted as a bullish sign. 反之当 AO 为负时,代表着短期移动平均线低于长期移动平均线,Should be interpreted as a bearish sign。
所以,AO 指标可以有效地判断趋势的方向。当 AO 上穿 0 轴线时,代表着市场趋势转为看涨,应该做多;当 AO 下穿 0 轴线时,代表着市场趋势转为看跌,应该做空。
另外,本策略还加入了 20 周期和 200 周期的移动平均线。这两个均线的角度代表着中长期趋势的方向。仅仅依靠 AO 指标来判断短期趋势方向还不够,还需要中长期趋势的确认,所以加入了移动平均线的判断。
当快速均线上穿慢速均线,中长期趋势转为看涨时,我们在 AO 上穿 0 轴线的时候做多,随着趋势走高来获利;当快速均线下穿慢速均线,中长期趋势转为看跌时,我们在 AO 下穿 0 轴线的时候做空,随着趋势走低获利。
本策略属于简单的趋势跟踪策略,通过 AO 指标判断短期趋势且中长期趋势确认的思路是正确的。AO 指标和移动平均线的组合使用广泛,较为成熟,本策略也具有很强的可靠性。通过进一步参数优化和组合指标优化,可以使本策略的效果更加出色。
/*backtest
start: 2023-12-12 00:00:00
end: 2023-12-14 20:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// https://www.youtube.com/watch?v=zr3AVwjCtDA
//@version=5
strategy(title="Bingx ESTRATEGIA de Trading en 1 minuto ", shorttitle="AO")
long = input.bool(true, "long")
short = input.bool(true, "short")
profit = (input.float(10, "profit") / 100) + 1
stop = (input.float(5, "stop") / 100) + 1
ao = ta.sma(hl2,5) - ta.sma(hl2,34)
diff = ao - ao[1]
plot(ao, color = diff <= 0 ? #F44336 : #009688, style=plot.style_columns)
changeToGreen = ta.crossover(diff, 0)
changeToRed = ta.crossunder(diff, 0)
alertcondition(changeToGreen, title = "AO color changed to green", message = "Awesome Oscillator's color has changed to green")
alertcondition(changeToRed, title = "AO color changed to red", message = "Awesome Oscillator's color has changed to red")
ema20 = ta.ema(close, 20)
ema200 = ta.ema(close, 200)
rsi = ta.rsi(close, 7)
plot(rsi)
plot(0, color=color.white)
var float pentry = 0.0
var float lentry = 0.0
var bool oab = false
// oab := ta.crossover(ao, 0) ? true : ta.crossover(0, ao) ? false : oab[1]
if long and close > open and ta.crossover(close, ema20) and ema20 > ema200 and ao > 0 and rsi > 50
strategy.entry("long", strategy.long)
pentry := close
strategy.exit("exit long", "long", limit=pentry * profit, stop=pentry / stop)
if short and close < open and ta.crossunder(close, ema20) and ema20 < ema200 and ao < 0 and rsi < 50
strategy.entry("short", strategy.short)
lentry := close
strategy.exit("exit short", "short", limit=lentry / profit, stop=lentry * stop)