I'm trying to figure out if it's possible to do something with an existing pine script.
Using the 15 minute chart, I want the buy/sell signals to generate only when the 4 hour RSI is above 45 and the 8 hour RSI is below 60.
Is this possible?
Thanks in advance for any help :)
study(title="8EMA", shorttitle="8EMA", overlay = true)
EMA1 = input(8, minval=1, title="EMA1")
EMA2 = input(13, minval=1, title="EMA2"),
EMA3 = input(21, minval=1, title="EMA3")
EMA4 = input(34, minval=1, title="EMA4"),
EMA5 = input(55, minval=1, title="EMA5")
EMA6 = input(89, minval=1, title="EMA6")
EMA7 = input(144, minval=1, title="EMA7")
EMA8 = input(233, minval=1, title="EMA8")
plot(ema(close, EMA1), color=green, linewidth=2)
plot(ema(close, EMA2), color=white, linewidth=2)
plot(ema(close, EMA3), color=gray, linewidth=2)
plot(ema(close, EMA4), color=blue, linewidth=2)
plot(ema(close, EMA5), color=red, linewidth=2)
plot(ema(close, EMA6), color=orange, linewidth=2)
plot(ema(close, EMA7), color=yellow, linewidth=2)
plot(ema(close, EMA8), color=purple, linewidth=2)
leftBars = input(4)
rightBars = input(2)
swh = pivothigh(leftBars, rightBars)
swl = pivotlow(leftBars, rightBars)
swh_cond = not na(swh)
hprice = 0.0
hprice := swh_cond ? swh : hprice[1]
le = false
le := swh_cond ? true : (le[1] and high > hprice ? false : le[1])
swl_cond = not na(swl)
lprice = 0.0
lprice := swl_cond ? swl : lprice[1]
se = false
se := swl_cond ? true : (se[1] and low < lprice ? false : se[1])
// Filter out signals if opposite signal is also on
se_filtered = se and not le
le_filtered = le and not se
// Filter consecutive entries
prev = 0
prev := se_filtered ? 1 : le_filtered ? -1 : prev[1]
se_final = se_filtered and prev[1] == -1
le_final = le_filtered and prev[1] == 1
plotshape(se_final, color=green, text = "BUY", style=shape.triangleup,location=location.belowbar)
plotshape(le_final, color=red, text = "SELL", style=shape.triangledown,location=location.abovebar)
alertcondition(se_final, "BUY-Autoview", "")
alertcondition(le_final, "SELL-Autoview", "")```
You can request data from other timeframes using the security() function.