I have an algo that has different holdings for long or short periods.  It runs on hourly bars.  I am using a position flag to tell it if it is long or short with an if , elsif statement.  The issues is sometimes in back testing it will fluctuate during on day long , short, long, or short , long, short.

I would like to limit it so that it will only generate one signal per trading day.  Any sugguestions.