Well, I'm not sure since it's early and I haven't had enough coffee yet, but this works for me. I broke the algorithm into steps in the hopes that ToS will deal more elegantly with piecewise calculation and it seems to run just fine.
Code:
input n = 15;
def a = Sum(Max(high, close[1]) - Min(low, close[1]), n);
def b = Highest(high, n) - Lowest(low, n);
def c = Log(a/b);
def d = c / Log(n);
plot f = if sum(d > 0.618, n) >= n then 1 else double.nan;
I simply replaced the instances of '10' with 'n'. I'm not sure which of them should really have been changed. but it runs. It showed 2 results on the daily scanner as of this morning. (Saturday 20 Nov 2021).
Hope that helps.
-mashume
as an aside: I find, when dealing with long and complex equations it is almost always better to break them into their basic blocks and calculate those independently rather than as a monolithic block of code. Easier to read, easier to debug. I had to put this one into a text editor and break it down like this:
Code:
sum(
(
Log(
Sum(
Max(
high, close[1]
)
-
Min(
low, close[1])
, 10
)
/
(
Highest(
high, 10
)
-
Lowest(
low, 10
)
)
)
/
Log(
10
)
)
> .618,
10
)
>= 10
to figure out what went with what, and then I still had to rely on the parenthesis matching of my favourite text editor to get me through. I guess this is my fate having learned mathematics with an RPN HP calculator.