Type/to search

MACD and RSI Based Long Short Trading Strategy

Cryptocurrency
Created: 2023-10-09 15:33:17
Last modified: 3 years ago
1
Follow
1781
Followers

Overview

This strategy combines MACD and RSI indicators to implement long and short trading simultaneously, in order to obtain excess returns in unclear trend situations.

Strategy Logic

  1. Calculate fast EMA (12-day) and slow EMA (26-day)
  2. Calculate MACD convergence divergence (fast EMA minus slow EMA)
  3. Calculate 9-day moving average of MACD as signal line
  4. Calculate 14-day RSI
  5. Go long when MACD<-0.1, RSI<27 and fast EMA below slow EMA
  6. Go short when MACD>0.125, RSI>81 and fast EMA above slow EMA
  7. Use take profit, stop loss, trailing stop loss to manage positions

Advantage Analysis

  1. Going both long and short can generate excess returns in non-trending markets
  2. Combining trend indicator EMA and reversal indicator RSI improves signal quality
  3. Using trailing stop loss to lock in profits effectively controls loss risk

Risk Analysis

  1. Trading both ways requires more capital to support margin requirements
  2. Prices may hit stop loss on both long and short positions when reversing sharply
  3. Improper parameter settings may cause over-trading

Risk Solutions:

  1. Sufficient capital to support position sizing
  2. Reasonable stop loss distance to avoid over-crowded stops
  3. Optimize parameters to reduce trading frequency

Optimization Directions

  1. Consider combining volatility indicators to improve entry timing
  2. Test different parameter combinations to find optimum
  3. Optimize stop loss strategy based on market conditions, such as trailing stop loss
  4. Use machine learning algorithms to auto-optimize parameters

Summary

This strategy implements dual-directional trading with MACD and RSI combination. Using trailing stop loss to lock in profits can generate excess returns in non-trending markets. The strategy can be further optimized on parameters, stop loss strategies etc. to obtain more consistent excess returns.

Source
Pine
/*backtest
start: 2023-09-08 00:00:00
end: 2023-10-08 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
// Revision:        290
// Author:          @Hugo_Moriceau
//study("Moriceau_Crypto_strategies_Long_short_indicator_thesis",overlay=true)
Strategy parameters
Strategy parameters
Invert Trade Direction?
From Month
From Day
From Year
To Month
To Day
To Year
Take Profit
Stop Loss
Trailing Stop Loss
Trailing Stop Loss Offset
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)