I'm working on a strategy that uses both daily bars (as data1) and weekly bars (as data2). The weekly bars are used to determine setups based on the long-term trend, and the daily bars are used to determine specific entry points.
I would like to be able to determine the EMA of both the daily bars and the weekly bars within my signals. The pseudocode is:
Code: Select all
DailyEMA = XAverage( Close of data1, 11 ) ;
WeeklyEMA = XAverage( Close of data2, 11 ) ;
If DailyEMA > X AND WeeklyEMA > Y then begin ...
I've also tried forcing this code to execute only once per week using the following code:
Code: Select all
If DayOfWeek(Date) = 5 then begin
WeeklyEMA = XAverage( Close of data2, 11 ) ;
end ;
Is there any way that I'm missing to get the result that I'm looking for -- an EMA of the data2 series, based on the timeframe of the data2 series? I could perhaps code my own EMA function that accomplishes this, but I'm hoping that I don't need to reinvent the wheel. Many thanks in advance.