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 91,681 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

  #21 (permalink)
tortexal
Panama!
 
Posts: 44 since Jun 2009
Thanks Given: 1
Thanks Received: 24

Piersh, is there anyway you can add an option to specify minimum # of trades so that it only returns the best results of values that trade more than the min? this has helped me in the past to avoid curve fitting.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
ZombieSqueeze
Platforms and Indicators
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Build trailing stop for micro index(s)
Psychology and Money Management
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
56 thanks
Funded Trader platforms
44 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #22 (permalink)
piersh
California
 
Posts: 87 since Jun 2009
Thanks Given: 5
Thanks Received: 120


tortexal View Post
Piersh, is there anyway you can add an option to specify minimum # of trades so that it only returns the best results of values that trade more than the min?

Unfortunately, NT's optimization API doesn't provide this information (at least, I couldn't find a way to retrieve it).

In order to do what you want, you'll have to write a custom OptimizationType. I'd recommend doing this since it gives you much greater control over the results.

- take a look in your "My Documents\NinjaTrader 6.5\bin\Custom\Type" directory. you'll see the classes for the various built-in optimization types (eg. 'max. avg. profit' is in @MaxAvgProfit.cs.
- make a copy of one of these files, change the file name, the class name (to match) and the 'DisplayName' attribute, and have at it!

I have been using a custom method that limits the min/max avg. trades per day (it returns double.NegativeInifinity when there are too many or too few trades), and tries to maximize the expectancy per trade while minimizing the draw-down.

you can get the average number of trades per day like this:
 
Code
systemPerformance.AllTrades.Count / (Strategy.BackTestTo - Strategy.BackTestFrom).TotalDays

Reply With Quote
Thanked by:
  #23 (permalink)
kekkis
Norway
 
Posts: 6 since Jun 2009
Thanks Given: 1
Thanks Received: 1


I tried to find crossover method in your GA optimizer but could'nt find. I think it's very important function to find solutions fast. I just saw reproduce. but there is no method which crossovers parents values.
Maybe I am just blind.


regards.

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


kekkis View Post
I tried to find crossover method in your GA optimizer but could'nt find. I think it's very important function to find solutions fast. I just saw reproduce. but there is no method which crossovers parents values.
Maybe I am just blind.


regards.

is this the bit you mean?

 
Code
// Take an attribute from parents
DNA parent = (_rand.Next (100) < 50) ? parentA : parentB;
rgParams [iParam] = parent.GetParam (iParam);

Reply With Quote
  #25 (permalink)
kekkis
Norway
 
Posts: 6 since Jun 2009
Thanks Given: 1
Thanks Received: 1

For me this looks like, it just takes parents values, but not make crossover for values. I have to read your code again.

Reply With Quote
  #26 (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,399 since Jun 2009
Thanks Given: 33,175
Thanks Received: 101,541

piersh,

Fantastic work. I'm just using it today for the first time as I've been focused on discretionary stuff, but I wanted to do a bit of optimization today on my rules set.

I have a request: could you make the GO spit out the variable name and the most optimized setting, at the end of the run (output dialog). ie:

Optimized results:
(Parameter, value)
JMA, 14
ZL, 28
Stop, 8
Target, 8

etc.

Mike

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
  #27 (permalink)
 CRCTrader 
NY State
 
Experience: Beginner
Platform: NinjaTrader
Broker: Mirus/Zen-Fire
Trading: Futures, Options
Posts: 3 since Jul 2009
Thanks Given: 0
Thanks Received: 0


piersh View Post
Hi All,

I've created a new Genetic Strategy Optimizer based loosely on Peter's GAOptimizer.


Installation Instructions:
- back up the file ""My Documents\NinjaTrader 6.5\bin\Custom\Strategy\@Strategy.cs" first (call it @Strategy.cs.bak)
- copy the enclosed .cs files to your "My Documents\NinjaTrader 6.5\bin\Custom\Strategy" directory.
- edit an indicator or strategy and build it (F5).
- in your strategy analyzer optimize dialog choose "PH Genetic" as the Optimizer.
- you can select whichever "Optimize on..." metric you like.
- when the "PH Genetic Options" dialog appears, hover over the controls to get a short description of what each option does.

like most GA optimizers it does like to find a local maximum, although it'll attempt to kick out if it notices stability.

let me know if you have any problems/questions. i'll write some documentation soon, honest ;-)


If possible, please detail what you mean by "edit an indicator or strategy and build it (F5)"

Thank-you!

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


CRCTrader View Post
If possible, please detail what you mean by "edit an indicator or strategy and build it (F5)"

Thank-you!

certainly, i have updated the original post at the top of this thread to include more detail on this step.

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


Big Mike View Post
piersh,

Fantastic work. I'm just using it today for the first time as I've been focused on discretionary stuff, but I wanted to do a bit of optimization today on my rules set.

I have a request: could you make the GO spit out the variable name and the most optimized setting, at the end of the run (output dialog). ie:

Optimized results:
(Parameter, value)
JMA, 14
ZL, 28
Stop, 8
Target, 8

etc.

Mike

sure. until then, though. you can select the best performing result in the strategy analyzer and see the parameter in the grid (see attachment).

Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	587
Size:	105.8 KB
ID:	683  
Reply With Quote
Thanked by:
  #30 (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,399 since Jun 2009
Thanks Given: 33,175
Thanks Received: 101,541



piersh View Post
sure. until then, though. you can select the best performing result in the strategy analyzer and see the parameter in the grid (see attachment).

Yeah I know, but with a lot of parms it gets real messy real fast. If you can add it great, if not I can live.

Mike

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




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