8 Day Run - Momentum Strategy
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Marcuscor

//@version=5

// Inpsired by Linda Bradford Raschke: a strategy for trading momentum in futures markets

strategy("8D Run", initial_capital = 50000, commission_value = 0.0004) 


SMA = ta.sma(close,5)

TrendUp = close >= SMA

TrendDown = close <= SMA


//logic to long

TriggerBuy = ta.barssince(close < SMA) >= 8

Buy = TriggerBuy[1] and TrendDown 

strategy.entry("EL", strategy.long, when = Buy)
strategy.close(id = "EL", when = close > SMA)

// 1) color background when "run" begins and 2) change color when buy signal occurs
bgcolor(TriggerBuy? color.green : na, transp = 90)
bgcolor(Buy ? color.green : na, transp = 70)


// logic to short 

TriggerSell = ta.barssince(close > SMA) >= 8

Sell = TriggerSell[1] and TrendUp

strategy.entry("ES", strategy.short, when = Sell)
strategy.close(id = "ES", when = close < SMA)

// 1) color background when "run" begins and 2) change color when sell signal occurs
bgcolor(TriggerSell ? color.red : na, transp = 90)
bgcolor(Sell ? color.red : na, transp = 70) 





