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,071 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

  #31 (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:
- in the main NT window, go to the 'Tools->Edit Ninjascript->Indicator' menu
- select any indicator, and click OK
- click the 'compile' button (in the toolbar, to the right of the binoculars). alternatively, hit F5
- click 'OK' when the 'Indicator successfully generated' dialog appears.
- 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 ;-)

I backed up @strategy.cs simply by copying and pasting and renaming file to @strategy.cs.bk IS THAT CORRECT
Saved PHGo to proper file
Then when to Utilities and >Import Ninja Strategy. That is when it blew up again. Doesn't allow.
Suggestions?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
What broker to use for trading palladium futures
Commodities
ZombieSqueeze
Platforms and Indicators
Quant vue
Trading Reviews and Vendors
 
  #32 (permalink)
piersh
California
 
Posts: 87 since Jun 2009
Thanks Given: 5
Thanks Received: 120


CRCTrader View Post
I backed up @strategy.cs simply by copying and pasting and renaming file to @strategy.cs.bk IS THAT CORRECT
Saved PHGo to proper file
Then when to Utilities and >Import Ninja Strategy. That is when it blew up again. Doesn't allow.
Suggestions?

oh, sorry. please check the updated instructions. they now detail how to install.

one day i'll get around to improving this...

Reply With Quote
  #33 (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,463 since Jun 2009
Thanks Given: 33,239
Thanks Received: 101,661


piersh,

1.04 doesn't properly list the # of combinations it would seem. 1.03 was fine. For combinations, 1.04 is just outputting the instrument name.

ZN 09-09: PH Optimizer Start @ 7/23/2009 12:14:37 AM, combinations: ZN 09-09

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
  #34 (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,463 since Jun 2009
Thanks Given: 33,239
Thanks Received: 101,661

Hi piersh,

Also at some point of combinations, the error "Failed to call method Optimize for optimizer 'PHGenetic': Index was out of range." occurs.

I am not sure at what point this happens, but I have run into it a couple of times on a very complex money management strategy I am writing that auto adjusts multiple stops and targets, it has about 30 parameters to optimize, and some of those have a wide variety of values.

It is easy to work around, I just reduce the set of combinations, but wanted to make you aware of it incase you weren't. It may just be a limitation.

Last, I was wondering if you would consider adding a Stop time to the Output box, or an ETA so we know how long the job took to complete.

On a wish list, I'd like to see your own Window (like the options window) stay open during the optimization job and update with stats on-the-fly, would be very cool.

BTW, do you have a website? Are you accepting donations for your hard work?

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
  #35 (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,463 since Jun 2009
Thanks Given: 33,239
Thanks Received: 101,661

Oops - I just noticed you updated the first post to include the # of combinations fix. I will install it soon (in middle of a large job) and then I can report back some better figures perhaps to my last post.

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
  #36 (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,463 since Jun 2009
Thanks Given: 33,239
Thanks Received: 101,661

It seems to break when it goes above 4,096,xxx,xxx,xxx,xxx,xxx,xxx. I think that is understandable and clearly an enormous number. I will rewrite some of my logic so I can do with fewer optimization variables.

Here is the last one that was successful for me:

ZN 09-09: PH Optimizer Start @ 7/25/2009 5:34:42 AM, combinations: 3,976,005,110,290,448,384

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
  #37 (permalink)
piersh
California
 
Posts: 87 since Jun 2009
Thanks Given: 5
Thanks Received: 120


Big Mike View Post
It seems to break when it goes above 4,096,xxx,xxx,xxx,xxx,xxx,xxx. I think that is understandable and clearly an enormous number. I will rewrite some of my logic so I can do with fewer optimization variables.

Here is the last one that was successful for me:

ZN 09-09: PH Optimizer Start @ 7/25/2009 5:34:42 AM, combinations: 3,976,005,110,290,448,384

Mike

ok, the new limit is 79,228,162,514,264,337,593,543,950,335

if you hit that then you're out of luck ;-)

Reply With Quote
  #38 (permalink)
 
caprica's Avatar
 caprica 
USA
 
Experience: Master
Platform: NinjaTrader
Posts: 155 since Jul 2009
Thanks Given: 45
Thanks Received: 114

I optimize on things other than net profit and wonder if you could make this wonderful script display not just the performance of whatever I am optimizing on but also the net profit. For instance, many times I optimize on max expectancy but a high value will many times yield a very low net profit. I'd like to be able to see both as the optimization is progressing so I know when to abort the process.

So for instance if you optimize on something other than net profit, it would show:

ES 09-09: gen 1/20, 20.5 ips, PERF: [max 1.05, stability: 4.55], net profit: [$ 15,612.50]
ES 09-09: gen 2/20, 20.5 ips, PERF: [max 1.25, stability: 4.95], net profit: [$ 17,550.25]

Reply With Quote
  #39 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
Posts: 323 since Jun 2009

Piersh hi,
Great staf.
I have a question. Maybe you can help.
Its about Walk Forward. The sequence now in NT is:
Load min. bars required>optimize(Optimization period - min. bars required)>Load min. bars required>Test(Test period - min. bars required)> New Optimization (From date + Test period) etc.
My problem is that if Test Period is 7 days and min. bars required are 100 on a 10 min. time frame and a day session (8:30-15:15), this mean that 2 days are not tested.
Is there a way to move the "From Date" back on each iteration to achieve the correct sequence:
optimize(Optimization period)>Test(Test period)>New optimize.

Regards,
Baruch

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



caprica View Post
I optimize on things other than net profit and wonder if you could make this wonderful script display not just the performance of whatever I am optimizing on but also the net profit. For instance, many times I optimize on max expectancy but a high value will many times yield a very low net profit. I'd like to be able to see both as the optimization is progressing so I know when to abort the process.

So for instance if you optimize on something other than net profit, it would show:

ES 09-09: gen 1/20, 20.5 ips, PERF: [max 1.05, stability: 4.55], net profit: [$ 15,612.50]
ES 09-09: gen 2/20, 20.5 ips, PERF: [max 1.25, stability: 4.95], net profit: [$ 17,550.25]

unfortunately not, there's no way for the optimizer to get access to the underlying performance data required to do this.

my suggestion is that you build this rule into your scoring function. either as a weight, (eg. multiply your score by the net profit), or as a cut-off (eg. return double.NegativeInfinity for all scores with avg daily net profit less than a certain value).

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