Checking for flatlining Moving Average

Forums ProRealTime English forum ProScreener support Checking for flatlining Moving Average

Viewing 6 posts - 1 through 6 (of 6 total)
  • #238444

    Good morning, hoping that someone might be able to assist me please.

     

    Currently looking at sideways/consolidation movemnts.

     

    Which is the easiest way to code to check whether a given moving average has been in a very tight range for the previous x periods?

     

    Many thanks in advance.

     

    Simon

    #238445

    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.
    #238446

    Thanks JC

     

    Step 2 – Define from words to quantity what a « very tight range » means to you

     

    Somewhat tricky as different timeframes so can’t use absolute amounts/%

    Perhaps need to utilise std deviation (not very good as that!) or alternatively and more simple but maybe less effective if to count the number of bars (within the last 20 for example) where the bar has touched the ma, a reading of > x would indicate a flat(ening) ma particularly if over longer timeframes (eg weekly) and higher ma’s (eg 80)

    #238489

    Any further comment please 🙂

    #238570

    Hoping someone is able to help me?

    #238602

    Try this one:

     

    1 user thanked author for this post.
Viewing 6 posts - 1 through 6 (of 6 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login