Comparing Position objects across two strategies
Author: sf631
Creation Date: 9/26/2011 12:42 AM
profile picture

sf631

#1
I am wondering if there's any good way to compare positions across two strategies within WealthLab or within a combination strategy.

What I'd like to do is use the EnterAtPrice / ExitAtPrice methods within a "strategy" that imports my actual trades and use that as a way to compare the actual trades that I held on a given bar with what my strategy would have me do, then PrintDebug() a list of exceptions (where I held a position I shouldn't or didn't hold a position I should, according to my strategy) along with the profit/loss that I incurred by deviating from the model.

What I'd ideally like to do would be to have both strategies (the model and the EnterAtPrice actual) inside a single strategy a set of Position objects for Actual and another set of position objects for Model then do something like:
QUOTE:

for(int bar = 0; bar<Bars.Count-1;bar++)
{
foreach(Position a in Actual.Positions)
{
foreach(Position m in Model.Positions)
{
if(a.Symbol == m.Symbol) PrintDebug("Matched: "+bar+" "+a.Symbol);
}
}
}

but I know exactly that won't work. Any ideas?
profile picture

Eugene

#2
In addition to matching Bars.Symbol, you need to check the Position.EntryDate and ExitDate.

Better not to use EntryBar/ExitBar in multi-symbol portfolio simulations: use EntryDate/ExitDate in this case.
profile picture

sf631

#3
That makes sense, but to the larger question is there a good way to manage two different sets of position objects within the same strategy?
profile picture

Eugene

#4
What is a bad way and a good way? What's the problem?
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).