NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > Application Technical Support > Strategy Analyzer

Strategy Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer.

Reply
 
Thread Tools Display Modes
Old 10-31-2011, 10:09 AM   #16
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

ch9090,

No problem.

Are you attempting to only avoid a profit factor of 99? Do you want profit factors > 99? This is a massive profit factor, but I suppose it would be possible.

Please let me know if I may assist further.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 10-31-2011, 12:44 PM   #17
ch9090
Senior Member
 
Join Date: Aug 2011
Location: Belgium
Posts: 151
Thanks: 42
Thanked 3 times in 3 posts
Default

I am really trying to avoid a PF of 99 which usually is associated with 1 or 2 trades only.

That is why a combination of PF < 99 and # of trades > 10 should produce more relevant optimized parameters for my simple strategy.

chris
ch9090 is offline  
Reply With Quote
Old 11-02-2011, 06:11 AM   #18
ch9090
Senior Member
 
Join Date: Aug 2011
Location: Belgium
Posts: 151
Thanks: 42
Thanked 3 times in 3 posts
Default

I've run some optimizations and it still returns a PF of 99 based on a few trades... Any additional ideas?
ch9090 is offline  
Reply With Quote
Old 11-02-2011, 07:51 AM   #19
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

ch9090,

Are you able to add the new optimization type in the Optimization properties > "Optimize on" field?
NinjaTrader_AdamP is offline  
Reply With Quote
Old 11-02-2011, 08:06 AM   #20
ch9090
Senior Member
 
Join Date: Aug 2011
Location: Belgium
Posts: 151
Thanks: 42
Thanked 3 times in 3 posts
Default

Hi Adam,

Absolutely and I've used your suggestion for the code i.e.

if (systemPerformance.AllTrades.TradesPerformance.Pro fitFactor < 99 && systemPerformance.AllTrades.TradesCount < 10)
return 0;
else
return (double) systemPerformance.AllTrades.TradesPerformance.Prof itFactor;
ch9090 is offline  
Reply With Quote
Old 11-02-2011, 08:14 AM   #21
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

This might be the problem : systemPerformance.AllTrades.TradesPerformance.Pro fitFactor < 99

It can still return 99 since if ProfitFactor = 99, then this condition fails, and it can return the profit factor.

I believe you want to use something like,

if( ProfitFactor < 99 && NumberTrades>=10 )
{
return ProfitFactor;
}
else
{
return 0;
}
NinjaTrader_AdamP is offline  
Reply With Quote
Old 11-07-2011, 07:21 AM   #22
ch9090
Senior Member
 
Join Date: Aug 2011
Location: Belgium
Posts: 151
Thanks: 42
Thanked 3 times in 3 posts
Default

Hi Adam,

You were right, the logic was flawed!

I hope I do understand the code correctly now:

1) the strategy PF factor will be optimized based on two conditions (PF<99 and # trades >=10).
2) the "else return 0" just means it will force the optimization?

I am asking this because so far my tests are returning good results (# of trades >= 10 and PF < 99) but I am not sure how to interpret the "return 0" since we're using bolean operators here?

Cheers, chris
ch9090 is offline  
Reply With Quote
Old 11-07-2011, 07:47 AM   #23
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

CH9090

Essentially, there are still optimization runs that are returning profit factors greater than 99 but you are intercepting them and returning a profit factor of 0 instead of the real profit factor. You are only using the booleans as logical operators to do the interception, however you are still returning the actual calculated profit factor when its less than 99 and there were more than 10 trades.
NinjaTrader_AdamP is offline  
Reply With Quote
The following user says thank you to NinjaTrader_AdamP for this post:
Old 11-07-2011, 09:12 AM   #24
ch9090
Senior Member
 
Join Date: Aug 2011
Location: Belgium
Posts: 151
Thanks: 42
Thanked 3 times in 3 posts
Default

Dear Adam,

Many thanks for the quick reply.

I've been running a few dozens (if not hundreds) of optimization runs now and I never saw a PF > 99.

If I am not mistaken it is defined as (gross profit/gross loss) and when "gross loss" is 0 it returns a PF of 99 (instead of infinite). In theory you could have a PF > 99, but again I never saw one. Have you?

I optimize also on "aggregated results" and even if the optimization returns a few PF=99 for some individuals stocks, the PF of the "combined results" is always well below 99. I guess it means that your custom optimization works fine and I would even say that the results are more reliable compared to optimizing on the PF factor only.

Cheers,
Chris
ch9090 is offline  
Reply With Quote
Old 11-07-2011, 09:36 AM   #25
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

Quote:
Originally Posted by ch9090 View Post
Dear Adam,

Many thanks for the quick reply.

I've been running a few dozens (if not hundreds) of optimization runs now and I never saw a PF > 99.

If I am not mistaken it is defined as (gross profit/gross loss) and when "gross loss" is 0 it returns a PF of 99 (instead of infinite). In theory you could have a PF > 99, but again I never saw one. Have you?

I optimize also on "aggregated results" and even if the optimization returns a few PF=99 for some individuals stocks, the PF of the "combined results" is always well below 99. I guess it means that your custom optimization works fine and I would even say that the results are more reliable compared to optimizing on the PF factor only.

Cheers,
Chris
Chris,

What is probably happening is that NinjaTrader catches a profit factor of NaN, i.e. X / 0 and setting it to 99 or something since 99 is a ridiculously high profit factor. I've never seen any long term running strategy pull off that level let alone more.

Anyway, I am glad its working out for you.

Please let me know if I may assist further.
NinjaTrader_AdamP is offline  
Reply With Quote
The following user says thank you to NinjaTrader_AdamP for this post:
Old 11-08-2011, 03:42 AM   #26
ch9090
Senior Member
 
Join Date: Aug 2011
Location: Belgium
Posts: 151
Thanks: 42
Thanked 3 times in 3 posts
Default

Thank you Adam, all clear now until my next post :-)
ch9090 is offline  
Reply With Quote
Reply

Tags
1 trade only, high results, optimizer

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fibbonacci Retracements on Bond Charts Display non-tick based results ATX_tdr Charting 1 07-21-2011 01:43 AM
Looking for trade size based indicator dbissett Indicator Development 1 07-18-2010 10:59 PM
Trade based on 2nd chart shazzmoe Automated Trading 7 02-17-2010 11:57 AM
How to enter a trade based on time KeelRisk Strategy Development 1 08-19-2009 06:12 AM
Stop Trading Based on Results daven Automated Trading 1 06-24-2009 05:59 AM


All times are GMT -6. The time now is 05:59 PM.