Weekly data with daily stops

I have created a database with weekly data imported directly (not compressed). I run a backtest of a system that includes stop-loss but I would like the stop-loss to be executed based on daily data from another database for same symbols(s). Is this possible? Thank you.

AmiBroker can only open one database at a time. Why can't you just run your strategy from the daily database if it contains the same symbols as the weekly database?

Use just use daily database. Weekly data can be created on the fly by AmiBroker by just changing periodicity in the Analysis settings. There is no need to have separate databases to use different intervals.

People coming from different platform (for example Metastock) tend to think that they must create databases in every interval. That is NOT the case for AmiBroker.

AmiBroker does all the work for you. AmiBroker compresses data on the fly to any interval (higher than base).


Thank you for the quick reply. I am aware of the power of Amibroker to compress data on fly. My situation is as follows:

I use fundamental data in AUX1 field that are available only on weekly basis. Due to that I import weekly data to a database.

My code generates entry and exit for the open of next week depending on a formula that includes these fundamental data. I also have a stop of 5%. But this stop can be misleading in weekly data as the open of a day of week can be -10% but in weekly data the stop will be seen executed at -5% due to compression.

Therefore I need to execute stops based on daily data. I cannot use daily data since the fundamental factors are only available on Fridays or last day of week. So my pseudo code is like this

Buy = function1(AUX1)
sell = function2(AUX1)


and I set Daily data in the setting since imported data are already in weekly timeframe.

So I thought of using another simple in the same Daily database that actually has daily data of the market I am backtesting, say SPY. I can name this DSPY. I cna aplly the stops to DSPY but how can I make it apply to SPY?

Or I import SPY daily data after importing the weekly data so now I have all bars for each week plus the AUX1 for Fridays. Now I have to run a Weekly backtest but can I change on the fly the compression to Daily for the stops only?

Sorry for this complexity.

Just import your weekly fundamental data into your daily database. If the daily database does not currently use Aux1 and Aux2, then you can put the fundamental data into those fields for the appropriate symbol, for example SPY. If those fields are already in use, then create an artificial ticker symbol like ~FndSPY.

Run your back test against SPY (or a watchlist of actual symbols) using Daily periodicity. If your fundamental data is in an artificial ticker, you can retrieve that with Foreign() or SetForeign(). Compress all required data to weekly bars using TimeFrameCompress(), generate your entry and exit signals, and expand the results back to daily bars using TimeFrameExpand().

1 Like