![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Feb 2008
Location: Paris
Posts: 713
Thanks: 10
Thanked 10 times in 7 posts
|
I changed one of my strategy parameters from int to double and then ran the strategy optimizer. For example I ran from 2;4;0.5 (2-4 stepping by 0.5). The results had the same values for 2 & 2.5, and the same for 3 & 3.5. It look me a while to figure it out but what was happening was the optimizer was using int instead of double.
I closed the strategy analyzer and then opened a new one and it worked properly. |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
You were likely just still running on the old instance of your strategy with it being an int before.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 | |
|
Senior Member
Join Date: Feb 2008
Location: Paris
Posts: 713
Thanks: 10
Thanked 10 times in 7 posts
|
Quote:
I just thought I'd post it here in case you want to look into and/or if someone else notices weird behavior this could explain it. It took me a while to figure it out. |
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Jan 2009
Posts: 26
Thanks: 0
Thanked 0 times in 0 posts
|
I have a similar problem... when changing a variable and backtest/optimize the parameter doesn't "save". I have a large formula with about 20 variables.
I've tried shutting the Strategy Analyzer (SA) down and starting it back up again and the values are still set as they were before the SA was closed. Changing them has no effect. Even when I shut ninja trader down and start it back up I'm not be able to change the values. I have to go into the code, into the Variables and Properties to change the default values to be able to use them. What may be the problem? |
|
|
|
|
|
#5 | |
|
Senior Member
Join Date: Feb 2008
Location: Paris
Posts: 713
Thanks: 10
Thanked 10 times in 7 posts
|
Quote:
There's something that I consider weird going on but apparently it's as designed. When you run a backtest or the optimizer, Ninjatrader will initialize your strategy more than once. I found this out because I print out the instrument name in my strategy. So let's say I run backtest on ES, I see my strategy print out both ES & QM. I have no idea why QM! Could this be related? |
|
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Initialize() is called at several points in time. You will get several prints.
As far as "saving" values go, the optimizer doesn't "save" parameter values. You have to change it away from what you coded as the default if this is something you wanted to do. A 1;1;1 optimize doesn't optimize anything. This is why you may not see anything.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 | |
|
Senior Member
Join Date: Feb 2008
Location: Paris
Posts: 713
Thanks: 10
Thanked 10 times in 7 posts
|
Quote:
|
|
|
|
|
|
|
#8 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
If you run the optimizer on 1;1;1 it won't do anything. There is nothing to optimize.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#9 | |
|
Senior Member
Join Date: Feb 2008
Location: Paris
Posts: 713
Thanks: 10
Thanked 10 times in 7 posts
|
Quote:
![]() like: smaPeriod 10;20;5 optimize 1;1;1 if optimize = 1 it'll use the parameter values if optimize = 0 it'll ignore the parameter values and use my hardcoded values The reason I do this is because when I run live I want to be 100% sure I use the right parameters. So I hardcode them in the code. |
|
|
|
|
|
|
#10 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Then I am not sure what your concern is about.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Senior Member
Join Date: Feb 2008
Location: Paris
Posts: 713
Thanks: 10
Thanked 10 times in 7 posts
|
Because in my code I do something like this:
if(optimize==0) { smaPeriod = myHardcodedSmaPeriod; } And sometimes when I put optimize=1, it still uses my hardcoded value. So I run backtest with optimize=1 and then rerun the optimizer (not changing anything) and then it works properly. The fact that initialize is invoked several times may have something to do with it, I'm not sure.. |
|
|
|
|
|
#12 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Are you placing this code in Initialize()? Logic should NEVER be placed in Initialize().
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Feb 2008
Location: Paris
Posts: 713
Thanks: 10
Thanked 10 times in 7 posts
|
|
|
|
|
|
|
#14 |
|
Junior Member
Join Date: Jan 2009
Posts: 26
Thanks: 0
Thanked 0 times in 0 posts
|
Yes this is a similar issue I'm having.
When I say "save" I mean it doesn't hold the new new values when running the operation. It seems to be very erratic and hard to replicate - would be nice to give you a scenario. I have double varA = -99.5 for instance in the code and then I change it (either in optimize or backtest) to -100 (I have 20 or so variables). When running it the value it uses is still -99.5. If I close the strategy analyzer and reopen it, it makes no difference. I have to go into the code and change it. |
|
|
|
|
|
#15 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
cunparis,
Just ensure you have a new instance of the strategy running. pureporsche, Not sure what you mean. You cannot change anything unless you have actually made it a parameter.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Optimizer Type: Max. Expectancy | Elliott Wave | NinjaScript File Sharing Discussion | 7 | 05-01-2010 10:50 AM |
| New Optimizer Type: System Quality Number | Pete S | NinjaScript File Sharing Discussion | 12 | 11-25-2009 10:04 PM |
| Indicator: Creating a user-defined parameter type (enum) | NinjaTrader_Josh | Reference Samples | 0 | 09-24-2007 09:12 PM |
| Bug in Optimizer | NinjaTrader_Josh | Suggestions And Feedback | 5 | 05-29-2007 02:02 AM |
| Problem with 'Parameter Type' set to Price | codeye | Miscellaneous Support | 5 | 12-09-2005 07:06 AM |