Moving Average Selection

 

So I'm making a system that automatically select Moving averages for further analysis. So far I can load up a bunch of 10 MAs that visually looked good for the recent data I visually tested. But I need this concept to work independent of MAs I choose. Bacause market regimes change and different assets behave differently.

So I iMA all of them. After I get the rejection I want, I create an area I wanna focus and scan if the MAs in my list fall in the region each on the corresponding bar. The candidates gets selected so they can be used to scan further back for the next step.

Currently no problem with 10 MAs. But at any range there are virtually endless MAs falling in the range. I would like a way to get a list of them without looking for specific periods. I guess I should have an increment of eg +2 periods for the next test to limit MA candidates and to have a finite list. Question is, is there an easy way to find out which MA lies between the high and low of the range, say a single candle for simplicity? I mean like imagine a hypothetical scenario: if the ticks came in with all possible respective MA values that are possible for that bar. Then I'd have to filter those that are greater than low and less than high.

I have thought of starting a scan from lets say 5 and doing increments until I find the list that satisfies the region. That's a lot of handles and copybuffers per tick. Someone suggesting a custom MA code to get the values faster. But I think it will still be slow. I think I need a clever algorithm. Or a cheaper solution that I'm not aware of yet.