![]() |
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
|
|||||||
| NinjaScript File Sharing Discussion Discussion for shared NinjaScript files. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jul 2007
Location: Fairfax, VA
Posts: 216
Thanks: 0
Thanked 0 times in 0 posts
|
Updated: please download SQN.cs (for NT version 6.5) from the Genetic Optimizer thread in this forum. I don't want to maintain the file in 2 places and it is required for that optimizer as well. Thanks.
This is a new optimizer type for comparing strategies in the Strategy Analyzer called System Quality Number. The formula is SQN = sqrt(N) * average("Profit") / stddev("Profit") where N is the number of trades, which encourages a large number of trades, a large average profit, and a small standard deviation. You can read more about Ragingbull's description of this number in the original thread that I coded the optimizer from here: http://www.ninjatrader-support.com/v...ead.php?t=4320 To install, take SQN6 if you are running 6.0, or SQN if you are running 6.5. 1. Copy this to My Documents/Ninja Trader 6[.5]/bin/Custom/Type 2. Recompile any of your indicators or strategies -- this will cause the optimizer type to be compiled as well 3. "my system quality number" will show up in your list of optimizer types 4. The SQN value shows up in the Performance column on the grid (see attached screenshot) Keep in mind that as far as I know, this type of customization is not supported by NT, so if anything goes wrong, a reinstall may be your only recourse. Having said that, I have not had any issues thus far. Feel free to post issues in this thread and I will try to help.
Last edited by Pete S; 02-12-2008 at 05:47 AM.
Reason: Moved SQN.cs to Genetic Optimizer thread
|
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Dec 2007
Location: Guernsey (UK)
Posts: 152
Thanks: 0
Thanked 1 time in 1 post
|
Thanks very much for your work and to Raging Bull aswell.
You brought us a nice tool here!
Last edited by ryker; 12-13-2007 at 11:31 AM.
|
|
|
|
|
|
#3 |
|
Member
Join Date: Nov 2007
Posts: 40
Thanks: 7
Thanked 0 times in 0 posts
|
|
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
|
Hi,
I noticed the following 2 declaration in the SQN source file: public class SQN : OptimizationType { public static double sLastSQN; public static int sMinTrades = 0; This 2 variables are declared static. If you should ever create more than one instance of this class, then these variables are shared across all class instances. I am not sure this is intended behaviour, especially for sLastSQN. Regards Ralph |
|
|
|
|
|
#5 |
|
Member
Join Date: Jan 2008
Posts: 32
Thanks: 0
Thanked 0 times in 0 posts
|
Hi,
I'm running NT 6.5 so I need SQN.cs. I did a search but I came up empty. Can someone post a link to that file? Thanks, |
|
|
|
|
|
#6 | |
|
Senior Member
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
|
Quote:
|
|
|
|
|
|
|
#7 |
|
Senior Member
Join Date: May 2006
Location: , ,
Posts: 155
Thanks: 0
Thanked 0 times in 0 posts
|
Hi
I have attempted to load the update to your optimizer and receive this error message; Type\SQN6.cs NinjaTRaderStrategy TradeCp;;ectopm" does not contain a definition for 'performance" CS0117 Line 41 column 52 And same error message for line 42 column 33 Any Suggestions? Thanks Lynn |
|
|
|
|
|
#8 | |
|
Senior Member
Join Date: Jul 2008
Posts: 271
Thanks: 4
Thanked 7 times in 7 posts
|
Quote:
The system quality measure I'm more familiar with (via Van Tharp), described here can be reduced to SQN = net_profit/average_loss ...where average_loss doesn't include "scratch" losses where you lose only commission and slippage. That formula also encourages maximizing both profit and quantity of trades, and minimizing losses. Other trading platforms let you define your own custom optimization result. I'm still fairly new to NinjaTrader; doesn't NT let you do that too? -Alex |
|
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Apr 2008
Posts: 105
Thanks: 0
Thanked 1 time in 1 post
|
I have a question on the code. When you are going through each trade, you call several methods in the Trade class:
Code:
tradeProf = (t.ProfitPoints * t.Quantity * t.Entry.Instrument.MasterInstrument.PointValue); Quantity? Is that the number of contracts/Stocks traded in that transaction? How about PointValue? the value per point per contract in currency? So, say I trade 1 Contract of S&P Emini, at $50/point, and make 5 points that would be: tradeProf = 5 * 1 * 50 = 250 Is that what it is? Thanks! |
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Apr 2008
Posts: 105
Thanks: 0
Thanked 1 time in 1 post
|
I was asking about the code before because this SQN number looked familiar. I don't know who this Van Tharp guy is and I have not read his books; but I think he is claiming something that was published back in 1908. At least if he is claiming this as his discovery; but, again, I have not read his books.
What he calls "SQN" number, is actually the Student t statistics. You can read about it here: Wiki Student T I don't know, he may have been the first one to relate trading to statistics and that is why he is claiming it with that name (that is giving him the benefit of the doubt). I'm not a judge. But, definitely, it's not something "new". I can say this, however, it is useful. I don't think it will "increase" the number of trades; at least not in my experience. It does optimize the number of trades though. And I can tell you also that a big "SQN" number is not necessarily good. In fact, a big "SQN" number may be a sign of over-fitting. So, be aware of that. About the code, I would need to test some more; but I found it to increase rapidly after 2.5 or so and it would jump very fast. I am not sure why, I may be wrong. When I find it I will let you know. |
|
|
|
|
|
#11 |
|
Junior Member
Join Date: Oct 2008
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
|
HI everybody
I've developed a futures strategy. After some optimization with the SQN, I get an SQN = 3.4 with 500 trades ¿3.4.....What does it mean? ¿Dollars? ¿Points? ¿Percent..? ¿Is it good or bad? ¿Is SQN a better indicator than sharpe ratio? Regards |
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Sep 2008
Posts: 183
Thanks: 0
Thanked 1 time in 1 post
|
The SQN number isn't dollars, percent, or any other normal unit. It is just a unit-less measure of risk-adjusted performance (similar to the sharpe ratio). Higher numbers are better. If you want a more tangible number, look at something like cumulated profit, average trade %, etc. If you can get a 3.4 SQN with a few dozen actual or sim trades using realtime data (not historical data subject to curve fitting), then you are in very good shape. Whether the SQN is better than sharpe ratio is for you to decide based on your preferences for risk and return. In general, I slightly prefer it, since it doesn't penalize occasional very large winning periods the way the sharpe ratio does. My other favorite performance measure is a monthly Sortino Ratio, but it is not built-into NT.
|
|
|
|
|
|
#13 |
|
Junior Member
Join Date: Aug 2009
Posts: 15
Thanks: 0
Thanked 0 times in 0 posts
|
I'm getting an SQN of 6.9 with about 400 trades over 3 years, is that good ?
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Optimization function - System Quality Number | Ragingbull | Market Analyzer | 32 | 07-13-2009 12:16 PM |
| Problem with Optimizer | JC_Fernandes | Strategy Analyzer | 5 | 10-17-2007 04:55 AM |
| Optimizer Suggestion | NinjaTrader_Josh | Suggestions And Feedback | 2 | 08-12-2007 01:31 PM |
| about the optimizer | HelloHello | Strategy Development | 1 | 08-11-2007 03:07 AM |
| Bug in Optimizer | NinjaTrader_Josh | Suggestions And Feedback | 5 | 05-29-2007 02:02 AM |