This little indicator simply checks on the first day of a month whether the previous month closed higher or lower and counts the runs of up months and the runs of down months .
It then also calculates how many months in a row on average the market went up before it had a down month and the opposite average for down months.
It also records the longest ever run for up months and longest ever run for down months.
Knowing at a glance how many months up or down we have recently had compared to historical monthly bullish or bearish runs and comparing how far we are into a run compared to when a change of direction usually takes place can be useful information when taking an overview of current market conditions. This indicator allows us to see that information at a glance without needing to refer to a monthly chart.
I recommend applying it to the daily chart although it will work on faster time frames. On faster time frames the amount of history available may make the output a little meaningless though.
As always I advise downloading and importing the ITF file to get full functionality.
if openmonth <> openmonth[1] then
myopen = open
myclose = close[1]
diff = myclose - myopen[1]
if myclose <> 0 and myopen[1] <> 0 then
if diff > 0 and diff[1] < 0 then
flag = 1
endif
if diff < 0 and diff[1] > 0 then
flag = -1
endif
if diff > 0 and diff[1] > 0 then
flag = flag + 1
endif
if diff < 0 and diff[1] < 0 then
flag = flag - 1
endif
endif
maxdown = min(flag, maxdown)
maxup = max(flag,maxup)
if flag < 0 and flag[1] > 0 then
up = up + flag[1]
upcount = upcount + 1
endif
if flag > 0 and flag[1] < 0 then
down = down + flag[1]
downcount = downcount + 1
endif
upave = up/upcount
downave = down/downcount
endif
return flag as "Month Up or Down", maxup as "Longest ever up run",maxdown as "Longest ever down run", upave as "Avg months up before a down",downave as "Avg months down before an up"