How do I use different time frames in a strategy?
If you want to use a higher timeframe in your strategy, you have to use the resize() function.
This can be done in 2 ways:
Resize a close and use this to calculate the ema This will update every candle
close1H = resize(close, "1H")
ema1H = ema(close1H,21)
Resize an entire function This will only update every resized candle
res = resInput("MTF", "1D", ["4H", "6H", "12H", "1D", "1W"])
def std = resize(res)
{ stdev(close, ma_len)
}
An example can be found in the public library. Click here for the link.