Strategy vault / Mean reversion
MACD Indicator Bottom Reversal Early Warning Strategy
The MACD Indicator Bottom Reversal Early Warning Strategy analyzes the fast and slow lines of the MACD indicator to determine whether the current price is at a historical high or low and whether a reversal will occur…

Overview
The MACD Indicator Bottom Reversal Early Warning Strategy analyzes the fast and slow lines of the MACD indicator to determine whether the current price is at a historical high or low and whether a reversal will occur soon, in order to quickly judge the trend of market prices.
Strategy Principle
This strategy screens and filters the fast line and slow line data corresponding to the output of the standard MACD indicator to judge whether the price has entered the critical area before reversal and issues buy or sell signals.
Specifically, the strategy judges whether the price has entered the bottom area of an uptrend or the top area of a downtrend by calculating the golden cross and death cross of the fast and slow lines of the MACD. On golden crosses, if the close price is higher than the close price of the previous bar and the diff is higher than the diff value of the previous bar, it is determined that the bottom area has been entered and a bottom reversal early warning signal is issued. On death crosses, if the close price is lower than the close price of the previous bar and the diff of the previous bar is higher than the current diff value, it is determined that the top area has been entered and a top reversal early warning signal is issued.
Advantage Analysis
- Use MACD indicator for accurate judgment of market trend
- Bottom and top reversal early warning can capture reversal opportunities in time
- Avoid unnecessary misreporting by combining fast and slow line relationships
- Alerts can be added for real-time monitoring of market changes
Risk Analysis
- The MACD indicator itself has lagging judgment and cannot determine the exact reversal point
- Need to adjust parameters appropriately to suit different trading varieties and time frames
- Unable to determine the specific reversal amplitude and trend after reversal
- Need to monitor changes in trading volume at the same time to determine the reliability of reversal
Solutions:
- Combine with other indicators such as K-line patterns and changes in trading volume for judgment
- Adjust parameters to suit different trading varieties and time frames
- Timely stop loss to control risks
Optimization Directions
- Optimize MACD indicator parameters for better judgment of bottoms and tops
- Increase stop loss logic to avoid loss enlargement
- Combine trading volume changes to determine reliability of reversals
- Increase machine learning model to determine probability of reversal
Conclusion
The MACD Indicator Bottom Reversal Early Warning Strategy can effectively discover bottoms and tops to provide guidance for trading decisions by analyzing MACD fast and slow line crosses to judge whether prices have entered the critical area before reversal. However, the lagging judgment of the MACD itself cannot determine the exact reversal point and reversal momentum. Therefore, appropriate parameter adjustments are needed, combined with other indicators, to control risks and leverage the effectiveness of this strategy. In the future, the introduction of machine learning techniques can further improve judgment accuracy.
Source Pine Script
/*backtest
start: 2023-11-06 00:00:00
end: 2023-12-06 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// ____ __ ___ ________ ___________ ___________ __ ____ ___
// / __ )/ / / | / ____/ //_/ ____/ |/_ __< / // / / __ |__ \
// / __ / / / /| |/ / / ,< / / / /| | / / / / // /_/ / / __/ /
// / /_/ / /___/ ___ / /___/ /| / /___/ ___ |/ / / /__ __/ /_/ / __/
// /_____/_____/_/ |_\____/_/ |_\____/_/ |_/_/ /_/ /_/ \____/____/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © blackcat1402
//@version=5
strategy("[blackcat] L2 Reversal Labels Strategy", overlay=true, max_bars_back=5000, max_labels_count=500)
[diff, dea, macd] = ta.macd(close,12, 26, 9)
a1 = ta.barssince(ta.crossover(diff,dea)[1])
a2 = ta.barssince(ta.crossunder(diff,dea)[1])
bottom_zone = (close[a1+1]>close) and (diff>diff[a1+1]) and ta.crossover(diff,dea)
top_zone = (close[a2+1]<close) and (diff[a2+1]>diff) and ta.crossunder(diff,dea)
// Plot labels
l0 = top_zone ? label.new(bar_index, high * 1.0, 'Near Top', color=color.new(color.red, 50), textcolor=color.white, style=label.style_label_down, yloc=yloc.price, size=size.small) : bottom_zone ? label.new(bar_index, low * 1.0, 'Near Bottom', color=color.new(color.green, 50), textcolor=color.white, style=label.style_label_up, yloc=yloc.price, size=size.small) : na
if bottom_zone
longmsg = 'Bottom Reversal Soon!'
alert(message=longmsg, freq=alert.freq_once_per_bar_close)
else if top_zone
shortmsg = 'Top Reversal Soon!'
alert(message=shortmsg, freq=alert.freq_once_per_bar_close)
longCondition = bottom_zone
if (longCondition)
strategy.entry("long", strategy.long)
shortCondition = top_zone
if (shortCondition)
strategy.entry("short", strategy.short)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-07. 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.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/MACD-Indicator-Bottom-Reversal-Early-Warning-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- 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
- 1 2 3 Pattern Quantitative Trading Strategy with EMAs MACD and 4th Candle ExtensionPine Script · Mean reversion · 1h
- 3 10 Oscillator Profile Flagging StrategyPine Script · Mean reversion · 1d
- ATR and EMA based Dynamic Take Profit and Stop Loss Adaptive StrategyPine Script · Mean reversion · 1h
- Advanced 15 Minute Chart Trading Signal StrategyPine Script · Mean reversion · 3h
- BONK Multi Factor Trading StrategyPine Script · Mean reversion · 1d
- Bearish Harami Reversal Backtest StrategyPine Script · Mean reversion · 15m