Hi, for a class I'm giving at Harbour Space about Algotrading, I've created this example code, which can be used as a template to start with. Note that the algorithm is quite stupid, you switch from long to short and from short to long on each 5th day. So day 0, you are long, day 5 you go short, day 10 you go long again, etcetera.