This strategy is a trend-following trading system based on the Bull Market Support Band. It primarily uses crossover signals between the 20-week Simple Moving Average (SMA) and 21-week Exponential Moving Average (EMA) to determine market trend direction and make trading decisions. The strategy generates long signals when the moving averages cross upward and exits when they cross downward, aiming to capture medium to long-term trend opportunities.
The core logic of the strategy is to monitor the relative position of the 20-week SMA and 21-week EMA to judge market trends. When the shorter-term average (20-week SMA) breaks above the longer-term average (21-week EMA), it indicates a potential uptrend, triggering a long position entry. When the shorter-term average falls below the longer-term average, it signals a potential end to the uptrend, triggering position closure. The strategy employs percent_of_equity position management, with a trading commission of 0.1% and slippage of 3 basis points.
The Bull Market Support Band trading strategy is a trend-following system based on classical technical analysis theory. It captures medium to long-term trend opportunities through weekly timeframe moving average crossovers, featuring clear logic and controllable risk. However, the strategy performs poorly in ranging markets and exhibits some lag. Through the addition of auxiliary indicators, stop-loss optimization, and improved capital management, the strategy has significant room for optimization. It is suitable for investors with substantial capital and risk tolerance.
/*backtest start: 2019-12-23 08:00:00 end: 2024-12-25 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This source code is subject to the terms of the Mozilla Public License 2.0 // © zkdev //@version=6 strategy(title='Demo GPT - Bull Market Support Band', overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1, slippage=3) // ------------------------------------------------------------------------- // Compile-time timestamp constants for default date range // (2018-01-01 00:00:00 UTC -> 1514764800000 // 2069-12-31 23:59:59 UTC -> 3155759999000) // ------------------------------------------------------------------------- const int defaultFromDate = 1514764800000 const int defaultToDate = 3155759999000 // ------------------------------------------------------------------------- // Inputs: date range // ------------------------------------------------------------------------- fromDate = input(title='Start Date', defval=defaultFromDate) toDate = input(title='End Date', defval=defaultToDate) // ------------------------------------------------------------------------- // Indicator settings & calculations // ------------------------------------------------------------------------- smaLength = 20 emaLength = 21 source = close sma = ta.sma(source, smaLength) ema = ta.ema(source, emaLength) // ------------------------------------------------------------------------- // Fetch weekly SMA & EMA // ------------------------------------------------------------------------- outSma = request.security(syminfo.tickerid, 'W', sma, gaps=barmerge.gaps_on, lookahead=barmerge.lookahead_off) outEma = request.security(syminfo.tickerid, 'W', ema, gaps=barmerge.gaps_on, lookahead=barmerge.lookahead_off) // ------------------------------------------------------------------------- // Plot visuals (20w SMA, 21w EMA, fill in between) // ------------------------------------------------------------------------- smaPlot = plot(outSma, color=color.new(color.red, 0), title='20w SMA') emaPlot = plot(outEma, color=color.new(color.green, 0), title='21w EMA') fill(smaPlot, emaPlot, color=color.new(color.orange, 75), fillgaps=true) // ------------------------------------------------------------------------- // We evaluate crossover/crossunder on *every bar* and store the result // ------------------------------------------------------------------------- crossUp = ta.crossover(outSma, outEma) crossDown = ta.crossunder(outSma, outEma) // ------------------------------------------------------------------------- // Trade logic: only operate within chosen date range // Buy when outSma crosses above outEma; Sell (close) when outSma crosses below outEma // ------------------------------------------------------------------------- inDateRange = true if inDateRange // If we have a crossUp event on this bar, buy (go Long) if crossUp strategy.entry('Long', strategy.long) // If we have a crossDown event on this bar, sell (close Long) if crossDown strategy.close('Long')