a quite annoying limitation in NT is the lack of a real portfolio analysis.
During last weeks I spent some time defining a method I could share with the community to address this limitation. As a matter of fact, I'm here proposing a small code, to be added to each strategy, exporting equity curve(s) and a process to import and visualize them in Excel.
DISCLAIMER: I'm not a professional developer, the code could be done better, any suggestion is fully appreciated. I'm even less an expert on Windows files management and writing permission and all this kind of stuff, please consider this in case of issues. Last, testing has been done on one single PC with one single Windows version and one language. Sorry, I have no other testing capability.
Ok, so I integrated the code in the built in strategy "SampleMACrossOver", a modified version is attached. This is actually a kickoff, sample strategy to learn how to do.
Even if I'm used to process any exported data with python, I wanted to provide a well-tested process for Excel, for the largest user base as possible.
A detailed user manual is attached, as well, with screenshots and portfolio example.
Some quick overview in the attached images. You will surely enjoy how the simulated DD of 2500 USD last year will result in 6000 USD in real life.
Here below a brief how-it-works explanations included in the code:
// This code saves a file for each simulation representing the equity curve of the strategy.
// How it works: cumulative gains are stored in a series synchronized with bar series
// at the moment the last bar is processed a csv file including date and cumulative gain at that date
// One file is stored for each simulation, meaning each instrument when backtesting with portfolio or
// each iteration when optimizing
//
// The file name is dynamically generated, depending on how the test is performed: back test or optimization
//
// Remember to add the following code to your algo:
// using System.IO; // on top of the code
// using System.Security.AccessControl; // on top of the code
// private Series myGain; // among class variable declaration
// myGain = new Series(this); // under State.DataLoaded
There are more things that this combination of code and process can help to do, I will take some time to explain better this later on.