The goal here is two-fold:
a) to get the algo to successfully calculate pivot points, resistances, and supports - based off of high, low, and close data from the previous day.
b) record that pivot point value on a chart.
Can anyone help?
import numpy, datetime, pytz
def initialize(context):
context.aapl = sid(24)
def handle_data(context, data):
return history(2,"1d","close_price")
print history(2,"1d","close_price")
prev_close_list = history(bar_count=1, frequency='1d', field='close_price')
prev_high_list = history(bar_count=1, frequency='1d', field='high')
prev_low_list = history(bar_count=1, frequency='1d', field='low')
prve_close = prev_close_list[0]
prev_high = prev_high_list[0]
prev_low = prev_low_list[0]
pivot_point = (prev_close + prev_high + prev_low)/3
rr_i = 2 * pivot_point - prev_low
rr_ii = pivot_point + prev_high - prev_low
rr_iii = rr_ii + prev_high - prev_low
ss_i = 2 * pivot_point - prev_high
ss_ii = pivot_point - prev_high + prev_low
ss_iii = ss_ii - prev_high + prev_low
record(piv_pt = pivot_point)