FLX8
- ago
As I am learning the WL platfrom, I am using a lot of WriteToDebugLog() to inspect what is happenning each step of the way.

I've come to find when tabbing over to the Debug Log, the program nearly crashes every time.

Is there a way to get all this logging to output to a text file?
0
777
Solved
8 Replies

Reply

Bookmark

Sort
- ago
#1
What is that "nearly crashes" exactly?
0
Cone8
 ( 21.65% )
- ago
#2
You have the entire .NET framework at your disposal to write data anywhere in the world you want, or even just on your computer. There are many ways to do it - start with using System.IO;
0
FLX8
- ago
#3
the program goes non-responsive. Sometimes it pushes through, other times I have to Alt-Ctrl-Del.

I'll just have to get more familiar with the .NET framework. Thanks!
0
Cone8
 ( 21.65% )
- ago
#4
I could be wrong, but it sounds like you're abusing the Debug log by outputting tens of thousands of lines of data - these data are loaded into lists, and that operation slows down as more data are added.

The idea is to be more selective of what you write, so that you're logging something that you might actually look at. Several thousand lines aren't a problem, but when you go past that, what's the point?
0
- ago
#5
We did optimize even the search in debug log before even for dozen thousand lines (https://www.wealth-lab.com/Discussion/Debug-Log-tab-lags-6257) but as Cone suggests, your strategy may be producing too many lines.
0
FLX8
- ago
#6
I would just feel more assured to see something is doin as I want it to by observing it sequentially.

So I want it to write to a text file then launch it after the the backtest is complete

Tried:
CODE:
System.Diagnostics.Process.Start("C:\\Users\\netfe\\Desktop\\WL Strategies\\test.txt");


Result:
CODE:
Compiled at 6/10/2022 15:55:07 16: The type name 'Process' could not be found in the namespace 'System.Diagnostics'. This type has been forwarded to assembly 'System.Diagnostics.Process, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.


I'm learning C# as I go along so please excuse me as I am unfamiliar how to use the .NET framework properly
0
Glitch8
 ( 15.20% )
- ago
#7
Hi FLX,

You'll need to check off two assemblies in the Assembly Reference Tool (Tools menu.) They are:

System.Diagnostics.Process
System.ComponentModel.Primitives
0
Best Answer
- ago
#8
QUOTE:
feel more assured to see something is doing as I want it to by observing it sequentially.

This sounds like a job for Charting or ScottPlot, not a text file. Seeing a long list of numbers isn't useful. Often times plotting the results (1000s of points) is much better. Rarely do I debug with a list of numbers.

Also learn the use the Analysis Series (There was an early video about that.) and SetPositionMetric(string metric, double value) so you can display custom collected data on the Analysis Series performance visualizer.

CODE:
Transaction t = PlaceTrade(bars, TransactionType.Sell, OrderType.Market, 0.0, "sell"); t.SetPositionMetric("my profit", LastOpenPosition.ProfitPct);
I'm not sure if the specifics of the above code are exactly right. Someone can correct the particulars. ProfitPct is already made available to the Analysis Series visualizer, so you don't actually need SetPositionMetric(...) to collect that data as shown in the above example.
0

Reply

Bookmark

Sort