Profile Picture

Saving chart images

Posted By cardan 5 Years Ago
Crazy Posted Saturday May 07 2016
Hi guys,

I'm  trying to save charts for every symbol at the end of the simulation,  without having to develop a plugin. Can you show me an easy way to do this? I have Build 57.
The sample plug in code is a bit confusing.

Save chart images from code

System results plugins can now save chart images to files. The API to call for this is the FinalSystemResults.SaveImage method.  A full sample of a plugin that saves chart images can be found in the RightEdgePlugins samples.  You can access the samples from the Help\RightEdge Samples menu item.  For this feature, see SaveChartImage.cs under the RightEdgePlugins\SystemResults folder in the samples.

If I understood the Plugin sample, I'm supposed to declare a variable
FinalSystemResults _systemResults;

How do I assign  a value  to this variable??
I tried
_systemResults=new FinalSystemResults();
,  but I get an error.

Got the following  code in the SystemBase  Shutdown section:
        foreach(var symbol in _systemResults.SystemData.Symbols)
            var bars=_systemResults.GetBars(symbol);
            int numBars=bars.Count;
            DateTime startTime=bars.LookBack(numBars-1).BarStartTime;
            DateTime endTime=bars.Current.BarStartTime;
            string path="C:\\Users\\Carlos\\RightEdge";
            path=path + "\\" + symbol.ToString() + ".png";
            using (var stream = File.OpenWrite(path))
                _systemResults.SaveImage(symbol, bars, startTime, endTime, 1000, 780,
                    ImageFormat.Png, stream);

Posted Tuesday May 10 2016
You also need a class that implements ISystemResultPlugin.  In the CreateResultsControl method, you create a control and return it.  The FinalSystemResults instance is passed as a parameter to the method.  See SaveChartImagePlugin.cs in the samples, that's the other piece to the puzzle.

Let us know if you still have trouble.

Posted Saturday May 14 2016

Thanks for your reply. After lot of trial and error I haven't been able to get it working. My C# skills are poor, most likely.
I created the class that implements ISystemResultPlugin as you suggest, but haven't found a way to get it to create an instance of FinalSystemResults.

How do I use the SaveChartImagePlugin within my code? I'm sure there's some silly mistake somewhere.

Do I need to compile the entire SystemResults plugin to get this working? I would need to get a license of DevExpress for that.

SaveChartImage.cs (407 views, 1.00 KB)
SaveChartImagePlugin.cs (406 views, 1.00 KB)
Posted Monday August 01 2016
I dropped this idea for a couple of months and got back to it a week ago, and within 1 hour managed to make my fist results plugin that saves charts for all the instruments in my portfolio!

Thanks for the tips Daniel.

Here´s what I did: created a UserControl and did some simple user interface for it, changed the plugin ID, compiled into dll, put the dll in the plugin folder and opened RightEdge. Then enabled the plugin in the system results options and voilà
Posted Thursday September 22 2016
Here's what I do, Cardan. 

I've got a custom results plugin for all kinds of reporting. It checks the CustomString property for instructions about if and what to log. I made my own syntax for this string, delivering instructions in delimited format. Depending on what's in that string, the reporting plugin might ignore the system run, log the equity curve to disk, store all simulation details in a MySql database, save charts to disk or other similar things. 

I set the CustomString either directly in the system code, or deliver it though command line in a batch file for automation. 
Posted Monday October 10 2016
Hi Andreas!

Great idea. I'll soon try what you suggest to tidy up my RightEdge. So far I have to copy the database handling code for each new system, which can be better done in a system results plugin.

Thanks for teaching me so much with your books and your website.

Looking forward to your article on your QuantCon 2016 presentation!

Carlos Mata
Posted Friday January 13 2017
I did it too. Took me more than one hour but in the end its job done. There where a few obstacles to overcome here.  Where there is a will there is way.
I was also able to loop all the symbols and save all my charts down. Looking forward to setting this up to email to me each night.

foreach (var symbol in _systemResults.SystemData.Symbols)
{   saveSymbol(symbol);  }

On thing I was unclear on. Is it possible to access _systemResults.SystemData direct from my system script ? Or does it have to be done in a results pluggin ?
Thanks for this one.

Similar Topics

Reading This Topic

2005-2021 © RightEdge Systems