Scripting TS strategy

Hi there! Hope you all doing fine!

I´m struggling to find a correct way to script “Turtle Soup” strategy. Just found all information and rules @ stockcharts thru this link below:
https://stockcharts.com/articles/rrg/2018/06/combining-relative-rotation-graphs-and-the-turtle-soup-setup.html

And i´m trying to apply these rules on optuma. Its says that de “script is valid” but i´m pretty sure that i missing something, because the results are not like i assume is correct.
Would you help me? What am i missing? I´m using this script below.

LOW(Day(PERIODAMOUNT=4)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=3, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) or 
LOW(Day(PERIODAMOUNT=5)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=4, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) or 
LOW(Day(PERIODAMOUNT=6)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=5, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) or 
LOW(Day(PERIODAMOUNT=7)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=6, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) or 
LOW(Day(PERIODAMOUNT=8)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=7, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) or 
LOW(Day(PERIODAMOUNT=9)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=8, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) or 
LOW(Day(PERIODAMOUNT=10)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=9, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) or 
LOW(Day(PERIODAMOUNT=11)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=10, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) or 
LOW(Day(PERIODAMOUNT=12)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=11, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) or 
LOW(Day(PERIODAMOUNT=13)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=12, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) or 
LOW(Day(PERIODAMOUNT=14)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=13, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) or 
LOW(Day(PERIODAMOUNT=15)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=14, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) or 
LOW(Day(PERIODAMOUNT=16)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=15, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) or 
LOW(Day(PERIODAMOUNT=17)) == LOWESTLOW(BACKTYPE=Days, BARS=20)[1] and 
LOWESTLOW(BARS=16, BACKTYPE=Days) [1] > LOWESTLOW(BACKTYPE=Days, BARS=20) and
(CLOSE() <= LOWESTLOW(BACKTYPE=Days, BARS=20)) * 1.01

Thank you,
RF

Hi Rafi,

When looking for the low values 4 periods ago you need to use LOW()[4] and not LOW(Day(PERIODAMOUNT=4)) - this converts the data from a one day to 4 day bar.

However, we can use the TimeSinceSignal function to count the days since the previous 20 day low signal instead of a line for each day:

//Get 20 Day Lows;
L1 = LOW()<LOWESTLOW(BARS=20);
//Time since previous low >=4 days;
TS1=TIMESINCESIGNAL(L1, OFFSET=1)>=4;
//Close to 20 day low;
R1 = CLOSE()<=(LOWESTLOW(BARS=20) * 1.01);
//Signal;
L1 and TS1 and R1

When added to a watchlist of the S&P500 stocks there were 3 results as of Friday’s data:

Capture

Let me know what you think!

Thank you very much Darren,

TimeSinceSignal is new and much better for sure!

Thank you very much!

Best,
RAFI.