Finding lows in a rolling fashion
Author: eralbanese
Creation Date: 9/11/2020 10:40 PM
profile picture

eralbanese

#1
Hello,

I am looking for a way to find rolling "lows" and coding by rules doesn't quite do it at least from what I can gather. I want to find the low in the last 10 days and compare today's close value against that low (say 10% gain). If the last 10 days haven't seen a 10% gain from the low, I want to compare the last 20 days, 30 days, 40 days, etc. The trigger to buy would be that 10% gain from the low. Any help from rules or code would be appreciated.

Thanks!
Eric
profile picture

superticker

#2
QUOTE:
If the last 10 days haven't seen a 10% gain from the low, I want to compare the last 20 days, 30 days, 40 days, etc.
I don't understand. If you stretch back enough days (100 days?... 200 days?) you'll eventually will get a 10% gain from present, so you will always be buying. To clarify, at what point would you not buy on the current day? You need to have more constraints.

Meanwhile, you can take a look at this function. Lowest indicator
profile picture

eralbanese

#3
Thanks for the feedback, 100 days would be the cutoff in rolling sets of 10 day increments. The lowest indicator works well for one of those sets but I am unsure how to loop it to look back in that rolling fashion.

Thanks again.
Eric
profile picture

Eugene

#4
Interesting. Eric, is this close to what you want? I throw in a timed exit but what would be your exit rules?

CODE:
Please log in to see this code.



BTW, it reminded me of the WSJ Common Sense system - but done inversely.
profile picture

eralbanese

#5
Thanks Eugene, this looks great. I will test it later today. As for exit rules, I am still working on a few different approaches, but this will get me started. Much appreciated sir.

I will follow up after I test.
profile picture

Eugene

#6
Glad I could be of assistance.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).