< All Topics

TradeStation “Fast Calculation” (FC) functions.

TradeStation supplies “Fast Calculation” counterparts to several of their functions. For example, you could theoretically use Average() or AverageFC() and obtain the same results. AverageFC() is simply much faster.

However, there are situations where FC functions yield inaccurate results due to (1) a bug in TS’s FC functions and (2) their use with walkforward strategies if you optimize the length parameter to the function.

I have written WFSafe replacements for these FC functions to correct both of the above issues. If you would like to understand more of the issues, read on. Otherwise, please click here for a list of WFSafe versions of the functions.

Issue #1

All the FC functions use the keyword CurrentBar. There is a known bug in TradeStation where there are situations when CurrentBar will never equal “1” for the first bar in a strategy. Instead, it skips “1” and starts at “2”.

I was working through this issue with TS support some time ago and actually got a phone call from Chris Davey, who was an excellent support tech at TS support. He explained the issue and the fix.  See our conversation on the TS forum here: https://community.tradestation.com/Discussions/Topic.aspx?Topic_ID=163834

If you have code in your strategy such as:

if ( CurrentBar = 1 ) then
    // do this...

There are situations, such as in multi-time frame strategies, where your if-then conditional code will never be executed since CurrentBar will never equal 1.

The fix to this is to use BarNumber instead of CurrentBar. BarNumber will always work.

Issue #2

If you create a walkforward strategy that optimizes the length of the FC function, the results will not be correct since TS’s FC functions assume that the length parameter will never change.  Therefore the first length parameter you pass it will be used for the entire lifetime of the strategy.

It was trickier correcting this behavior since the beauty of FC functions is that they are fast since they do not recalculate the entire average on every bar.  However, when the length parameter changes, the average must be recalcuated at the time of the length change so that the FC results will continue to be correct after.

See the header notes and actual code of WFSafe_SummationFC for the actual implementation.

Table of Contents