NexusFi: Find Your Edge


Home Menu

 





Van Tharp's SQN (system quality number)


Discussion in Psychology and Money Management

Updated
      Top Posters
    1. looks_one Big Mike with 9 posts (2 thanks)
    2. looks_two Luger with 5 posts (9 thanks)
    3. looks_3 Sandpaddict with 4 posts (2 thanks)
    4. looks_4 Wikmar with 3 posts (4 thanks)
      Best Posters
    1. looks_one caprica with 2 thanks per post
    2. looks_two Luger with 1.8 thanks per post
    3. looks_3 Wikmar with 1.3 thanks per post
    4. looks_4 Big Mike with 0.2 thanks per post
    1. trending_up 44,470 views
    2. thumb_up 26 thanks given
    3. group 30 followers
    1. forum 42 posts
    2. attach_file 5 attachments




 
Search this Thread

Van Tharp's SQN (system quality number)

  #11 (permalink)
 Luger 
Nashville, TN
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: NQ ES
Posts: 468 since Feb 2011
Thanks Given: 323
Thanks Received: 543

@Big Mike

I am attaching your requested optimizer type. The new score considers Max Profit, SQN, Trades per Day, and the ratio of Long Profit to Short Profit.

There is one variable in there for the Long/Short Profit that is easy to change. I was not sure how sensitive you wanted this metric to be. I left comments in explaining.

//This value represents the floor to a divisor representing long short profit split
//0.1 = (60/40 split = 50/50 split = 40/60 split) performance would be halved at (70/30, 30/70)
//For a value of 0.05 (55/45 split = 50/50 split = 45/55 split)
//performance would be halved at (60/40, 40/60)
double rngLongShortBalance = 0.1;
//Actual calculation so that you can see what I am dividing by in the final output.
double rngLSbalance = Math.Max(rngLongShortBalance, Math.Abs(0.5 - (totLongProfit / totProfit)));

Basically, I thought you could use that variable to to set your own acceptable range outside of which there are reductions in the final score.

Otherwise the final score looks like this:

(SQN * Max Profit * Trades per Day) / (Long Short Ratio derivative)

To install place attached file in:
NinjaTrader7\bin\Custom\Type
Open Ninja Trader editor and compile any indicator or strategy

I am also going to take a look at the idea you mentioned about variation around a smooth upward sloping profit line as a possible improvement to the SQN number. Right now I can't visualize if that is going to be an improvement or end up causing problems somewhere.

Attached Files
Elite Membership required to download: SQNlsprofitbalancetraderate.cs
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
NexusFi Journal Challenge - April 2024
Feedback and Announcements
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
36 thanks
NexusFi site changelog and issues/problem reporting
22 thanks
The Program
20 thanks
GFIs1 1 DAX trade per day journal
19 thanks
  #12 (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,399 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,538


Luger View Post
@Big Mike

I am attaching your requested optimizer type. The new score considers Max Profit, SQN, Trades per Day, and the ratio of Long Profit to Short Profit.

There is one variable in there for the Long/Short Profit that is easy to change. I was not sure how sensitive you wanted this metric to be. I left comments in explaining.

//This value represents the floor to a divisor representing long short profit split
//0.1 = (60/40 split = 50/50 split = 40/60 split) performance would be halved at (70/30, 30/70)
//For a value of 0.05 (55/45 split = 50/50 split = 45/55 split)
//performance would be halved at (60/40, 40/60)
double rngLongShortBalance = 0.1;
//Actual calculation so that you can see what I am dividing by in the final output.
double rngLSbalance = Math.Max(rngLongShortBalance, Math.Abs(0.5 - (totLongProfit / totProfit)));

Basically, I thought you could use that variable to to set your own acceptable range outside of which there are reductions in the final score.

Otherwise the final score looks like this:

(SQN * Max Profit * Trades per Day) / (Long Short Ratio derivative)

To install place attached file in:
NinjaTrader7\bin\Custom\Type
Open Ninja Trader editor and compile any indicator or strategy

I am also going to take a look at the idea you mentioned about variation around a smooth upward sloping profit line as a possible improvement to the SQN number. Right now I can't visualize if that is going to be an improvement or end up causing problems somewhere.

You rock!

Mike

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
  #13 (permalink)
 Luger 
Nashville, TN
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: NQ ES
Posts: 468 since Feb 2011
Thanks Given: 323
Thanks Received: 543


I am attaching the Perfect Equity Curve (PEC) variants as well.

PEC
PEC * Max Profit
(PEC * Max Profit * Trades per Day) / (Long Short ratio derivative)

I would stay with the SQN and variants. The PEC versions truly do favor smoother curves at the expense of many other considerations. This ended up mostly an academic exercise, and I am posting just for anyone that is curious. Though I guess it could be used to check a smaller optimization field once the larger population has been narrowed down.

For example, I optimized one variable on my bot with just PEC. Usually the top few choices run from 58k-63k profit. Pure PEC gave me 22k for the first three, then got to some in the mid to upper 50k.

Attached Files
Elite Membership required to download: PEC.cs
Elite Membership required to download: PECmaxprofit.cs
Elite Membership required to download: PEClsprofitbalancetraderate.cs
Reply With Quote
  #14 (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,399 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,538


Luger View Post
I am attaching the Perfect Equity Curve (PEC) variants as well.

PEC
PEC * Max Profit
(PEC * Max Profit * Trades per Day) / (Long Short ratio derivative)

I would stay with the SQN and variants. The PEC versions truly do favor smoother curves at the expense of many other considerations. This ended up mostly an academic exercise, and I am posting just for anyone that is curious. Though I guess it could be used to check a smaller optimization field once the larger population has been narrowed down.

For example, I optimized one variable on my bot with just PEC. Usually the top few choices run from 58k-63k profit. Pure PEC gave me 22k for the first three, then got to some in the mid to upper 50k.

Thanks for this. What kind of sample size and trade frequency did you use in your test? I can imagine the fewer the trades, the more this will not make any sense.

Mike

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
  #15 (permalink)
 Luger 
Nashville, TN
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: NQ ES
Posts: 468 since Feb 2011
Thanks Given: 323
Thanks Received: 543

It was small numbers compared to what I know you are planning...lol

Range was from 60 to 170 trades for those weird results. The PEC results in general, even for the variants, are certainly much more rigid than SQN. Instead of comparing to trade results to average profit and compiling, you are comparing current cumulative profit to where current cumulative profit should be based on average profit (average profit * trade number) and compiling. Effectively the variance can accrue trade to trade.

Reply With Quote
  #16 (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,399 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,538


Luger View Post
I am attaching the Perfect Equity Curve (PEC) variants as well.

PEC
PEC * Max Profit
(PEC * Max Profit * Trades per Day) / (Long Short ratio derivative)

I would stay with the SQN and variants. The PEC versions truly do favor smoother curves at the expense of many other considerations. This ended up mostly an academic exercise, and I am posting just for anyone that is curious. Though I guess it could be used to check a smaller optimization field once the larger population has been narrowed down.

For example, I optimized one variable on my bot with just PEC. Usually the top few choices run from 58k-63k profit. Pure PEC gave me 22k for the first three, then got to some in the mid to upper 50k.

So far the PEC model seems to be performing very well. I am still wet behind the ears when it comes to Ninja and C#, I am having to re-learn stuff all over again after being out of it for years. But it seems that your code works. Once I get some more complex strategies converted, I'll know for sure

In my testing, the PEC model produces quicker [genetic time] and more desirable results than the other SQN types you provided.

Looking forward to it, and really want to thank you again.

Mike

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
  #17 (permalink)
 NW27 
Newcastle, Australia
 
Experience: Intermediate
Platform: Multicharts 8 - Full Version
Broker: IB
Trading: SPI,FTSE100, 6E, 6A
Posts: 285 since Oct 2010
Thanks Given: 108
Thanks Received: 188

Hi
Im very interested in this topic but Im a multicharts user.
Would you have this code in a pseudo form so that I can generate easylanguage code?

Regards,
Neil.

Reply With Quote
  #18 (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,399 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,538


NW27 View Post
Hi
Im very interested in this topic but Im a multicharts user.
Would you have this code in a pseudo form so that I can generate easylanguage code?

Regards,
Neil.

The source was posted already, MultiCharts uses C# for its optimizer type thing (whatever it is called). They don't document anything, so good luck finding the right keywords. It is not EasyLanguage.

Mike

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
  #19 (permalink)
 
Silver Dragon's Avatar
 Silver Dragon 
Cincinnati Ohio
Legendary Master Data Manipulator
 
Experience: Intermediate
Platform: TastyWorks / NT
Broker: TastyWorks /NT
Trading: FX, Stocks, Options
Posts: 2,107 since Feb 2011
Thanks Given: 6,422
Thanks Received: 5,238


Luger View Post
I am attaching the Perfect Equity Curve (PEC) variants as well.

PEC
PEC * Max Profit
(PEC * Max Profit * Trades per Day) / (Long Short ratio derivative)

I would stay with the SQN and variants. The PEC versions truly do favor smoother curves at the expense of many other considerations. This ended up mostly an academic exercise, and I am posting just for anyone that is curious. Though I guess it could be used to check a smaller optimization field once the larger population has been narrowed down.

For example, I optimized one variable on my bot with just PEC. Usually the top few choices run from 58k-63k profit. Pure PEC gave me 22k for the first three, then got to some in the mid to upper 50k.

@Luger

Trying to understand the code; What does this part of the code do?

SD

 
Code
for (n = 0; n < Strategy.Parameters.Count; n++)
		{
		if ("SQNMinTrades".CompareTo(Strategy.Parameters[n].Name) == 0)
			{
				minTrades = (int)Strategy.Parameters[n].Value;
				break;
			}

nosce te ipsum

You make your own opportunities in life.
Visit my NexusFi Trade Journal Reply With Quote
  #20 (permalink)
 Luger 
Nashville, TN
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: NQ ES
Posts: 468 since Feb 2011
Thanks Given: 323
Thanks Received: 543



Silver Dragon View Post
@Luger

Trying to understand the code; What does this part of the code do?

SD

 
Code
for (n = 0; n < Strategy.Parameters.Count; n++)
		{
		if ("SQNMinTrades".CompareTo(Strategy.Parameters[n].Name) == 0)
			{
				minTrades = (int)Strategy.Parameters[n].Value;
				break;
			}

It was in the original SQN code so I left it. If there are less than 30 trades, then SQN returns zero due to too small of a sample. I think that part also checks the number of parameters in the strategy and if there are more than 30, then that number becomes the floor.

I could be totally wrong. It would be nice to have someone who is a better coder to evaluate that section because it may just be wasting cpu cycles.

Reply With Quote
Thanked by:




Last Updated on May 12, 2021


© 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