How can i get the source code of Donchian Channel from quantopian!
How can i get the source code of Donchian Channel from quantopian!
Donchian Channel plots the highest high and the lowest low over the last period time interval.
Try this:
# Donchian Channel indicator
# -------------------------------
stock, period = symbol('SPY'), 21
# -------------------------------
def initialize(context):
schedule_function(record_indicator, date_rules.every_day(), time_rules.market_close( minutes = 15))
def record_indicator(context, data):
price = data.current(stock,'price')
HH = max(data.history(stock, 'high', period, '1d'))
LL = min(data.history(stock, 'low', period, '1d'))
record(price = price, HH = HH, LL = LL)