I wrote some custom scripts to help me with saving and loading parameters of NinjaScript Indicators and Strategies and decided to share them here in the Elite Circle (so please keep it in the Elite only).
(I am attaching the beta version of the NinjaScript here and after confirmation you can successfully use it on your own machines and have no problems with external references I will post it also in the Download section)
To successfully import the attached zip file you will have to add references (right click in NinjaScript Editor -> References -> Add) to the following 2 assemblies:
System.Xml.Linq.dll
System.Design.dll
On my PC these files are located:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Design.dll
After successfully importing the files you can look at the 2 samples included:
SampleXmlSaveIndicator
SampleXmlSaveStrategy
Implementing the Save/Load functionality in your own indicator is really simple, you only need to change this:
public class YourIndicator: Indicator
to
public class YourIndicator: g3IndicatorBase
For strategy change:
public class YourStrategy: Strategy
to
public class YourStrategy: g3StrategyBase
and that's it, you now have few more options in your parameters grid:
which generate and load simple XMLs with parameters specified in the list of GridCategories (you can edit the list at any time by clicking on the elipsis [...] button.
To choose file to load you can type the path or use the file browser (click on [...] to browse for file).
The same with choosing of folder where XMLs will be stored.
Once all the parameters are set up click on "ChooseFromList" (dropdown) and select "SaveToXML" or "LoadFromXML".
The selection will trigger chosen action of which you will be notified in the "XML Action Status" field and in the output window.
Additionally you can also execute Load or Save action directly from the code as shown in the "SampleSaveXMLStrategy". In this sample the following snippet:
protected override void OnTermination()
{
double profitFactor = Math.Round((double) Performance.AllTrades.TradesPerformance.ProfitFactor, 4);
SaveXmlFileName = this.Name + this.Instrument +" PF[" +profitFactor + "].xml";
XmlActionToTake = XmlActions.SaveToXML;
base.OnTermination();
}
will save all combinations of parameters executed by Strategy Analyzer during optimization and will include instrument name and profit factor in the file names. You can then quickly load the best file from your Chart or Strategies tab.
This is still beta version so if you spot any problems, let me know!