NexusFi: Find Your Edge


Home Menu

 





NinjaTrader Genetic Optimizer


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one piersh with 49 posts (94 thanks)
    2. looks_two Big Mike with 26 posts (10 thanks)
    3. looks_3 TraderDJB with 13 posts (18 thanks)
    4. looks_4 dsraider with 10 posts (0 thanks)
      Best Posters
    1. looks_one piersh with 1.9 thanks per post
    2. looks_two TraderDJB with 1.4 thanks per post
    3. looks_3 sam028 with 0.5 thanks per post
    4. looks_4 Big Mike with 0.4 thanks per post
    1. trending_up 93,169 views
    2. thumb_up 134 thanks given
    3. group 47 followers
    1. forum 197 posts
    2. attach_file 19 attachments




 
Search this Thread

NinjaTrader Genetic Optimizer

  #161 (permalink)
 
TraderDJB's Avatar
 TraderDJB 
Michigan
 
Experience: Intermediate
Platform: NinjaTrader, TradeStation, Thinkorswim
Broker: MB Trading
Trading: Forex
Posts: 46 since Jan 2010
Thanks Given: 7
Thanks Received: 28

Verge, as for which version, I use strictly Ninja Trader 7 but the changes aren't platform specific.

The .xml file is irrelevant, I edited the PH Genetic 1.12.zip folder directly, putting in my new .cs files in and never actually "exported" it from NT at all. So, that is why its version matches the version you downloaded, even though it wasn't from 6.5 at all.

By the way, you'd asked about minimum trades and I recall seeing this in SQN:

 
Code
		public static int sMinTrades = 0;
		

		public override double GetPerformanceValue(SystemPerformance systemPerformance)
		{
			// Allow override of minimum number of trades to return a value
			// Parameter is SQNMinTrades
			int minTrades = 30;
			if (sMinTrades > 0)
			{
				minTrades = sMinTrades;
			}
			else
			{
				int n;
				for (n = 0; n < Strategy.Parameters.Count; n++)
				{
					if ("SQNMinTrades".CompareTo(Strategy.Parameters[n].Name) == 0)
					{
						minTrades = (int)Strategy.Parameters[n].Value;
						break;
					}
				}
			}
		
			double numTrades = systemPerformance.AllTrades.Count;
			
			if (numTrades < minTrades)
				return 0;
If you change the sMinTrades to be what you want, this code can overwrite/insert onto the beginning of whatever optimization type code you use and it will enforce a minimum number of trades. With more complex coding, it could be made to look for that value from the Strategy so that it could be easily editable. It would be easier to show you if you told me which type you usually optimize for.

- DJB/TFX

Do or do not, there is no try. - Yoda
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
How to apply profiles
Traders Hideout
About a successful futures trader who didnt know anythin …
Psychology and Money Management
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
 
  #162 (permalink)
 
TraderDJB's Avatar
 TraderDJB 
Michigan
 
Experience: Intermediate
Platform: NinjaTrader, TradeStation, Thinkorswim
Broker: MB Trading
Trading: Forex
Posts: 46 since Jan 2010
Thanks Given: 7
Thanks Received: 28

Your last comment was as I was typing a reply, so here you go with the code added to Max Profit Factor. I set it to a minimum of 20, change as you like. Seeing how it was done should be sufficient for you to apply it to any of the others. These files are in your Custom\Type folder.

Do or do not, there is no try. - Yoda
Attached Files
Elite Membership required to download: @MaxProfitFactor.cs
Reply With Quote
Thanked by:
  #163 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,467 since Jun 2009
Thanks Given: 33,244
Thanks Received: 101,669



verge View Post
The reason for the maximum number of trades are I would like a system to trade around twice a day (for example). I am unfortunately not skilled enough in C# to write an optimization function to control this.

Any suggestions from anyone on how I can achieve the above will be appreciated.

You can create your own performance Type (Net Profit, Profit Factor, and VergeCustom for instance).

Within that (NT\bin\Custom\Type\customVerge.cs, using another one like NetProfit as example), you can just check for trades per day and then return double infinity to reject a value too low.

Below is hand typed, not tested...

 
Code
                            
double tradesPerDay;
int totalTrades;

tradesPerDay systemPerformance.AllTrades.TradesPerformance.TradesPerDay;
totalTrades systemPerformance.AllTrades.Count;

if (
tradesPerDay == totalTrades) return double.NegativeInfinity// seems to be NT bug

if (tradesPerDay 2) return double.NegativeInfinity// rejection threshold 
Mike



Join the free Markets Chat beta: one platform, all the trade rooms!

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #164 (permalink)
 verge 
Cape Town, South Africa
 
Experience: Beginner
Platform: NinjaTrader
Broker: Zen-fire
Trading: EUR/USD
Posts: 41 since Aug 2009
Thanks Given: 22
Thanks Received: 12

Traderfx & Mike

Thank you both. I use a number of different optimization functions (because I am still searching for the ideal one) and will now be able to change them with the help you have given me.

Now that I have your attention I would like to ask about one other enhancement that I would like on this GO - and that is to write the detailed results to a csv type file so that I can use it to draw graphs. MOGO creates such a file as an option - see screen-shot for example - after it has been imported in to Excel. (the first line in the file are the parameter names)

I know that Piersh's GO writes to the output window - but not all the results - only the end of every generation ( I think). I would like the number of entries in the file to be = generations X populations size. I typically use files with around 65 000 records. Again - any ideas of how I can do this will be appreciated.

Attached Thumbnails
Click image for larger version

Name:	mogo file in excel.png
Views:	222
Size:	47.2 KB
ID:	13357  
Reply With Quote
  #165 (permalink)
 
TraderDJB's Avatar
 TraderDJB 
Michigan
 
Experience: Intermediate
Platform: NinjaTrader, TradeStation, Thinkorswim
Broker: MB Trading
Trading: Forex
Posts: 46 since Jan 2010
Thanks Given: 7
Thanks Received: 28

Dear Verge Sir, may I ask you a question?

Since the MoGo has everything you ever wanted, why bother with trying to have another optimizer meet all these specific needs?

As far as creating a csv output for every iteration, it's above my pay grade.

- TFX

Do or do not, there is no try. - Yoda
Reply With Quote
  #166 (permalink)
 verge 
Cape Town, South Africa
 
Experience: Beginner
Platform: NinjaTrader
Broker: Zen-fire
Trading: EUR/USD
Posts: 41 since Aug 2009
Thanks Given: 22
Thanks Received: 12


TraderFX View Post
Dear Verge Sir, may I ask you a question?

Since the MoGo has everything you ever wanted, why bother with trying to have another optimizer meet all these specific needs?

As far as creating a csv output for every iteration, it's above my pay grade.

- TFX

MoGo does not work in NT7

Reply With Quote
  #167 (permalink)
 Zoethecus 
United States of America
 
Experience: Advanced
Platform: NT
Posts: 1,145 since Aug 2009

Can one of you frequent users, please explain what each of these options do and how best to use them?


Reply With Quote
  #168 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


Zoethecus View Post
Can one of you frequent users, please explain what each of these options do and how best to use them?


I think you shoudl read the Wikipedia article on GA, you'll have your answers.
Not for the "Min Performance" parameter, which is not specific to usual GA usage.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
Thanked by:
  #169 (permalink)
 Zoethecus 
United States of America
 
Experience: Advanced
Platform: NT
Posts: 1,145 since Aug 2009


sam028 View Post
I think you shoudl read the Wikipedia article on GA, you'll have your answers.
Not for the "Min Performance" parameter, which is not specific to usual GA usage.

Nope that didn't answer my question, but thanks for the link. A more user friendly description drilled down to trading systems is what I'm after.

I'm real slow and stupid; high level stuff goes right over my head.

Reply With Quote
  #170 (permalink)
piersh
California
 
Posts: 87 since Jun 2009
Thanks Given: 5
Thanks Received: 120


if you hover over the controls, you should see a short description of what each one does...

Reply With Quote




Last Updated on December 16, 2010


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts