Hi,
I'm new so please go easy :) I've copied this code from the sample talib alogs using the stochastic indicator:
# Iterate over our list of stocks
for stock in context.stocks:
current_position = context.portfolio.positions[stock].amount
slowk, slowd = talib.STOCH(hist['high'][stock],
hist['low'][stock],
hist['close'][stock],
fastk_period=5,
slowk_period=3,
slowk_matype=0,
slowd_period=3,
slowd_matype=0)
# get most recent SSI value
slowk = slowk[-1]
slowd = slowd[-1]
# If either the slowk or slowd are less than 20, the stock is
# 'oversold,' a long position is opened if there are no shares
# in the portfolio.
if slowk < 20 and current_position <= 0 and data.can_trade(stock):
order_target_percent(stock, context.long_pct_per_stock)
However, how can I call a previous day's value to compare to the current value? Thanks in advance!