
该策略综合利用双移动均线、布林带和MACD指标,设定买入和卖出条件,对银行Nifty指数进行5分钟周期的交易。当MACD金叉且收盘价突破布林带上轨时买入;当MACD死叉且收盘价跌破布林带下轨时卖出。该策略结合多种指标优势,既能发现趋势也能定位极值点,实现高效率交易。
以上便是该策略的整体交易逻辑。
这是一个非常实用的趋势策略,具有如下优势:
综上,该策略充分利用各种指标的优势,判断准确,操作规范,是一种可靠、可控的趋势策略。
尽管该策略优势明显,但仍存在一定的风险需要注意:
对策与解决方法如下:
该策略仍有优化空间:
总体来说,该策略具有非常好的框架,通过 Parameter优化、指标创新、自适应方式等进一步完善,可成为更加强大、稳定的交易策略。
该双均线布林带MACD策略充分利用各种指标判断买入卖出时机。它结合趋势识别与极值判断,操作规范,风险可控,是一种高效稳定的交易策略。通过持续优化和创新,该策略具有很大的应用前景。它为投资者在交易市场中实现稳定、可控的盈利提供了重要的技术工具。
/*backtest
start: 2023-11-28 00:00:00
end: 2023-12-28 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Modified MACD and Bollinger Band Strategy", shorttitle="Mod_MACD_BB", overlay=true)
var bool open_buy_position = na
var bool open_sell_position = na
// MACD settings
fast_length = input(12, title="Fast Length")
slow_length = input(26, title="Slow Length")
signal_length = input(9, title="Signal Length")
src = close
[macdLine, signalLine, _] = macd(src, fast_length, slow_length, signal_length)
// Bollinger Band settings
bb_length = input(20, title="Bollinger Band Length")
bb_mult = input(2, title="Bollinger Band Multiplier")
basis = sma(src, bb_length)
dev = bb_mult * stdev(src, bb_length)
upper_band = basis + dev
lower_band = basis - dev
// Define profit target and stop loss
profit_target = input(60, title="Profit Target (Points)")
stop_loss = input(30, title="Stop Loss (Points")
// Buy condition: MACD crosses up the signal line and close is above upper Bollinger Band
buy_condition = crossover(macdLine, signalLine) and close > upper_band
// Sell condition: MACD crosses below the signal line and close is below the lower Bollinger Band
sell_condition = crossunder(macdLine, signalLine) and close < lower_band
// Check for open positions
if (buy_condition)
open_buy_position := true
if (sell_condition)
open_sell_position := true
// Strategy Orders
strategy.entry("Buy", strategy.long, when = buy_condition and not open_sell_position)
strategy.exit("Take Profit/Stop Loss", from_entry = "Buy", limit = close + profit_target, stop = close - stop_loss)
strategy.entry("Sell", strategy.short, when = sell_condition and not open_buy_position)
strategy.exit("Take Profit/Stop Loss", from_entry = "Sell", limit = close - profit_target, stop = close + stop_loss)
// Reset open position status
if (sell_condition)
open_buy_position := na
if (buy_condition)
open_sell_position := na