HighTick
Van K. Tharp's Expectancy FunctionThis is a function proposed by Van K. Tharp in his book Trading Your Way to Financial Freedom (1999) as a way to measure strategy performance. Although Expectancy is not one of the objectives that the user can select when choosing how Tradestation will optimize a strategy (under View Chart Analysis Preferences), calculating Expectancy will allow the user to output this information for each strategy run to an external file which may contains the values of the variables being optimized along with several user defined objective functions for the strategy, such as Tharp's Expectancy, Tharp's System Quality Number or Sharpe Ratio. This external output file may then be imported into Excel, sorted in descending order by Expectancy, Sharpe Ratio, or any other user defined objective for strategy performance, to determine which parameter values are likely to produce the greatest returns. The Expectancy function is defined by Tharp as follows:
It is useful to annualize the result, making this objective more useful when comparing strategies that were run on different spans of time or on different trading vehicles that have been available for different periods of time:
Note that there are 365 calendar days in a year, but only an average of 252 trading days per year when weekends and holidays are accounted for. It is somewhat easier to count the number of days the strategy has been trading (StrategyTradingDays) than do deal with the date functions that calculate the number of calendar days between a Strategy Start Date and Strategy End Date, so my personal preference is to use StrategyTradingDays. However, either formula is equally valid.
UsageThis function is normally called from within the strategy when LastBarOnChart is reached. The following code illlustrates how the function may be called from within a strategy:
DownloadsInitial posted version: 09/09/09 Latest Update: 09/17/09 *.ELD files are compiled for TS 8.6. All ELD and code text files packaged here: Users of earlier versions of Tradestation may compile the code The code may be visualized here: How to call this function from your strategy: Sample Strategy Code to Call Function
|