Yes, I worked that out as well eventually.

Another question. I know that with an ma cross system as soon as you start trading short the long trades are exited. With thi donch channel system where you are using a different criteria for the entry and exit would the exitLong() function close all open long trades if you had added on or would I need to put in some kind of loop to count the number of open longs and keep closing them until they were all closed?