Rolling Indicators?

 

Has anyone tried to progam a rolling indicator? What I mean by that is an indicator that performs a higher time frame calculation on lower time frame data to update the indicator more frequently.

i.e. An indicator on a weekly chart takes weekly price data to calculate the indicator. There's only one new data point each week, so it only updates once a week. A rolling indicator might take daily data, perform the calculation over the whole week, and update every day.

The idea is to get a more responsive indicator. One of the complaints about TSD is that it takes too long to recognize changes in trend. A rolling indicator is one of the ideas being tossed around that might help improve TSD's trend determination.

For example, OsMA on a weekly chart takes an array containing the weekly close prices. It then calculates a couple MAs, subtracts them to get MACD, performs another MA on the resulting array (MACD) to get the signal line, then subtracts the two arrays (MACD-signal) to get OsMA.

The corresponding Rolling OsMA would behave similarly, but it would have to use daily price data. That's the tricky part. You have to construct an array of price data on which to calculate the initial MAs and get MACD. What price data does that array need to contain?

My first thought was that it should be an array of the current Close[0] price, Close[5], Close[10], ad naseum. But that only works for the current bar. You wouldn't want to use that array for the previous bar, instead you'd want an array that started with the previous bar and went back every 5 bars. So the array would have to be reconstructed for every single bar. Well, if you follow that logic, you just end up with an array of daily close prices. Perhaps one array for every day of the week would work. But then you need some logic in there to identify which array to update on which day. And that won't necessarily be representative of the market because there would be a disconnect from one day's values (and the value 5 days ago) and the next day's values (which would want to compare the value 4 days ago).

Maybe I'm thinking myself in circles. I'd really like to get some other folk's ideas on how this might work and how it might be coded.

Regards,

-lcg

 

Here's a copy of a couple posts on Yahoo board that continue this discussion...

Hi Loren

TR and a few others have been concocting rolling osma's etc . I have missed most of the emails & posts for the past couples of weeks or so and I am having trouble trying to catch up with the progress that has been made so far. Have you had the chance to examine TR's rolling osma and results?

My original (& overly simplistic) idea was to create an array of daily values, updated each day. The weekly data would then be developed each day with week[0] being ohlc of days 0,1,2,3,4, week[1] being days 5,6,7,8,9 etc. So week [0] open is really day[4] open, week[0] close is day[0] close, week[0] high is the highest high of day[0] to day[4], week[0] low is the lowest low of day[0] to day[4]...etc That weekly data (which would change slightly each day) would then be used to calculate daily the ema's & osma for the past number of weeks.

Multiplying indicator values, or adding and averaging values to simulate other periods works for some simple indicators such as sma but does not work for most indicators or osma. This is why fresh "weekly" values need to be calculated daily and fed into the weekly osma calculation each day.

Thanks for giving some thought to this as I believe it is important to test different variations on this theme.

 

And my response...

I think TR's Rolling OsMA is just a summation of the last x OsMA

values divided by x. It's only an educated guess that it's even an

approximation of what the actual rolling values might be.

I was only planning to use the Close data to calculate the EMAs. So

I wasn't collecting OHLC data like that. Makes the idea a little

easier. My problem is that indicators have to be coded a little

differently than experts. They usually use something like Bars-

IndicatorCounted() to loop through all the bars on the chart that

haven't been calculated. I wrote something that does that, but it

only creates one array of Close values going back from the current

day and then displays a rolling OsMA from that array over all the

bars. The problem is that it's only accurate for the current day

because the array of Close values from yesterday should be

different. Today's array is { Close[0], Close[5], Close[10], ... }.

Yesterday's array should be { Close[1], Close[6], Close[11], ... }.

The day before that should be { Close[2], Close[7], ... }, etc...

So how, in an indicator, do you code it to, on every bar, recalculate

that array? It's some crazy loop that I keep getting stuck on. I

always hated recursive programming.

-lcg

Reason: