HighTick


Van K. Tharp's System Quality Number Function

 

Book cover: the definitive guide to position sizing

Van K. Tharp proposed a formula for System Quality Number that measured strategy performance and could be used as a custom objective for optimizing strategy parameters.

The formula was presented in his recent book: The Definitive Guide to Position Sizing, published August 2008.

SQN = SquareRoot(TotalTrades) * AverageWins / ( StdDev of Wins )

 

 

 

 

Typical Usage

The function is called from a strategy when the LastBarOnChart is reached.

{ calling function from a strategy }

 

vars: SQN ( 0 );

 

arrays:

TradeArray[3000](0); { TradeArray may be loaded with function _LoadTradeArray }

 

if LastBarOnChart then begin

SQN = SystemQualityNr ( TradeArray ) ;

end;

Code Description

The function uses all in-line code, uses a faster algorithm for calculating Standard Deviation than the Tradestation's built-in StdDev function, and trade information passed to it in an array, TradeArray. It is called once at the end of a each strategy run, when the LastBarOnChart condition is reached.

The TradeArray may be loaded with all strategy trades using function LoadTradeArray. A description and code for the LoadTradeArray function is referenced below.

The System Quality Number value can be output, using FileAppend, along with other strategy performance statistics to optimize strategy input parameters beyond the built-in objective functions that are available within the Tradestation optimizer.

Downloads

Initial posted version: 09/14/09

Latest Update: 09/17/09

SystemQualityNr.ELD


( *.ELD files are compiled for TS 8.6. )

All ELD and code text files packaged here: SystemQualityNr.Zip


Users of earlier versions of Tradestation may compile the code
from the text files included in the above *.zip file.


The code may be visualized here:

Tharp's SystemQualityNr Function

 

The LoadTradeArray function may be found here:

Loading Strategy Trades Into An Array

 

Bookmark and Share