Reputation: 5
I want to use the ema indicator that I put below as fixed. I want to set it as 1 day in any case. So period 1440 for 1 minute time frame = period 96 for 15 minute time frame is the same thing or period 48 for 30 minute time frame. How can I fix this?
indicator("EMA", "EMA", overlay=true)
length = input.int(1440, "Length")
lineColor = input.color(#000000, "Line-Color")
emaTop = ta.ema(input.source(high, "Top-Source"), length)
emaBot = ta.ema(input.source(low, "Bot-Source"), length)
fillColor = close < emaBot ? input.color(color.rgb(255, 0, 0, 67), "Fill-Color-Below") :
close > emaTop ? input.color(color.rgb(27, 255, 27, 67), "Fill-Color-Above") :
input.color(color.rgb(120, 123, 134, 67), "Fill-Color-Neutral")
pTop = plot(emaTop, color=lineColor)
pBot = plot(emaBot, color=lineColor)
fill(pTop, pBot, color=fillColor, fillgaps=true)
Upvotes: 0
Views: 48
Reputation: 178
This is my updated answer after taking a fresh look at your question.
You can find the length relative to 1 day using timeframe.in_seconds():
length = timeframe.in_seconds("1D") / timeframe.in_seconds()
Upvotes: 0