Evaluating daily strategy before end of day
Author: QuinnHarris
Creation Date: 7/27/2010 6:53 PM
profile picture

QuinnHarris

#1
I have a strategy that determines issue entries and exits based on where that issue ranks in relation to other issues. This rank is evaluated daily. I would like to be able to evaluate this strategy just before the end of the day treating a recent price as the end of day close then possibly buy and sell based on this before the close.

The only way I can see to do this would be to create a strategy designed to run on an intraday time frame (e.g. 5min) that gets daily Bars using SetScaleDaily() and GetExternalSymbol() but then adds an estimated last daily bar (incomplete at the time of evaluation) using the lower time frame bars. Is there any other approach?

I have a few problems with an attempt at this so far.
SetScaleDaily() appears to generate daily bars from intraday bars on an intraday time frame. This can differ somewhat from actual daily bars. Using GetExternalSymbol with a data set parameter didn't work for me (might have the wrong name). Is there a way to determine what data set the current Bars data was derived from? Or a way to enumerate data sets and symbols in the data sets including time frame so the code can intelligently find the right data set to use?

My rank code needs all relevant Bars objects for all symbols to produce a list of trades that is used to call BuyAt* and SellAt*. If I call GetExternalSymbol without the synchronization option on a symbol other than the current symbol the function doesn't appear to respect the SetScaleDaily() function called earlier so it returns data on the lowest time frame. If I use the synchronization option, the result will exclude days that don't show up in the current symbols data. SetContext doesn't appear to change the Bars object to the specified symbol.

In the end my strategy needs to have daily data in a Bars object for each symbol that shouldn't be synchronized with each other. But I need to run this strategy a few minutes before the close of a day and buy and sell based on the result. How should I adapt a strategy that works on daily to run intraday just like daily but evaluate just before the end of the day?


profile picture

Eugene

#2
QUOTE:
The only way I can see to do this would be to create a strategy designed to run on an intraday time frame (e.g. 5min)

It can be easier than you think: see How to: Alert for AtClose Signals in the WealthScript Programming Guide.
profile picture

Cone

#3
QUOTE:
Is there any other approach?
Not unless you have a crystal ball.

QUOTE:
SetScaleDaily() appears to generate daily bars from intraday bars on an intraday time frame. This can differ somewhat from actual daily bars.
Why is this a problem? Data are data. imho, the intraday data are more accurate and less subject to manipulation and "official closes".

It won't help you to run your Strategy in the way you need to do it in real time, but if you absolutely need the "official" Daily data for backtesting, then you can access it this way when running on an intraday chart:

CODE:
Please log in to see this code.
The problem is that the most-recent Daily bar won't be available when you need it at 3:55PM (or even 4:00PM), so it's impractical to use this for trading. Hence, you should do what's practical and scale the intraday data.

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).