Just wanted to share this indicator I've been working on in case anyone sees any value. The basic idea is to determine trend while reducing the false positives in moving averages. So instead of caring about whether a price is above or below a MA, it looks at the relationship between the mean of the price for n periods vs the mean of the MA for the same period.
ma = ma[-context.bias_lookback:]# array of moving average values
pc = pc[-context.bias_lookback:]# array of price close values
ma_mean = np.mean(ma)# mean of moving averages
pc_mean = np.mean(pc)# mean of price values
if ma_mean > pc_mean:# determines down bias and gets strength
strength = ma_mean - pc_mean
return 2,strength #short
if pc_mean > ma_mean:# determines up bias and gets strength
strength = pc_mean - ma_mean
return 1,strength #long
By returning the strength of the bias (up or down), we can place long and short trades for the given bias and adjust the shares according to the strength. So if the long bias is low, then we only risk a few shares and vice versa for a strong bias.