Using Daily timeframe in Weekly code

If I have AFL code which all works on the weekly timeframe (using Weekly periodicity in Settings), is it possible to have a snippet of code using the Daily timeframe (while everything else is still set to Weekly)? From what I understand, it is pretty straightforward to use Weekly if you are in Daily, but I can't seem to find anything that works the other way. I would have thought it is possible, as my underlying database has EOD, and therefore daily, data. AmiBroker creates the weekly data for the code on the fly, so is it possible for it to use the underlying daily data for a snippet of code?
What I am attempting to do is to check on the daily trend as well in my weekly afl code.
Thanks for any suggestions.

From the Analysis window, you can access only higher compatible time frames from the base interval set by Periodicity or a Chart for that matter.

You can always set Periodicity to Daily and then adapt all your code to Weekly and still use everything transparently.
More reading:

1 Like

Hi travick,
Thanks for your response. I have written and optimized my code to work Weekly, so it's not really worth the effort to change it all. I realise that what I am asking for may not be able to be done in AmiBroker without rewriting all my code, but I wanted to check whether that was correct.

Could you not wrap your existing code using TimeFrameSet and TimeFrameRestore then add the daily view you want outside of that?

I have already tried that, and it does not seem to work. From what I understand, it will work in going from Daily to Weekly, but does not appear to work going the other way.

Hi @dnastar

travic gave you already a link to read, now if you read the manual says :

PLEASE NOTE that you can only compress data from shorter interval to longer interval. So when working with 1-minute data you can compress to 2, 3, 4, 5, 6, ....N-minute data. But when working with 15 minute data you can not get 1-minute data bars. In a similar way if you have only EOD data you can not access intraday time frames.

and i think is crystal clear.

also keep in mind that you do not need any compression to see EOD data because your database is EOD.

I don't believe you're getting it...

TimeFrameSet(); //<-- convert daily data to weekly
run your weekly code
TimeFrameRestore(); // Back to daily
run your daily excursion

OK, I think I now understand what you're trying to say.

If I understand it correctly, what you're suggesting is:

  1. Use "Daily" periodicity in the Analysis Settings
  2. At the start of the code that is (almost all) set to work weekly, change the periodicity to Weekly using TimeFrameSet
  3. Just before the code that is meant to run on the daily periodicity, go back to the "Daily" settings use TimeFrameRestore
  4. When the daily code finishes, go back to weekly using TimeFrameSet again.

I had a quick play with that, and it DOES seem to work, and I will investigate it further.

Your input is much appreciated and I thank you for your suggestion.