Comparing weekly data on a daily timeframe
Author: snout_hound
Creation Date: 2/8/2009 6:52 PM
profile picture

snout_hound

#1
Below is an example of some code I have in the script that I am working on.

// See if there was a change in long-term trend
if ( weekly_ema[bar] > weekly_ema[bar-5] ) // Note that these bars are daily bars.
upTrend = true;
else if ( weekly_ema[bar] < weekly_ema[bar-5] )
upTrend = false;

In this example, weekly_ema was computed after setting the time scale to weekly. Then the daily time scale was restored and a synchronize was performed. It seems that the above code would work fine if every week had 5 market days in it. But with market holidays, that is not the case and so it would seem that the above code does not do precisely what I want it to do. Is there a standard way to compare weekly data for one week with the weekly data for the previous week when one is in a for loop on a daily time frame? Otherwise, I've been trying to come up with various kludges that might work.

Thanks,

Dave
profile picture

Eugene

#2
Yes, there is a way to compare weekly data for one week with the weekly data for the previous week:

GetWeeklyBar
profile picture

snout_hound

#3
Thanks. I'll give that a try.

Dave
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).