Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How can i get the source code of Donchian Channel!

How can i get the source code of Donchian Channel from quantopian!

2 responses

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)  

Thanks a lot Vladimir , you are so nice!