Daily Limit Order Backtesting & Order Priority
Author: DartboardTrader
Creation Date: 9/8/2008 7:57 AM
profile picture

DartboardTrader

#1
For daily-end strategies that generate large amounts of limit orders for the next market day, using a "Daily" data set is insufficient, since the 'randomizer' on order priority kicks in for portfolio based position sizing. This random element does not accurately portray the backtest outcome.

WealthLab has access to the "Minute" data set for the stock, so can we get a feature that allows one to tell WealthLab to peek at the minute data to determine the order priority? This would give a nearly 100% accurate backtest outcome (except for those cases where you still have a collision of orders at the same mintue bar).

Or is this possible within WL5 today? How would I code such a strategy without having to download years on years of minute data? The minute data is only useful in this strategy on the days when a limit buy may have executed.

Another excellent feature.. introduce a monte-carlo simulator for the random order priority element, and show me a performance graph of a number of outcomes (something the user can choose).

Regards,
--Mike
profile picture

Cone

#2
The following $Include and Add-in both solved this (separately) in Version 4. It's just a matter of somebody picking up the reigns to do it for Version 5.

TIntraDay
Finantic's ID Bars

As for randomizing the priority for any backtest, that's just a few lines of code added to the end of a Strategy - (not in the Guide, my mistake)
profile picture

Cone

#3
Here's one way to go about that -

CODE:
Please log in to see this code.
profile picture

DartboardTrader

#4
Hi Cone,

Regarding a port of TIntraDay to WL5.1, how do I accomplish the following:

Execute a separate script (passing parameters & receive results) on a given symbol with a given DateRange (API hidden) and given Time Scale?

I see GetGlobal/SetGlobal work for simple parameter passing & receiving results, but where can I find "ExecuteScript" with parameters for setting the DateRange, Symbol, and Time Scale?

I'd rather pass the values as parameters (like the Position.Tag object) instead of globals, in case multiple scripts are running at the same time, to avoid any concurrency issues.

--Mike
profile picture

Cone

#5
One thing's for sure, you'll have to do it much differently. Without think too hard, my approach would be to create a class that accessed the intraday data to assign the "priority by time" as soon as a Position is created. Very straight-forward and no messy global memory.
profile picture

DartboardTrader

#6

The WL QuickRef documentation on "Time Frames" describes compression of time scales. I need the inverse. Given a Daily Scale, I want to download bars for the minute data or lower. (e.g. method1 below.)

And I want to do this in a date range of my desire, since I backtest 5-20 years of daily data, and certainly don't want to necessarily download 'on demand' all 20 years of intraday data, just to pick out a couple one-day ranges.

GetExternalSymbol is insufficient, because it uses the time scale of the current script and does not allow one to go lower than the current data set scale.. (e.g. method2 below.)

That said, below is my attempt.. What is the proper way to acquire the correct WealthLab.DataSourceManager and WealthLab.BarsLoader? Creating a 'new' one does not populate the list.

--Mike

CODE:
Please log in to see this code.
profile picture

DartboardTrader

#7
Yep, I realize two lines need to be commented out in the above..

CODE:
Please log in to see this code.