Hello Folks....newbie question here
RE: Using variable other than prices for first variable of RSI
Function:
rsi = talib.RSI(variable other than prices, timeperiod=14)
RSI=rsi[-1]
I'm having some trouble using the talib rsi function. Rather than using 'prices' as my first variable.....I would like to use another variable. For purposes of illustration lets say I'm using the high of one security less the low of a second security as my RSI variable.
I am using this to grab data:
Grab 2 stocks
context.stock1 = symbol('AMZN')
context.stock2 = symbol('FSLR')
context.stocks = [context.stock1, context.stock2]
For notational convenience
s1 = context.stock1
s2 = context.stock2
prices = data.history([s1, s2], "price", context.long_ma_length, '1d')
short_prices = prices.iloc[-context.short_ma_length:]
My problem is if I use A (below) as my variable...RSI will not compute since its looking for 14 days of data ? If so, then I need to setup an array with each days data manipulation ?
A. Hi_Low_spread = ((short_prices[s1]-x)/y) - ((short_prices[s2])-x/y)
I can't use B (below) price history because prices are an array and I need to do 'daily' data manipulation
B. Hi_Low_spread = ((prices[s1]-x)/y) - ((prices[s2])-x/y)
The above is more concpetual than actual since I'm not showing the data capture of highs and lows.....but I hope I've illustrated my dilemma