0bps

Strategy vault / Mean reversion

Multi Indicator Bitcoin Daily Trading Strategy

This strategy combines multiple indicators to identify trading opportunities within the daily time frame for Bitcoin. It mainly uses indicators like MACD, RSI, Stoch RSI, together with the direction of moving average…

Author
ChaoZhang
Complexity
Intermediate · 85 lines
Parameters
19
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

IMG

Overview

This strategy combines multiple indicators to identify trading opportunities within the daily time frame for Bitcoin. It mainly uses indicators like MACD, RSI, Stoch RSI, together with the direction of moving average to determine the current trend direction for generating buy and sell signals.

Strategy Logic

The strategy utilizes the following key indicators:

  1. MACD (Fast MA - Slow MA) and its signal line. MACD crossing above signal line gives buy signal, and crossing below 0 gives sell signal.

  2. RSI (Relative Strength Index). RSI crossing above a threshold gives buy signal.

  3. Stoch RSI. Stoch RSI shows overbought/oversold levels of RSI. Stoch RSI below threshold gives buy signal, while above threshold gives sell signal.

  4. Moving average direction. Close price crossing below MA gives sell signal.

According to these indicators, the trading signals are:

Buy Signal: When (Stoch RSI < Threshold) AND (MACD crossing above threshold OR RSI crossing above threshold)

Sell Signal: When (MACD crossing below 0) AND (Close below MA OR Stoch RSI > Threshold)

Using multiple indicators together can better determine the current trend direction and identify trend reversal points for entering trades.

Advantages

  1. Combining multiple indicators improves accuracy and avoids false signals from a single indicator.

  2. MACD shows trend direction and strength. RSI reflects overbought/oversold levels. Stoch RSI determines overbought/oversold of RSI. MA shows trend direction. These indicators verify each other.

  3. The buy/sell signals require a combination of multiple indicators, filtering out some false signals and avoiding unnecessary trades.

  4. Backtest starts from 2017/1/1, covering the huge bull run of Bitcoin at 2017 year end. Tests strategy performance in a real bull market.

  5. Stop loss is set to control loss in single trades.

Risks

  1. Although using multiple indicators improves accuracy, discrepancy between them can still lead to some wrong signals.

  2. The optimized stop loss level may need adjustments for different market situations. Stop loss too wide increases loss in single trades, while too tight may get stopped out prematurely.

  3. Daily timeframe prevents detailed operations in shorter time ranges. Unable to respond to sudden short-term big moves.

  4. Strategy is only backtested on limited historical data. Overfit risk exists. Requires further testing across longer timeframe and more markets.

Enhancement Opportunities

  1. Test more indicator combinations to find optimal multi-indicator strategies.

  2. Optimize parameters of the indicators for better values.

  3. Test different stop loss levels to find optimal risk/reward ratio.

  4. Conduct backtests across longer historical data to avoid overfitting.

  5. Explore applying strategy logic in higher frequency timeframes for more frequent trading.

Conclusion

This strategy combines MACD, RSI, Stoch RSI and other indicators to determine the bitcoin daily trend direction and identify trend reversals for trade entry. Stop loss is set to control trade risk. Backtest shows positive results but still requires further verification across longer timeframe and more markets to avoid overfit risks. Further optimizations on indicator parameters and stop loss/take profit levels can improve results. The strategy provides an initial idea of multi-indicator combination approach which is worth deeper exploration and enhancement.

Parameters

NameDefaultWhat it controls
v_input_12017Backtest Start Year
v_input_2trueBacktest Start Month
v_input_3trueBacktest Start Day
v_input_42019Backtest Stop Year
v_input_512Backtest Stop Month
v_input_631Backtest Stop Day
v_input_730rsi_threshold
v_input_84rsi_length
v_input_98srsi_length
v_input_104srsi_smooth
v_input_1157srsi_sell_threshold
v_input_1214length
v_input_13-1dma_signal_threshold
v_input_1411fastLength
v_input_1518slowlength
v_input_166MACDLength
v_input_17-2MACD_signal_threshold
v_input_185short_loss_tol
v_input_195long_loss_tol

Source Pine Script

/*backtest
start: 2022-10-23 00:00:00
end: 2023-10-29 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
// Original code is from CredibleHulk and modified by bennef
strategy("BTC Daily Strategy BF", overlay=false, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.075)

/////////////// Time Frame ///////////////
testStartYear = input(2017, "Backtest Start Year") 
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay, 0, 0)

testStopYear = input(2019, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(31, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay, 0, 0)

testPeriod() => true

/////////////// Input Params /////////////// 
rsi_threshold = input(30)
rsi_length = input(4)
srsi_length = input(8)
srsi_smooth = input(4)
srsi_sell_threshold = input(57)
length = input(14)
dma_signal_threshold = input(-1)
fastLength = input(11)
slowlength = input(18)
MACDLength = input(6)
MACD_signal_threshold = input(-2)
short_loss_tol = input(5)
long_loss_tol = input(5)

stop_level_long = strategy.position_avg_price * (1 - long_loss_tol / 100.0)
stop_level_short = strategy.position_avg_price * (1 + short_loss_tol / 100.0)
    
///////////////  Signal generation ///////////////
// MACD 
MACD = ema(close, fastLength) - ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
delta = MACD - aMACD

// RSI and Stochastic RSI 
rs = rsi(close, rsi_length)
k = sma(stoch(rs, rs, rs, srsi_length), srsi_smooth)

// SMA 
norm = sma(ohlc4, length)
threshold = close - norm   

/////////////// Strategy ///////////////
long = ((crossover(delta, MACD_signal_threshold) or crossover(rs, rsi_threshold)) and k < srsi_sell_threshold)
short = (crossunder(delta, 0) or (crossunder(threshold, dma_signal_threshold) and k > srsi_sell_threshold))

if testPeriod()
    strategy.entry("L", strategy.long, when = long)
    strategy.entry("S", strategy.short, when = short)
    strategy.exit("stop loss L", from_entry = "L", stop = stop_level_long)
    strategy.exit("stop loss S", from_entry = "S", stop = stop_level_short)

/////////////// Plotting ///////////////
// MACD
plot(delta, color = delta > MACD_signal_threshold ? color.lime : delta < 0 ? color.red : color.yellow)
MACD_signal_threshold_line = hline(MACD_signal_threshold, color = color.yellow, title = "MACD Signal Threshold")

// RSI
plot(rs, color = rs > rsi_threshold ? color.lime : color.fuchsia)
rsi_threshold_line = hline(rsi_threshold, color = color.fuchsia, title = "RSI Threshold")

// Stochastic RSI 
plot(k, color = k > srsi_sell_threshold ? color.lime : color.red)
srsi_sell_threshold_line = hline(srsi_sell_threshold, color = color.white, title = "Stoch RSI Threshold")

// SMA
plot(threshold / 100, color = threshold < dma_signal_threshold ? color.red : color.blue)
dma_signal_threshold_line = hline (dma_signal_threshold, color = color.blue, title = "DMA Signal Threshold")

bgcolor(long ? color.lime : short ? color.red : na, transp=50)

Published by ChaoZhang on the FMZ strategy square · last modified 2023-10-30. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Multi-Indicator-Bitcoin-Daily-Trading-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open