Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Hello. I just uploaded this to the Ninja Strategies section. It is really a unique method to optimize your strategies on.
This is Van Tharp's System Quality Number (SQN) optimizer type for NinjaTrader. Place the SQN.cs file in your Documents\NinjaTrader 6.5\bin\custom\Type directory and then exit and reload Ninja.
Here is information from Ragingbull on SQN:
The code itself was written by Pete S all credit to him.
To use this you need to use Strategy Analyzer and change your "Optimize on..." selection to "my system quality number". This is where you normally choose max net profit, or max profit factor, etc.
Here is a brief PDF that is a sample only of the table of contents from the publisher of Van Tharp's book "Definitive Guide to Position Sizing", to whet your appetitive and interest you in purchasing this book.
I'm still trying to find the ideal fitness function. Net Profit / Drawdown as suggested here previously doesn't do it for me, as that ignores consistency and unrealized risk. The attached is the best I've come up with so far. For me the goal …
Thanks for your contribution towards helping everyone optimize their systems for SQN. I'm a big fan of Tharp's work as well.
However, I believe the formula you posted above is incorrect, or at least flawed in a big way.
From what I understand, Tharp basis is the risk of each trade, which he calls R. He uses the R-multiple of trades to calculate the SQN. However, the formula you posted doesn't use R at all. Since you are going by what someone else posted, I want to ask you to double check this. Please consider the following method of how I calculate the SQN for my trades. It's my interpretation of Tharp's words, but I may be wrong as well. What do you think?
1) Calculate R, how much you risk per trade. For example, if you risk 2% of your account on each trade, and you have a $10k account, R would be 200.
2) Calculate the R-multiple of each trade. For example, if R is 200 and a given trade had a net profit of 400, then the trade's R-multiple was 2. If it lost 200, then the R-multiple for that trade is -1.
3) Calculate E, the expectancy of the system. I interpret this to be the average R-multiple of all trades. If your system has a positive expectancy, this should be greater than zero.
4) Calculate SQN, the ratio of E to the standard deviation of the R multiples dataset in step 2.
Regarding the SQN*maxprofit you shared. Years ago I used a similar scoring system, but it also weighted based on trade frequency as well as long vs short. I am having trouble finding my old Optimizer Type code, so thought I would ask if you would code this, since I am so rusty with NT.
The idea is to expand on your SQN*maxprofit, adding:
1) Higher score for more trades per day. I value this because I believe if a system has a true edge, then greater frequency can demonstrate that edge by beating out slippage and commissions, and fight curve fitting.
2) Weight score based on Long vs Short performance. For example, if Long's account for 80% of profit, then this would score badly. Optimal would be 50/50.
Mike, I agree with your effort to sanity check the system and ensure that it's not long or short biased, but how do you account for the dataset bias?
If you were to take an data set for CL from the highs of 2008 till today, featuring a trend trading system, obviously you're going to generate more profit on the short side, simply because the entire market moved short a great deal (macro) from then till now.
I guess I would prefer to use the long/short ratios as a sanity check or post analysis screening criteria rather than an evaluation criteria (depending on the system's approach).
I do the same thing for profit distributions. Rarely (if ever) is a system able to hit high marks on every criteria (drawdown, expectancy, trade sample size, etc) and I find that some systems, I largely rejected simply because it earned too high of a profit% in a couple of months during the sample. Obviously, we'd all love a consistent profit distribution where every month is similar. But in reality, the markets don't feed us that way, and it's difficult to massage a system to vary depending on the market conditions (sometimes).
So now I look at the distributions and as long as all the profit isn't in one or 2 months AND there's little to no negative months, then that's okay. I call it the "fishing" centric systems, that wait (patiently) for those few time periods that really kill it, then during the other time periods they either hold flat or lose a very small amount.
Obviously that's asking a lot (for a trader to sit and fish for months waiting on the whopper months) but it's exactly what a lot of Fundamental traders do. There are a lot of fundamental traders that will make their whole year based on a couple of good months. Which really capitalizes on the concept of big winners and tiny losers.
"A dumb man never learns. A smart man learns from his own failure and success. But a wise man learns from the failure and success of others."
Yes absolutely. I basically write two kinds of strategies, small time frame and big time frame. For the small time frame system I believe the 50/50 split is realistic because the amount of time in the market is minimal per trade, it is not influenced heavily by bigger trends.
I wish I could find my old code, I spent a huge amount of time developing that optimizer type just the way I wanted it. It is in a backup file somewhere.
I cannot remember all the reserve keywords with NT, so am having trouble remembering how I had mine set up.
If there are 100 trades total, 50 long, 50 short, but the 50 longs account for 80% of the profit, I want this to score badly. My strategy is not written well if it takes 50 short trades that only account for 20% of the profit compared to long trades.
I had a lot of code in my optimizer setup to prevent curve fitting. I also prefer to optimize against huge data sets, multi-year of tick data, with thousands of trades per year. I'll keep digging for it.