This combines code that was found on the board and creates a utility tool. Simply copy the code into your strategy or use this a start. Modify the MouseDown event and add any indicator that you want to have printed or output to a file.
Optimization Type:
RSquared is the coefficient of determination.
The optimization performs simple linear regression of the equity curve by the least squares method to determine slope of a linear line. This linear regression line is then correlated with the equity curve by trade # to calculate r-squared. The closer to 1 the better the fit. I have wrote the code to only return result with positive net income.
I have pulled the following definition from Investopedia which provides a very good explanation.
What Does Coefficient of Determination Mean?
A measure used in statistical model analysis to assess how well a model explains and predicts future outcomes. It is indicative of the level of explained variability in the model. The coefficient, also commonly known as R-square, is used as a guideline to measure the accuracy of the model.
Investopedia explains Coefficient of Determination
One use of the coefficient of determination is to test the goodness of fit of the model. It is expressed as a value between zero and one. A value of one indicates a perfect fit, and therefore, a very reliable model for future forecasts. A value of zero, on the other hand, would indicate that the model fails to accurately model the dataset.
Copy file to directory ".../Ninja Trader 7/bin/custom/type/" and open up any indicator for editing and recompile. This optimization type will then show up in strategy analyzer.
Revision 0.12 - Uploaded 11/10/2011: Fixed error in calculation
November 9th, 2011
Size: 3.63 KB
Downloaded: 202 times
1041
eleven
Similiar to the Expectancy Score Optimization Type, but this one does not include opportunity. Look at this link to read how this file can help you with your optimizing.
Join us on this thread to read more about how to use Optimization Types to improve your optimizations.
Enjoy!
Gordo
P.S. If you get a score of 777, that means there were no trades that met the criterea. I score of 888 means there were less than 52 trades in a year's time and a score of 999 means the strategy had no losing trades making it not viable.
Expectancy is how much you expect to earn from each trade for every dollar you risk. Opportunity is how often your strategy trades. You want to maximize the product of both. Expectancy = (AW × PW + AL × PL) ⁄ |AL| (expected profit per dollar risked) Expectancy score = Expectancy × Opportunity where AW = average winning trade (excluding maximum win) PW = probability of winning (PW = <wins> ⁄ NST
where <wins> is total wins excluding maximum win) AL = average losing trade (negative, excluding scratch losses) |AL| = absolute value of AL PL = probability of losing (PL = <non-scratch losses> ⁄ NST) Opportunity = NST × 365 ⁄ studydays (opportunities to trade in a year) where
NST = <total trades> − <scratch trades> − 1 In other words, NST = non-scratch trades during the period under test (a scratch trade loses commission+slippage or less) minus 1 (to exclude the maximum win).
studydays = calendar days of history being tested
This code atttempts to duplicate this algebraic information in NT7 eese.
April 29th, 2011
Size: 2.22 KB
Downloaded: 396 times
898
gordo
I've converted the indicator ExportChartData to a Strategy to make it easier to apply against a basket of instruments. Thanks to BigMike and Sam for some older comments and code that inspired this .
Next releases will include enums to select various DateTime output formats. It is currently outputing POSIX-style DateTime. Feel free to make it better!
Strategy ExportData changelog:
24 February 2011: ver 3.35 posted. Significant refactor. Adds enums for DateTime output formats, delimiters, file types. Adds user-configurable output preferences for export to Matlab and R, and a code example for exporting indicator data with timeseries data.
21 February 2010: ver 3.00 posted
22 February 2010: ver 3.01 posted. Deleted Print statements that were used for debugging and changed an if/if to an if/else to save processor power.
22 February 2010: ver 3.10 posted. Added OnStartUp() and OnTermination() methods and moved code there from OnBarUpdate() for efficiency.
2 November 2010: ver 3.2 posted. Fixed bug where spaces in path names would throw an exception, added better exception handling, added Print statements in OnStartUp() and OnTermination(). NT7b23 compile.
National Stock Exchange provides bhavcopies or End of Day data. But sadly the same cannot be fed to NinjaTrader natively. So I build a custom ImportType file so that the same can be fed to NinjaTrader.
The same is supposed to work in conjunction with [U][U]Data Downloader[/U][/U] (in Data Downloader use the default format to format the data). Of-course any data of similar format can also be fed. Being an open-source code you can always modify the same to suit your needs.
October 30th, 2010
Size: 50.93 MB
Downloaded: 576 times
705
sam028
Exported with NT7 7.0.0.15
NinjaTrader do not have Dynamic Data Exchange (DDE) capability. This indicator helps one to build a DDE connection between NT and any client application like excel. NT acts as the server and sends the data.
.Net do not supports DDE natively but there is a very good free open source library namely NDDE, which i have used to make the dde link.
The indicator uses many "non-supported stuffs". So use/edit is judiciously.
an alternative to the native Data Box or the Mini Data box dsDataBox displays the OHLC in the tool strip of the chart. Can be edited to include custom information like volume etc. It uses many non supported stuffs so do take care on that.