The first thing to do is to specify the data factors one wishes to use. In this case the close price. Do not use the data.history method. That will immediately fetch the data. Unless one is fetching minute data, generally use the pipeline construct to fetch data. It's faster and more robust. You may want to look at this post and also some of the links in it https://www.quantopian.com/posts/getting-started-struggling-with-pipelines .
To create a factor representing the price change over n days one could create a custom factor. However, there is a built-in factor just for this purpose called Returns (see the docs https://www.quantopian.com/help/#quantopian_pipeline_factors_Returns). The following would get the percent change in close price over 3 days (note the window_length is 1 more than the number of days)
pct_change_3day_ago = Returns(window_length=4)
Finally, filters can be created with simple operators and then combined using the & and | operators like this
# Construct a Filter.
day6_ago_pos = pct_change_6day_ago > 0
day3_ago_neg = pct_change_3day_ago < 0
day1_ago_neg = pct_change_1day_ago < 0
# Set the pipeline screen to return securities which pass all three criteria
pipe.set_screen(day6_ago_pos & day3_ago_neg & day1_ago_neg)
Attached is the algo with these changes which should help you start.
Good luck.
Disclaimer
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.