Strategy vault / Trend following
Golden Cross Dead Cross Trading Strategy
This strategy generates trading signals based on the golden cross and dead cross of the 30-day, 60-day and 200-day simple moving averages. When the short-term moving average crosses over the long-term moving average…

Overview
This strategy generates trading signals based on the golden cross and dead cross of the 30-day, 60-day and 200-day simple moving averages. When the short-term moving average crosses over the long-term moving average, a buy signal is generated. When the short-term moving average crosses below the long-term moving average, a sell signal is generated. The strategy combines the advantages of trend following and moving average crossovers, capturing both long-term trends and turning points.
Strategy Logic
The strategy employs 3 simple moving averages with different timespans: 30-day, 60-day and 200-day. The 30-day line represents short-term trend, the 200-day line represents long-term trend, and the 60-day line serves as a reference. When the short-term trend line crosses over the long-term trend line, it indicates the market is shifting from consolidation to uptrend and generates a buy signal. When the short-term trend line crosses below the long-term trend line, it indicates the uptrend is shifting to consolidation and produces a sell signal.
The strategy also sets a 40-point stop-loss to control risks and a 40-point take-profit to lock in gains after entering a position.
Advantage Analysis
The advantages of this strategy include:
Combines the merits of trend following and instant signals, considering both long-term trends and short-term trading points.
Crossover signals are clear, avoiding excessive repeated signals.
Reasonable stop-loss and take-profit setups effectively control per trade loss.
Simple and clear logic, easy to understand and implement.
Mature and stable moving average techniques with widespread application.
Risk Analysis
Some risks also exist:
Short-term stop-loss may be penetrated, unable to completely avoid losses.
Golden cross and dead cross signals can turn out to be false breakouts.
Difficult to set reasonable stop-loss and take-profit during market consolidation.
Parameter selection like period settings contain subjectivity that may impact strategy performance.
Enhancement Directions
The strategy can be enhanced and optimized from the following aspects:
Improve stop-loss mechanisms using trailing stop loss, smoothed rate of change index etc. to lower risk exposure.
Optimize parameter selections by testing more periods and finding optimal period combinations.
Add position sizing rules to optimize overall profitability through capital management.
Filter out false breakouts incorporating momentum indicators.
Increase use of machine learning models and big data to find superior tactics.
Conclusion
In summary, this article introduces a trading strategy based on moving average golden crosses and death crosses. It takes the crossovers of 30-day, 60-day and 200-day moving averages as trading signals, combines trend following and timing selection. Reasonable stop-loss and take-profit setups effectively control per trade loss. But risks like whipsaws and false breakouts remain. We can enhance the strategy from multiple aspects like improving stop-loss methods, parameter optimization, capital management to make it more stable and profitable.
Source Pine Script
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Estrategia de Cruce de Medias Móviles", overlay=true)
// Medias móviles
ma30 = ta.sma(close, 30)
ma60 = ta.sma(close, 60)
ma200 = ta.sma(close, 200)
// Cruce de medias móviles
crossoverUp = ta.crossover(ma30, ma200)
crossoverDown = ta.crossunder(ma30, ma200)
// Señales de compra y venta
longCondition = crossoverUp
shortCondition = crossoverDown
// Ejecución de órdenes
if (longCondition)
strategy.entry("Buy", strategy.long)
strategy.exit("Cover", "Buy", stop=close - 40.000, limit=close + 40.000)
if (shortCondition)
strategy.entry("Sell", strategy.short)
strategy.exit("Cover", "Sell", stop=close + 40.000, limit=close - 40.000)
// Plot de las medias móviles
plot(ma30, color=color.blue, title="MA 30")
plot(ma60, color=color.orange, title="MA 60")
plot(ma200, color=color.green, title="MA 200")
// Condiciones para cerrar la posición contraria
if (strategy.position_size > 0)
if (crossoverDown)
strategy.close("Buy")
if (strategy.position_size < 0)
if (crossoverUp)
strategy.close("Sell")Published by ChaoZhang on the FMZ strategy square · last modified 2024-02-21. 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/Golden-Cross-Dead-Cross-Trading-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
- ADX MA and EMA Long Only Trend Tracking StrategyPine Script · Trend following · 1d
- ATR and Moving Average Crossover Hybrid StrategyPine Script · Trend following · 1h
- Adaptive FVG Detection and MA Trend Trading Strategy with Dynamic ResistancePine Script · Trend following · 1d
- Adaptive Risk Management Strategy Based on Dynamic ATR and Moving Average CrossoverPine Script · Trend following · 2h
- Adaptive Trading Strategy Based on Stochastic RSI Dual Line CrossoverPine Script · Trend following · 4h
- Adaptive Volatility Based Trend Following Short Strategy with Time Delay and Stop Loss ProtectionPine Script · Trend following · 2m