MACD Long Only Strategy
Overview
This strategy is based on the MACD indicator and long and close lines to implement long-term trading of the currency pair. It opens positions when the MACD indicator line crosses over the long line and closes positions when the MACD indicator line crosses below the close line. Stop loss strategy is also configured.
Strategy Logic
The strategy uses fast and slow lines of the MACD indicator. The fast line has a parameter of 12-day EMA and the slow line has a parameter of 26-day EMA. The difference between the two lines is the MACD histogram. In addition, 9-day EMA is calculated as the signal line. It goes long when the MACD histogram crosses above 0.04 and closes long positions when crossing below 0.015. Also, 5% stop loss is set.
Specifically, the strategy first calculates the fast line, slow line and signal line of the MACD indicator. Then the long line is set at -0.04, the close line is set at 0.015. If the current MACD histogram is greater than the long line, it goes long. If the current MACD histogram is less than the close line, it closes the long position. In addition, the stop loss line is set at 95% of the entry price.
Advantage Analysis
The strategy has the following advantages:
- Use MACD indicator to judge market trend with high accuracy
- Double filter with long and close lines avoids wrong signals
- Stop loss strategy effectively controls risks
- Simple and clear logic, easy to understand and implement
- Only needs and MACD indicator, less resource occupation
Risk Analysis
The strategy also has some risks:
- MACD indicator has some lagging, may miss short-term opportunities
- Stop loss setting may be too conservative to keep tracking long term trends
- Parameter tuning needs lots of backtesting, otherwise overfitting may occur
- Only applicable to , effectiveness for other pairs is uncertain
Methods like adjusting parameters, combining other indicators can be used to optimize and improve.
Optimization Directions
The strategy can be optimized in the following aspects:
-
Test different MACD parameter combinations to find better parameters
Fast line, slow line, signal line with different lengths can be tried to find more suitable combinations
-
Try other indicators
Indicators like RSI, KD may have very different results
-
Optimize long and close line parameters
More suitable parameters can be found through repetitive backtesting
-
Adjust stop loss strategy
Consider trailing stops to make stop loss more dynamic
-
Test on different currency pairs
Apply the strategy to other pairs and examine the effects
Conclusion
In conclusion, this is an overall very simple and intuitive long term trading strategy. It judges market conditions using MACD indicator and sets double filter criteria to reduce false trading. Risk control is also configured through stop loss. The logic is clear and resource occupation is low. It is easy to understand and implement, worth recommending. Of course, there is still much room for improvement through parameter tuning, indicator change and other means, to make the strategy even more outstanding.
/*backtest
start: 2024-01-04 00:00:00
end: 2024-01-11 00:00:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy(shorttitle = "GBPJPY MACD", title = "GBPJPY MACD")
fastMA = input(title="Fast moving average", defval = 12, minval = 7)
slowMA = input(title="Slow moving average", defval = 26, minval = 7)- 1

