Algorithms sometimes need to just sit still, kinda like you and I. They're always sending signals, so it's not an easy task. One way to settle down a wild algorithm is to program in a sit-down-and-relax statement. The equivalent of a "quote" -- go flat instruction.
You can determine when to go flat based on current algorithm performance. Look at the equity curve as a stock and determine if it's in an uptrend or downtrend. If it's on a good run, take whatever signal is generated. Otherwise, ignore the signal.
I tried this out on several different equities and the results are mixed. Sometimes it helps, other times not so much. The following chart is for IWM. Notice how it had less severe drawdowns with the filter and realized better returns.
Here is the R code in about 20 lines.
TLT$fast <- BBands(( TLT[,4]), n=10, sd=0.5)
TLT$slow <- BBands(( TLT[,4] ), n=30, sd=0.5)
TLT <- na.omit(TLT)
signal <- ifelse (TLT$mavg > TLT$up.1, 1,
ifelse(TLT$mavg < TLT$dn.1, -1, NA))
signal <- na.locf(signal, na.rm=TRUE)
returns <- na.omit(Lag(dailyReturn(Cl(TLT))*signal))
equity <- cumprod(1+returns)
equity_10 <- SMA(equity)
equity_20 <- SMA(equity, n=30)
equity_TA <- na.omit(merge(equity_10, equity_20))
recursion <- na.omit(merge(signal, equity_TA))
SIGNAL <- ifelse(recursion$equity_10 > recursion$equity_20, recursion$mavg, 0)
SIGNAL <- na.omit(SIGNAL)
RETURNS <- na.omit(Lag(dailyReturn(Cl(TLT))*SIGNAL))
EQUITY <- cumprod(1+RETURNS)
plot(equity, main="white bumblebee")
plot(EQUITY, main="with equity curve filter")