
该策略结合了移动平均线指标和布林带指标,实现了在均线之间进行双边交易的策略。当价格上破下轨时做多,当价格下破上轨时做空,利用价格在均线之间的振荡获利。
风险解决方法:
以上优化可以进一步提高获利率,减少不必要的交易,降低交易频率和亏损风险。
该策略结合均线系统和布林带指标,实现了在价格均线之间振荡交易的策略。双重指标结合可以提高信号质量,允许双边交易可以获得更多机会。通过进一步优化参数以及加入其他辅助指标判断,可以减少不必要交易和提高获利率,值得实盘检验和优化。
]
/*backtest
start: 2023-12-09 00:00:00
end: 2023-12-10 00:00:00
period: 2m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy("MA-Zorrillo",overlay=true)
ma_short= sma(close,8)
ma_long= sma(close,89)
entry_ma = crossover (ma_short,ma_long)
exit_ma = crossunder (ma_short,ma_long)
BBlength = input(24, minval=1,title="Bollinger Period Length")
BBmult = 2 // input(2.0, minval=0.001, maxval=50,title="Bollinger Bands Standard Deviation")
BBbasis = sma(close, BBlength)
BBdev = BBmult * stdev(close, BBlength)
BBupper = BBbasis + BBdev
BBlower = BBbasis - BBdev
source = close
entry_bb = crossover(source, BBlower)
exit_bb = crossunder(source, BBupper)
vs_entry = false
vs_exit = false
for i = 0 to 63
if (entry_bb[i])
vs_entry := true
if (exit_bb[i])
vs_exit := true
entry = entry_ma and vs_entry
exit = exit_ma and vs_exit
strategy.entry(id="long_ma",long=true,when=entry)
strategy.close(id="long_ma", when=exit)
strategy.entry(id="short_ma",long=false,when=exit)
strategy.close(id="short_ma",when=entry)