Death Cross Based on BTC 20W
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © OrionAlgo

//@version=5
strategy("Death Cross Based on BTC 20W", overlay=true)

// Define the length for SMA
p = 140 //20 week

// Request the 200-day SMA of BTC
btcSMA = request.security("BINANCE:BTCUSDT", "D", ta.sma(close, p))
btcClose = request.security("BINANCE:BTCUSDT", "D", close)

ticker50 = request.security(syminfo.tickerid, "D", ta.sma(close, 50))
ticker200 = request.security(syminfo.tickerid, "D", ta.sma(close, 200))

plot(close, color= (btcClose > btcSMA and ticker50<ticker200) ? color.rgb(76, 175, 79, 50) : na, style = plot.style_area )
plot(close, color= (btcClose < btcSMA ) ? color.rgb(175, 76, 76, 50) : na, style = plot.style_area )

longCondition = (btcClose > btcSMA and ticker50<ticker200)
if (longCondition)
    strategy.entry("My Long Entry Id", strategy.long)

shortCondition = btcClose < btcSMA
if (shortCondition)
    strategy.entry("My Short Entry Id", strategy.short)
