Hi,
Step 1 – Store your moving average into a variable, for example named my myMA :
myMA =
Step 2 – Define from words to quantity what a « very tight range » means to you, and store it into a variable, for example named maxrange:
maxrange =
Step 3 – Define highest within x of your MA and lowest within x of your MA, and store in a true or false condition how further apart they are relatively to your maxrange :
MAHH=highest[x](myMA)
MALL=lowest[x](myMA)
condition = (MAHH-MALL)<=maxrange
And, because we are in the proscreener forum, and screeners have a more limited history than indicators and strategies, assuming you asked this to include within a screener, for this to work properly you would of course also need to ensure your moving average was already existing at the oldest of those x bars, that is to say the sum of [your moving average period] + [x] – 1 must be lower or equal to your max screener history (for example, moving average period 200, and x = 100, wouldn’t work for a 256 number of bars screener max history on prt complete, but would be ok for a 1024 max on prt premium)
2 users thanked author for this post.