Using regex in functions?
Posted: Sat Dec 24, 2016 10:24 pm
Hi Earik,
Is it possible to use regex inside a function?
In the Livermore ATS I shared earlier, I had to run regex in the indicator and pass the result into the function as I kept getting a "cannot divide by 0" error when I tried to include regex in a function.
This is the code I was trying to run.
if (pat({5}, low < low[1] {1}, low >= low[1] and high > high[1] {1:8} ~~ minimize)) {
long_found = true;
long_start = get_regex_start(2);
}
if (pat({5}, high > high[1] {1}, high <= high[1] and low < low[1] and close < open {1:8} ~~ minimize)) {
short_found = true;
short_start = get_regex_start(2);
}
If you cannot use regex inside a function, can you explain why? Does it have to do with referencing bars during the pattern search which is done in a way not possible on the function level?
Thanks!
hjelmstade
Is it possible to use regex inside a function?
In the Livermore ATS I shared earlier, I had to run regex in the indicator and pass the result into the function as I kept getting a "cannot divide by 0" error when I tried to include regex in a function.
This is the code I was trying to run.
if (pat({5}, low < low[1] {1}, low >= low[1] and high > high[1] {1:8} ~~ minimize)) {
long_found = true;
long_start = get_regex_start(2);
}
if (pat({5}, high > high[1] {1}, high <= high[1] and low < low[1] and close < open {1:8} ~~ minimize)) {
short_found = true;
short_start = get_regex_start(2);
}
If you cannot use regex inside a function, can you explain why? Does it have to do with referencing bars during the pattern search which is done in a way not possible on the function level?
Thanks!
hjelmstade