This script should open a trade under the following conditions
- SMA20 goes up
- Last closing falls under SMA20
- ADX is above 30
it shall use the highest high of the last 5 candels as take profit and the lowest low of the last 5 candles as stop loss.
But it leeps opening trades when SMA goes down...
bool openTrade = false
fiveCandleHigh = ta.highest (5) [1]
fiveCandleLow = ta.lowest(5)[1]
[_, _, adx] = ta.dmi(1, 1)
if close < ta.sma(close, 20) and ta.ema(close,20) > ta.ema(close,20)[5] and adx > 30
openTrade := true
if (openTrade == true)
strategy.entry("LE", strategy.long)
strategy.exit("LE", from_entry = "LE", limit=fiveCandleHigh, stop=fiveCandleLow)