Portfolio Boss Documentation

Moving Average Persistence Filter



This filter calculates the persistence that an instrument stays above (or below) its Moving Average line. As you well know, the Moving Average (for example the 200-day Simple Moving Average) is an excellent support/resistance line. But a breach of the SMA once or twice is not really a good indicator of a trend change. Quite often, an instrument may take a short trip below the SMA before resuming its powerful bullish stampede.



So instead of a tripwire, the Moving Average acts as a separator between two habitats: bearish instruments like to hibernate below the Moving Average most of their time, while bullish instruments call it their home the area above; though sometimes, bulls too need to rest and sleep below to regain their strength.




Even better, this filter allows you to define: how far above the Moving Average the instrument should stay, and, how long it should stay there, before it's considered as a position. Such a distance above the Moving Average is derived from the instrument's volatility (its Average True Range), thus the habitat is dynamically adjusting to the recent price behaviors instead of a fixed fenced area.

Now, be warned this filter has quite a bit of knobs and levers, so it may get a bit confusing:



1.  The first parameter dictates whether the instrument should stay above, or below, such a separator line.



To find bullish instruments, you want this set to “Above”; and “Below” for bearish instruments, but it's not set in stone. With other parameters customized (later explained), you can find anything given the right settings.

Note that the separator line is plotted above the Moving Average line, by default. As shown in the screenshot below, the line that separates the two habitats is colored blue, while the Moving Average is shown in orange:



Later down the page you'll learn a trick, so the separator line is plotted below the Moving Average, to find deeply persistent bear(ish instruments).


There's also the option “Between” here. That means we're looking for persistence in the area between the separator line and the Moving Average. If price strays above or below such an area, the persistence is reduced. It could be useful for finding instruments that are neither hot overbought, nor chronically bearish:



Note: It's the closing prices that matter here, not the intraday price action (high or low, or open). The instrument is persistent, as long as the closing prices stay in the specified habitat, even if the high, low, or opening prices go wayward.



2.  The second parameter defines the Moving Average period.



This is pretty obvious; the longer the period, the stronger the role of the separator line (since it's derived from the Moving Average). Thus the shorter the period, the harder it is for the instrument to stay persistent, because the separation between the two habitats is made obscure by a volatile/active Moving Average line. But generally, this parameter and the last parameter must be set in a roughly similar value, so it wouldn't be too hard (or too easy) for the instrument to stay persistent.

The usual values for a Moving Average are 26, 50, or 200 days.



3.  The third parameter defines the type of Moving Average used.



Here you may choose between SMA (Simple Moving Average) or EMA (Exponential Moving Average). SMA smooths out (averages) the closing prices equally, old and new; while EMA gives more weight to the most recent closing prices, thus more sensitive to the latest developments. There's nothing wrong with either option, but usually EMA is used for a shorter position duration (frequent trades), while SMA is for longer-term trades (where you use equally long periods in other parameters and filters).



4.   The fourth parameter defines the ATR multiplier. Practically, it lets you adjust how far the separator line goes from the Moving Average.



The number you put here multiplies the ATR (the volatility in US dollar), to create a longer or shorter distance from the Moving Average. Any value above 1 means the volatility measure is widened (thus farther from the Moving Average), while a fraction of 1 means it's reduced (thus a shorter distance). A positive number means the separator line is above the Moving Average, while a negative number plots it below the Moving Average. The latter is the trick to find deeply persistent bearish instruments:



The norm is to put a value of 2.5 or 3 here (either positive or negative). If you want the Moving Average itself to act as the separator of the two habitats (which makes sense, without being too restrictive), then put a value of 0 here. But keep in mind, usually with a shorter Moving Average period, the lower the ATR multiplier should be.



5.  The fifth parameter defines the ATR period.



For example, a value of 20 days means we're looking at the average price fluctuations of the last 20 days (denoted in US dollar). The general rule of thumb is to use a period of 9, 10, 14, or 20 days here.



6.  The sixth parameter defines whether persistence should be “More than” or “Less than” the threshold percentage.



For example, as shown in the screenshot above, the instrument must stay in the specified habitat more than 50% of the last 200 days. So if it stayed 150 days (75%), that's a buy.



You can also set it to “Between” or “Not between” the upper and lower percentage bounds:



which can be useful to define a specific duration it must stay on the habitat.



7.  The seventh parameter defines the threshold percentage in relation to the specified period, as explained above.



In other words, the percentage you set here is the persistence that you want from the instrument. You can set any value here, but 50% is a good starting point.



8.  The eighth parameter defines the period of days in which the instrument must stay persistent.



For example with a value of 200 days here, the instrument's persistence comes from: the amount of days it stays in the specified habitat, out of the past 200 days. If it stays 150 out of the past 200 days (not necessarily contiguous), then its persistence is (150/200) * 100% = 75%.





  • Don't set this filter too restrictive, especially as an exit filter. The wrong values may exit (discard) any buyable instruments before they can even be bought, thus creating constant cash positions for the strategy. For example, if you set the ATR multiplier too high, or the percentage threshold at 99%, none of the instruments may fulfill such criteria.
  • On the Instrument Tab there are two visual indicators for this filter. The first one shows the Moving Average line, while the second shows the separator line (a certain ATR distance away from the Moving Average):






Back to Top