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

  #61 (permalink)
piersh
California
 
Posts: 87 since Jun 2009
Thanks Given: 5
Thanks Received: 120


AynRandFan View Post
Piersh, As my very first post here, I want to thank you for the exceptional effort here with this optimizer -- it's an incredibly valuable tool that you've shared here with everybody! I truly wish I had something equally cool to share with you.... If you ever come to St. Paul, Minnesota, the beer is ABSOLUTELY on me. An absolutely massive contribution. Just incredible.

thanks for your kind words. i hope it helps you find a strategy that works for you.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
REcommedations for programming help
Sierra Chart
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #62 (permalink)
piersh
California
 
Posts: 87 since Jun 2009
Thanks Given: 5
Thanks Received: 120


AynRandFan View Post
Piersh, please forgive me for what is probably a stupid question, but is there some easy way to test out a strategy in multiple time periods? For example, testing a basic moving average strategy for 1 minute, 2 minutes, 3 minutes, 4 minutes... etc... all the way to 60 minutes, just as an example, --all in one long test? Again, I thank you for sharing this with everybody. I've been up the whole night (the past 2 nights!) playing with this thing... it's just awesome...!

not stupid at all - I have long wished there was a way to do exactly what you're asking for. but the Ninjatrader API is just too simplistic I believe that NT7 will support this, whenever that might be...

Reply With Quote
  #63 (permalink)
 
AynRandFan's Avatar
 AynRandFan 
St. Paul, MN.
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Zen-Fire
Trading: ES, equity options.
Posts: 22 since Sep 2009
Thanks Given: 10
Thanks Received: 52



piersh View Post
ok, this is where it gets silly.

v1.03 includes support for optimizing Enum parameter values. If your strategy has a parameter that's an Enum, then the right hand side of the optimizer options dialog will show a scrolling list of those parameters and the possible values that each one can have. check the boxes on the right next to each value to test that value. check the box on the left next to the parameter name to toggle all the checkboxes on the right.

as always, please let me know if you have any problems.

May I ask you for a bit more discussion on how you create something like this? This looks absolutely incredible... it's probably something simple that I'm just not grasping here at 4AM, but some discussion on creating something like this would be appreciated by others here on the forum as time rolls forward... I have no doubt about it. Thanks again for this incredible tool, Piersh -- I've used it to prove (to myself) the incredible value of trailing stops (I'm honestly stunned at the merit inherent in trailing stops), as well as another concept that seemed so far away from me just a few days ago (the value of much longer-term moving averages, particularly with Renko bars); Renko bars don't have a fixed time in any case, but they do have a fixed range -- longer-term moving averages play very well with Renko bars, and it's pretty crazy to think about 60-bar trades when the time used for each bar is undefined in the first place. Your tool has really made me grasp the market in a much more profound and deep way. Anyhow, if you could elaborate a bit more on the post above, (which I will try and quote, here), that would be very cool. Thanks again.

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


AynRandFan View Post
Piersh, please forgive me for what is probably a stupid question, but is there some easy way to test out a strategy in multiple time periods? For example, testing a basic moving average strategy for 1 minute, 2 minutes, 3 minutes, 4 minutes... etc... all the way to 60 minutes, just as an example, --all in one long test? Again, I thank you for sharing this with everybody. I've been up the whole night (the past 2 nights!) playing with this thing... it's just awesome...!

For optimizing with different time periods, why not using something like:
 
Code
                            
 Add(PeriodType.MinutefirstTP);
Add(PeriodType.MinutesecondTP); 
where firstTP and secondTP are parameters.
Then the optimizer can increment these parameters, that's it...

Follow me on Twitter Reply With Quote
  #65 (permalink)
piersh
California
 
Posts: 87 since Jun 2009
Thanks Given: 5
Thanks Received: 120


AynRandFan View Post
May I ask you for a bit more discussion on how you create something like this?

sure, first of all, make sure you're familiar with Enums.

now, if you expose a property on your strategy that is an Enum value, the optimizer will allow you to vary that property as part of the optimization.

for example, many of the indicators that come with NT have PriceTypeSupported set to true, which means you can change the dataseries mapped to the indicator's Input by changing the PriceType.

so... you can expose this PriceType property on your strategy, like this:

 
Code
                            
        [Category ("Parameters")]

        public 
PriceType PriceType
        
{
            
get { return _priceType; }
            
set _priceType value; }
        }
        
PriceType _priceType
then you can pass this value into the indicator when you add it:

 
Code
                            
        Indicator.Indicator _ema;


        protected 
override void Initialize()
        {
            
Add (_ema EMA (15));
            
_ema.PriceType this.PriceType;
            ... 
I'm keeping a reference to the indicator locally, so I don't have to keep initializing it later:

 
Code
                            
        protected override void OnBarUpdate ()

        {
            if (
_ema [0] > _ema [1])
                
EnterLong ();
            else
                
EnterShort ();
        } 
now when you run the optimizer, it'll show the following dialog:



which allows you to choose which values of PriceType you wish to test.

hope that helps!

Reply With Quote
  #66 (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,469 since Jun 2009
Thanks Given: 33,246
Thanks Received: 101,669


sam028 View Post
For optimizing with different time periods, why not using something like:
 
Code
                            
 Add(PeriodType.MinutefirstTP);
Add(PeriodType.MinutesecondTP); 
where firstTP and secondTP are parameters.
Then the optimizer can increment these parameters, that's it...

Won't work, the Add() method can not be optimized against. At least not by NT 6.5, supposed to be fixed in 7.

Unless piersh has a work around?

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
  #67 (permalink)
 
jackyd's Avatar
 jackyd 
Calgary Canada
 
Experience: Intermediate
Platform: Ninja
Broker: IB/Kinetic
Trading: 6E, CL
Posts: 47 since Jun 2009
Thanks Given: 44
Thanks Received: 20

Thanks Piersh for this wicked tool.

I have a question if you don't mind. In the EMA example you provided, is there a way to also access a plot/dataseries and still gain control over the price type the way you have outlined above?

For instance...

Say I wanted to use the DoubleMA indicator which has a plot called "Signal". I would usually do it in the OnBarUpdate something like this, but I wouldn't have control over the pricetype...

 
Code
_dmaSignal0 = DoubleMA(1, NinjaTrader.Indicator.DoubleMA_internal_DMAType.EMA, 1, NinjaTrader.Indicator.DoubleMA_internal_DMAType.EMA).Signal[0];

if (_dmaSignal0 > 0) ...
But, if I defined it in Initialize() as you have, it would look something like this...

 
Code
Add(_dma = DoubleMA(1, NinjaTrader.Indicator.DoubleMA_internal_DMAType.EMA, 1, NinjaTrader.Indicator.DoubleMA_internal_DMAType.EMA));
 _dma.PriceType = this.PriceType;
So, at this point, how would I reference the Signal plot that reflects the pricetype enum I want?

I tried a few things, but nothing seems to work for me.

Thanks

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


jackyd View Post
Thanks Piersh for this wicked tool.

I have a question if you don't mind. In the EMA example you provided, is there a way to also access a plot/dataseries and still gain control over the price type the way you have outlined above?

For instance...

Say I wanted to use the DoubleMA indicator which has a plot called "Signal". I would usually do it in the OnBarUpdate something like this, but I wouldn't have control over the pricetype...

 
Code
_dmaSignal0 = DoubleMA(1, NinjaTrader.Indicator.DoubleMA_internal_DMAType.EMA, 1, NinjaTrader.Indicator.DoubleMA_internal_DMAType.EMA).Signal[0];

if (_dmaSignal0 > 0) ...
But, if I defined it in Initialize() as you have, it would look something like this...

 
Code
Add(_dma = DoubleMA(1, NinjaTrader.Indicator.DoubleMA_internal_DMAType.EMA, 1, NinjaTrader.Indicator.DoubleMA_internal_DMAType.EMA));
 _dma.PriceType = this.PriceType;
So, at this point, how would I reference the Signal plot that reflects the pricetype enum I want?

I tried a few things, but nothing seems to work for me.

Thanks


you should be able to use

 
Code
                            
_dma.Signal[0
in your OnBarUpdate(), although I haven't tried that particular indicator in a while - i use my own that doesn't look as nice, but uses less CPU.

one cool thing you can do with DoubleMA is parameterize the MA types in the optimizer.

for example:
 
Code
                            
Add(_dma DoubleMA(_maPeriod1_maType1_maPeriod2_maType2)); 

add corresponding properties in your strategy for those parameters and the optimizer will try to find the best set...

Reply With Quote
  #69 (permalink)
 
jackyd's Avatar
 jackyd 
Calgary Canada
 
Experience: Intermediate
Platform: Ninja
Broker: IB/Kinetic
Trading: 6E, CL
Posts: 47 since Jun 2009
Thanks Given: 44
Thanks Received: 20


piersh View Post
you should be able to use

 
Code
                            
_dma.Signal[0

that's what I thought too, but it won't work for me. I did these tests...
 
Code
double test1 = DoubleMA(30, NinjaTrader.Indicator.DoubleMA_internal.DMAType.WMA, 30, NinjaTrader.Indicator.DoubleMA_internal.DMAType.WMA).Signal[0]; // compiles OK

double test2 = _dma[0]; // compiles OK

double test3 = _dma.Signal[0]; // doesn't compile
with the _dma.Signal[0] I get an error that the
Quoting 
NinjaTrader.Indicator.Indicator" does not contain a definition for Signal.

I think I'm missing something obvious, but not sure what.

It's very cool though, can't wait to start testing with it.

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



jackyd View Post


Quoting 
NinjaTrader.Indicator.Indicator" does not contain a definition for Signal.

It's very cool though, can't wait to start testing with it.

ah! try changing the declaration of _dma to
 
Code
                            
DoubleMA _dma

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