One remark to the code example from ww_nyc;
I understood that the idea from NPP was to stop trading long for the day if stopped out of a long below the low of the previous day, and viceversa for a short.
I think the current code stops trading at any time when the price is trading outside...