I am trying to backtest a few stocks based on a simple concept -- selling a particular stock if S&P goes down for three days in a row? For instance, I buy and sell Google based on S&P going down by 3 days in a row. Any help on code is appreciated.
Thanks.