NinjaTrader Genetic Optimizer - futures io
futures io



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 68,322 views
    2. thumb_up 134 thanks given
    3. group 47 followers
    1. forum 197 posts
    2. attach_file 19 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

NinjaTrader Genetic Optimizer

(login for full post details)
  #1 (permalink)
piersh
California
 
 
Posts: 87 since Jun 2009
Thanks: 5 given, 119 received

Latest version (1.12), with NT7 support, is here

Hi All,

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


Installation Instructions:
- download the .ZIP file from the download link (above). NOTE: ignore the '1.09' in the filename - it's wrong, but i can't change it...
- in the main NT window, choose the "File->Utilities->Import NinjaScript" menu.
- when prompted, locate the downloaded .ZIP file
- 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.
- if you upgrade NT6.5, you'll need to re-install or uninstall the optimizer.

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 ;-)

- more info what's new here.
- brief instructions on how to optimize Enum values in your strategies, here.

Attached Thumbnails
Click image for larger version

Name:	Screenshot.png
Views:	1227
Size:	7.5 KB
ID:	153   Click image for larger version

Name:	Screenshot v1.03.png
Views:	2173
Size:	14.7 KB
ID:	1648  
Reply With Quote

Can you help answer these questions
from other members on futures io?
Experience with AGN (Introducing Broker)
Brokers
Eurex Denali vs dxFeed
Sierra Chart
1 min chart v-shape scan help please
ThinkOrSwim
TD Sequential for NT or MW?
Platforms and Indicators
For the experts of Metastock
Platforms and Indicators
 
 
(login for full post details)
  #2 (permalink)
 wh 
Neubrandenburg, Germany
 
Experience: Advanced
Platform: R
Trading: Stocks
 
wh's Avatar
 
Posts: 538 since Jun 2009
Thanks: 298 given, 505 received

please use this else error when you do on explorer ...
C:\Users\trading\Documents\NinjaTrader 6.5\bin\Custom\Strategy>rename @Strategy.cs @Strategy.cs.bak

Reply With Quote
 
(login for full post details)
  #3 (permalink)
 sam028 
Site Moderator
 
 
sam028's Avatar
 
Posts: 3,680 since Jun 2009
Thanks: 3,793 given, 4,519 received


It looks nice, but what did you add/modify ?
Is the % of Aliens are a random elements added during the selection process ?
Anyway, I'll test it, thx Piersh.

Follow me on Twitter Reply With Quote
The following user says Thank You to sam028 for this post:
 
(login for full post details)
  #4 (permalink)
piersh
California
 
 
Posts: 87 since Jun 2009
Thanks: 5 given, 119 received


sam028 View Post
It looks nice, but what did you add/modify ?
Is the % of Aliens are a random elements added during the selection process ?
Anyway, I'll test it, thx Piersh.

hi sam, it's pretty much a complete rewrite:
  • it uses a different way of extracting the tested strategy's score. it uses a hack in base Strategy.Dispose to get around a design flaw in NT - they don't expose the value being optimized to the optimizer . this allows you to use whichever scoring metric you like without modification. i removed the logging/threshold stuff since this it uses the same scoring as the analyzer. you can add this in your custom OptimizationTypes, if necessary.
  • it uses an integral representation of the parameter space that allows it to ensure that all children are unique - reducing the number of backtest runs that are required.
  • it uses a fitness weighting function to more naturally choose the parents of the next generation. the chance that an individual gets to procreate is on a probability curve, not a boolean function. this increases the richness of the gene pool by allowing worse-performing individuals to procreate (albeit with lower probablility than others)
  • it makes an attempt to determine when a maximum has been found and the parameter space is stable (ie. subsequent generations are unlikely to produce any better individuals). it does this by checking the top 'stability size' % of the population - if they're the same between two generations, then it considers the parameter space to be stable. at this point it blows away (almost) the whole history and starts over with the top 'reset size' % of the previous lot, seeds the rest of the new generation with aliens and continues. if you find it's resetting too much, try increasing the 'stability size' percentage (a value of 100 means it'll never reset).
  • between resets, it creates new generations from all previous generations. this is necessary since new children are now unique. i might add an aging function to reduce the probability of those crusty great-great-great-grandparents getting some action...
  • it adds aliens. aliens are completely randomly generated (none of their genes are derived in any way from other individuals). a certain configurable percentage of every new generation are aliens, the rest are normal (possibly mutated) children of the previous generations. I added this because I found that while it slows convergence somewhat, it allows a broader search of the parameter space, helping to avoid local maximums.

i have found, at least with the strategy i'm using to test with and fine-grained parameter settings (2 billion individuals), that the parameter surface is very bumpy and the algorithm likes to get caught at the top of some local maximum without getting closer to the optimal set. it'll find a good solution quickly, but not necessarily the best.

Reply With Quote
The following 11 users say Thank You to piersh for this post:
 
(login for full post details)
  #5 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 50,131 since Jun 2009
Thanks: 32,602 given, 98,790 received

This looks really interesting!


Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #6 (permalink)
 goforbroke01 
Chicago
 
Experience: Intermediate
Platform: NT
Broker: IB
 
Posts: 11 since Jun 2009
Thanks: 8 given, 1 received

Piersh

Great work! I have a question - do you have a way of making this compatible with the NT walk forward function? Currently, every time it rolls forward, it stops and waits for user input to confirm the GO parameters

thanks

Reply With Quote
 
(login for full post details)
  #7 (permalink)
piersh
California
 
 
Posts: 87 since Jun 2009
Thanks: 5 given, 119 received


goforbroke01 View Post
Piersh

Great work! I have a question - do you have a way of making this compatible with the NT walk forward function? Currently, every time it rolls forward, it stops and waits for user input to confirm the GO parameters

thanks

oops, sorry i hadn't tried with walkforward. i've uploaded a new version (to the original post above) which should help a little. please let me know if it still doesn't work for you.

Reply With Quote
The following 3 users say Thank You to piersh for this post:
 
(login for full post details)
  #8 (permalink)
 goforbroke01 
Chicago
 
Experience: Intermediate
Platform: NT
Broker: IB
 
Posts: 11 since Jun 2009
Thanks: 8 given, 1 received

Piersh

thanks for the fix - runs ok except that after the first full run through, subsequent runs don't display the GO params form. It may be that the walkthrough flag persists, not being reset after the job is complete.

-thanks

Reply With Quote
 
(login for full post details)
  #9 (permalink)
 Peter 
Brisbane; Australia
 
Experience: Intermediate
Platform: NT
Broker: IB/TDA needing new broker
Trading: Futures, Forex, Stocks
 
Peter's Avatar
 
Posts: 97 since Jun 2009
Thanks: 91 given, 113 received

Piersh, thanks a lot for this. First time user of GO and am very very impressed. Could have saved me weeks in working with the NT built-in. Finally my computer can work with 6 parameters at once instead of just 3 and that in a fraction of the time..

I saw a mail from -Swig- on the NT forum about optimizing e.g. running multiple moving averages via a trick of assigning numbers to the MAs. Did you ever try that with your GO?

Reply With Quote
The following user says Thank You to Peter for this post:
 
(login for full post details)
  #10 (permalink)
piersh
California
 
 
Posts: 87 since Jun 2009
Thanks: 5 given, 119 received



Peter View Post
I saw a mail from -Swig- on the NT forum about optimizing e.g. running multiple moving averages via a trick of assigning numbers to the MAs. Did you ever try that with your GO?

Yes indeed, I use Swig's neat trick in some of my strategies.

however, be warned that changing an MA (or MA combination) can have a drastic effect on the meaning of the other parameters, and the 'gene-splicing' of these other parameters makes little sense (in biological terms it's like cross breeding completely different species). this reasults in making the optimization surface much more bumpy, and the optimizer is more likely to get stuck in a local maximum. you might find that different runs of the optimizer will give you completely different results. I'm thinking that some kind of covariance decomposition would help with this, but that's a whole different kettle of fish.

Reply With Quote
The following user says Thank You to piersh for this post:


futures io Trading Community Platforms and Indicators NinjaTrader > NinjaTrader Genetic Optimizer


Last Updated on December 16, 2010


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing

Your Charts Should Speak To You w/Bob Cometta

Elite only
 

Our 12-year anniversary w/ $$,$$$ prizes (check soon)

August
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
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.
no new posts