This strategy combines the moving average indicator and Bollinger Bands to implement a strategy that oscillates between moving averages for two-way trading. Go long when the price breaks above the lower rail, go short when the price breaks below the upper rail, and profit from the oscillation between the moving averages.
Risk Management:
The above optimizations can further improve profitability, reduce unnecessary trades, lower trading frequency and loss risks.
This strategy combines moving average systems and Bollinger Bands to implement oscillation trading between price moving averages. The combination of dual indicators can improve signal quality, and allowing two-way trading provides more opportunities. Further optimizing parameters and adding other auxiliary indicators can reduce unnecessary trades and improve profitability, which is worth live testing and optimization.
]
/*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)