Search code examples
pine-scripttradingview-apirsi

Is it possible to make my indicator run on 30 second chart when I am using the 1 minute?


I'm trying to have my indicator show me the values from the 30 second chart while I am using the 1 minute chart. Is this possible?

indicator("Double RSI", timeframe="")
lengthRSIfast = input.int(2, minval=1,title="RSI Fast")
lengthRSIslow = input.int(14, minval=1,title="RSI Slow")
overSold =  10 
overBought = 90 
src = input(close, title="Source")
rsifast = ta.rsi(src, lengthRSIfast)
rsislow = ta.rsi(src, lengthRSIslow)

plot(rsifast,color=color.green)
plot(rsislow,color=color.red)

signal = ta.cross(rsifast,rsislow)?rsislow:na
signalcolor= rsifast>rsislow?color.green:color.red
plot(signal,color=signalcolor,style=plot.style_circles,linewidth=2)
os=hline(overSold)
ob=hline(overBought)

alertcondition(signal, title="DubRSi cross")

Solution

  • No, it is not possible. It is possible to request data from the lower timeframe, however, it is not recommended because some data will be lost.

    security function was designed to request data of a timeframe higher than the current chart timeframe. On a 60 minutes chart, this would mean requesting 240, D, W, or any higher timeframe.

    It is not recommended to request data of a timeframe lower that the current chart timeframe, for example 1 minute data from a 5 minutes chart. The main problem with such a case is that some part of a 1 minute data will be inevitably lost, as it’s impossible to display it on a 5 minutes chart and not to break the time axis. In such cases the behavior of security can be rather unexpected.

    You can read this for more details.