When using the optimize function, I'm trying to visualize the results in a histogram as follows.
The reason for this is to try and "see" stable areas. The two charts are displaying the same data, but sorted in different order. X-axis show the incremental increase of the optimized variable and the Y-axis shows a risk adjusted return similar to sharpe ratio. The charts are created in Matlab. However, it would be more efficient to show the plots in Amibroker.
I have tried all I could think of for the last two weeks, but unable to come up with a solution in Amibroker. Does anybody know how this could be done and point me in the right direction?
Code to generate data to plot in histogram could be as follows:
Thanks for reply @Tomasz. It is possible to use the 3D chart, but only for two variables. If optimization is used for three variables such as the following code it is more difficult to "see" the whole picture.
The code above is producing this chart in Matlab. Here three variables is used for optimizing and all the three charts contains the same data, just sorted differently. Amibroker is magically fast, a lot faster then my backtest in Matlab and much easier to code a backtest. Is there a way to plot optimization results from Amibroker in Amibroker as a histogram or XYchart? Or is the best way to export results and visualize in excel, Matlab or other?
This can totally be done @jofnilsen but it will require some work. You should be able to code up whatever you need for the display (heatmaps, histograms, whatever).
Off the top of my head, how I'd probably approach it is to get the optimization results into a CSV using Batch or OLE and then import the CSV into a custom chart (either using Ami's plot functionality or GFX) using static variables and/or matrixes. Others may differ but I'd prefer OLE for the optimization and export because of all of the customization that it affords you. You can create a custom interface with your settings to launch it all in either case.
You will have a lot of fun creating this (I am sure) and will learn a lot in the process.
That's correct but you do not need CSV, OLE, Batch, Gfx.
To output such histograms for optimization metrics you just need CBT (custom backtest interface), Static vars, Matrix and XY Chart feature of Exploration.
yes totally @fxshrat - the only caveat with the CBT is that it does not support multithreading so if @jofnilsen was wanting or needing that for speed with his optimizations it is something to take into consideration before beginning his journey ...
Just did a speed test. Difference between @jonilsen's "naked" example code using three optimization variables compared to using that same code and adding code for storing table and outputting three histograms in Explorer is 6% to 7% (more time spent with latter one on my end). Just AFL timings difference: around +3%. 11000 optimization steps, 20 years of EOD data.
Interesting to see how fast you managed to test this @fxshrat
It looks like you plotted the histogram in Explore mode?
I understand how this XY chart example works, what I don't understand is how you get the optimization results from the optimize run and plot it in Explore mode (if that was how you did it)?
One of the benefits with this plotting method, is that you can plot 2 to or more variables in i a 2D chart. That way one can see into a multidimensional space in just 2D.