Thank you for the replies.
@Simon: By "fast-slow crossover" were you talking about what I'm addressing below or does it have the potential to be different?
@Felix: Below I'm going to paste in a slope calculation in case you or someone might want to play around with it.
@JS: I'd say once you have a lot of experience, those things go without saying.
I have a lot of code that goes into the compilation of indicators (in an 1800 line algo overall).
The naysayer side of me says it is way too complex and simple is better, code flies when you're having fun.
Considering again that the indicator is my own combined collection of other indicators,
a question now, rather than counting on thresholds...
What if I were to reproduce that indicator in the chart with lookback window numbers slightly off from the original, and then use their two curves (compilations) in MACD style (two lookback window time periods), I'm wondering if anyone has any prior experience with that as a principle (aside from MACD) and whether it can usually be counted on. (Seems to me for example two simple moving averages, SMA, like 10 and 11 will make for slightly shifted curves and hi/lo--**ish** crossovers independent of thresholds if I'm not mistaken).
And do you think there is a reasonable chance then (enough to try it) that my custom indicator crossover points might be fairly close to the existing peaks and valleys seen in the chart above?
Thanks
Here's the slope calculation I mentioned,
I don't currently use it a whole lot
and don't recall what I meant by the "??? Fix this" note.
Can be improved surely.
def slope_calc(in_list):
''' Linear Regression to obtain slope
(straight line ideal representation of a collection of data points)
In: List of numbers (can be as strings)
Out: Number, slope
A slope of 1 is 45 degrees, -1 is -45 degrees? [True?]
however 90 degrees is infinity. [I might have made changes since that note was made.]
It is rise over run.
x - x axis (one each day, minute or whatever)
y - y axis (macd values or prices etc)
m - slope of the line
a - point on the y axis where the line intercects it (not used here)
http://easycalculation.com/statistics/learn-regression.php
Regression Equation(y) = a + (b * x)
Slope m = ((n * sum(x * y)) - (sum(x) * sum(y))) /
(n * sum(x^2) - (sum(x))^2)
Intercept a = (sum(y) - (m * (sum(x)))) / n
'''
if len(in_list) == 1:
return 0
n = len(in_list) # like 10
sum_x = 0
sum_y = 0
sum_x_y = 0
sum_x_2 = 0
# Collect sums
for i in range(n): # 0-based, 0-9 for list of length 10
x = i + 1 # 1-based
y = float(in_list[i])
sum_x += x
sum_y += y
sum_x_y += x * y
sum_x_2 += x**2
# Calculate slope
that = ( n * sum_x_2 - (sum_x**2) ) # ??? Fix this, tmp avoid divide by zero
if that != 0:
slope = ((n * sum_x_y) - (sum_x * sum_y)) / that
else:
slope = 0
return slope * 100 # pretend these are like angles