Adaptative EMA
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © benjaminhay

//@version=5
indicator("Adaptative EMA", overlay = true)

averageData = input.source(close, title="Average Data Source")

dailyTimeframeFastEma = input.int(8, "D and higher fast EMA length")
dailyTimeframeSlowEma = input.int(21, "D and higher slow EMA length")

lowerTimeframeFastEma = input.int(21, "intraday fast EMA length")
lowerTimeframeSlowEma = input.int(50, "intraday slow EMA length")

fastAverage = ta.ema(averageData, 8)
slowAverage = ta.ema(averageData, 21)

if timeframe.isintraday
    fastAverage := ta.ema(averageData, lowerTimeframeFastEma)
    slowAverage := ta.ema(averageData, lowerTimeframeSlowEma)
else
    fastAverage := ta.ema(averageData, dailyTimeframeFastEma)
    slowAverage := ta.ema(averageData, dailyTimeframeSlowEma)

plot(fastAverage, color=color.aqua, title="Fast EMA", linewidth=2)
plot(slowAverage, color=color.fuchsia, title="Slow EMA", linewidth=2)

