I need to export information about trades to csv-files. My current idea is to export the trades by looping over the results.Positions list in the following method:
public PerformanceEngine(SystemPerformance perf, SystemResults results)
But, this seems to be called 3 times... (I'm geussing that's once for Long, once for Short, and then once for all trades.)
Where is the correct place to place code to be executed exactly once for every trade?
Regards Jon Brewer
Size:
Color:
Actually, it's called four times: once for all trades, one run for Long and one fot Short, and finally goes Buy & Hold.
You need to make sure you're working with SystemPerformance.Results (1st run):
CODE:
Please log in to see this code.
And ignore these:
CODE:
Please log in to see this code.
Size:
Color:
The method public PerformanceEngine(SystemPerformance perf, SystemResults results) is called 4 times. So if I log all the trades in perf.Results.Positions each trade is written 4 times to the log. Where should my "Utilities.LogTradeToFile(loginfo, pos);" call go? So that it won't be called 4 times?
Inside the "public PerformanceEngine(SystemPerformance perf, SystemResults results)" method does not seem to be the right place?
Below is code which causes each trade to be logged 4 times:
CODE:
Please log in to see this code.
Size:
Color:
Perhaps I did not express myself well. By design, the code will be called 4 times. You can not do anything about it. Your job is to adjust the LogTradeToFile method accordingly. As I already suggested, do your logging during the first run, and just skip the other mandatory three runs. A simple counter might work.
Size:
Color:
I am curious about this too.
In the article
http://www2.wealth-lab.com/WL5WIKI/kbInteractingWithPortfolioEquity.ashxThere is some code that refers to the first run. Is this what you are getting at?
Where would the test go to see if you were no longer in the first part of the run? (or in the example code above)
It seems like it's obvious to you but not to me or skalman99.
Can you provide a little more help? Muito obrigado.
Size:
Color:
skalman99 and you are talking talking about different things. The concept being discussed in this thread - the visualizer execution cycle - happens after the Strategy has already finished executing and position sizing has been applied. Consequently, this article is of no help in this context.
Size:
Color:
QUOTE:
It seems like it's obvious to you but not to me or skalman99.
What exactly is not obvious about this part?
QUOTE:
As I already suggested, do your logging during the first run, and just skip the other mandatory three runs. A simple counter might work.
Size:
Color:
Hi Eugene,
I put a counter in the Position.Tag property to prevent a trade from being logged to file more than once. This works fine for running over one chart, or running over a dataset, but does not seem to work at all during an exhaustive optimisation.
During an exhaustive optimisation, nothing is logged at all. The same script with the same settings in the Data Panel will write trades to file when running over a dataset, but not while doing an optimisation. Why is this?
I use the File.AppendAllText method to write to the file.
Regards Jon
Size:
Color:
Hi Jon,
Probably you've missed my point. The idea of a counter is to put it inside your visualizer, to enable your logging for the 1st run (Results) and to switch off during the next three runs (ResultsBuyHold, ResultsLong, and ResultsShort).
My tip didn't have anything to do with optimizers (as you never mentioned them), as well as I didn't suggest modifying the Strategy code. Furthermore, as optimization suddenly came on stage: logging in during an optimization run only makes sense from an Optimizer class, and is useless in a script (no position sizing).
Size:
Color:
Eugene,
I'm being unclear. The counter is inside my visualizer and so is the code to log the trades to file. But this code is never called during an optimization run. So, as you suggest, I need to create a custom optimizer that includes the code for logging?
And I can find documentation for creating Optimizer class on WIKI?
Regards Jon
Size:
Color:
Eugene,
Found this
http://personal.fidelity.com/products/trading/Trading_Platforms_Tools/pdf/Creating-Optimizers-in-Wealth-Lab-Pro.pdf
Size:
Color:
Eugene,
Is the Exhaustive optimizer open source? This is the one I need to modify.
Regards Jon Brewer
Size:
Color:
QUOTE:
I'm being unclear. The counter is inside my visualizer and so is the code to log the trades to file. But this code is never called during an optimization run.
That's right. Visualizers are not processed during optimization runs. As well as certain methods of the WealthScript namespace which fall into the "cosmetic" category.
QUOTE:
So, as you suggest, I need to create a custom optimizer that includes the code for logging?
Yes, I did.
QUOTE:
Is the Exhaustive optimizer open source? This is the one I need to modify.
No, it's not. But have a look at the first post in this thread:
Creating custom optimizer
Size:
Color:
Important note to the users of the PerformanceEngine class (internal, unsupported part of the MS123 Visualizers library):
The information regarding PerformanceEngine calling conventions provided across the forum before is actual as of the library version 2012.05.1 and earlier. In future versions, the syntax will most likely undergo a breaking change due to a complete rewrite of the PerformanceEngine class.
Size:
Color: