🔓 Get All Tools for FREE!

  • ✅ Click here to open a trading account using our referral link and start trading.
  • 📅 After 7 days of active trading under our referral link, you can get access to all tools in your account.
  • ⚠️ Keep trading to keep access free — if you're inactive for 7 days, your access will be removed.
  • 👉 Already have an account? You can change the IB (introducing broker) to our referral link ( https://one.exnesstrack.org/a/w7syl3vnjb ) and still qualify!

Golden Cross and Death Cross Strategy [algo_aakash] | Full Code Inside

The Golden Cross and Death Cross are momentum-based signals traders use to identify trend reversals. This article explains how to implement these crosses in Pine Script with automated entries, exits, and risk management rules. Below you’ll find a ready-to-use strategy for TradingView.

Understanding Market Signals

🔓 Get All Tools for FREE!

  • ✅ Click here to open a trading account using our referral link and start trading.
  • 📅 After 7 days of active trading under our referral link, you can get access to all tools in your account.
  • ⚠️ Keep trading to keep access free — if you're inactive for 7 days, your access will be removed.
  • 👉 Already have an account? You can change the IB (introducing broker) to our referral link ( https://one.exnesstrack.org/a/w7syl3vnjb ) and still qualify!

A Golden Cross occurs when a 50-period SMA crosses above a 200-period SMA, signaling bullish momentum. Conversely, a Death Cross happens when the 50-period SMA drops below the 200-period SMA, indicating bearish sentiment. These crosses work best on daily or weekly timeframes to filter market noise.

Strategy Implementation Logic

This strategy includes:

  • Entry on cross confirmation (next candle open)
  • 1.5:1 Risk-Reward Ratio with 1% stop loss and 1.5% take profit
  • Automatic position closing on opposite signals
  • Visual plot of SMAs and crossover markers

The code avoids repainting by executing trades only after cross confirmation.

Backtesting Considerations

While historically effective in trending markets, this strategy may underperform during choppy price action. Always test across multiple assets and time periods. Customize SMA lengths and risk parameters according to your trading style.

Ready to automate cross-based trading? The Pine Script code below implements this strategy with clear visual cues and disciplined risk controls. Remember to validate its performance against your specific market conditions.

//@version=5
strategy("Golden Cross and Death Cross Strategy [algo_aakash] | Full Code Inside", overlay=true)
// Author: algo_aakash

// Input parameters
fastLen = input.int(50, "Fast SMA Length")
slowLen = input.int(200, "Slow SMA Length")
slPct = input.float(1.0, "Stop Loss %")/100
tpPct = input.float(1.5, "Take Profit %")/100

// Calculate SMAs
fastSMA = ta.sma(close, fastLen)
slowSMA = ta.sma(close, slowLen)
plot(fastSMA, "Fast SMA", color=color.blue)
plot(slowSMA, "Slow SMA", color=color.red)

// Crossover conditions
goldenCross = ta.crossover(fastSMA, slowSMA)
deathCross = ta.crossunder(fastSMA, slowSMA)

// Execute trades
if (goldenCross)
    strategy.entry("Long", strategy.long)
    strategy.exit("XL", "Long", stop=close*(1 - slPct), limit=close*(1 + tpPct))

if (deathCross)
    strategy.entry("Short", strategy.short)
    strategy.exit("XS", "Short", stop=close*(1 + slPct), limit=close*(1 - tpPct))

// Plot signals
plotshape(goldenCross, "GC", shape.triangleup, location.belowbar, color.green, size=size.small)
plotshape(deathCross, "DC", shape.triangledown, location.abovebar, color.red, size=size.small)

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *