Skip to main content

TradeStation bug when using both Open Next Bar and LIBB

Hunting down mis-match results between MultiWalk and TradeStation takes hours, even days, of my time..  Time that I have come to realize can always be better spent in other project and trading endeavors.  For that reason I am hesitant to spend time when someone contacts me about a mis-match between MW and TS results.  There has only been ONE time since the first release in 2018 that the mis-match was due to an issue within MultiWalk, and that was within a beta release, not an official release of MultiWalk.

There are many obvious reasons for the mis-match.  I have created a check-list for you here.  If you have a mis-match, please review that list.  The answer is normally there.  If you want MultiWalk to exactly match TradeStation results, enable the option “Calculate walkforward strategy using TradeStation” option on the Settings->Walkforward Options screen.

With that said, I recently decided to forensically determine the cause of a user reported mis-match when using that very option.  MW and TS should always match since MW is running the walkforward strategy using TradeStation’s API (application programming interface).  And, yet, in this situation is did not.  This option was supposed to remove such mis-matches.  MultiWalk is not providing the backtest results when using this option (as it does when using its own backtest emulator).

So how can there be a mis-match?  After days of drilling down into the mechanics of TS’s backtest engine and analyzing comparative results between TS’s API and Chart results, I pin-pointed the cause to the use of both “open next bar” and LIBB.  What took a moment to write here literally took days to determine.

The result is that we now have a workaround for this issue, which is to either not use “open next bar” or LIBB.  I would suggest to remove “open next bar” from your code if you can.

The Forensic Analysis

Here is a high level overview of the issue.

It started with this user’s post on Kevin’s Strategy Factory Forum:

Forum post reporting very different results from MultiWalk code run in TradeStation, with a TS equity curve and a MultiWalk equity chart

This is not supposed to be possible since MW is using TS’s API to calculate the results of the backtest.

Comparing the results between MW and TS reveals this:

Spreadsheet comparing API bars with TradeStation chart bars: chart is missing the 04/10/2007 2158 bar and duplicates the 04/11/2007 156 bar

This occurred on multiple different bars.  The results is that series functions, such as AvgTrueRange, Average, etc. gave different results since they were calculated on different bar values.  For this strategy, this resulted in different trade results, which was the reason for the mis-match in equity graphs between MW and TS.

Please understand that in this situation, MultiWalk is using TradeStation’s backtest engine to calculate the results.  MultiWalk is simply passing these results on for display in its reports and graphs.

So what happened on April 10 at 2158 hours and April 11 at 156 hours to create this issue?

TradeStation chart of @PL 238 min with a 1 min chart below, noting only one minute bar exists within the 238 minute bar on Apr 11, 2007

I identified this as the cause for every duplicated bar in TradeStation’s chart data stream.

The irony is that their API was correct and the chart results were incorrect.

This is the cause of the mis-match between MW and TS!

EasyLanguage code ending with Value99=Open Next Bar; callout says Open Next Bar combined with LIBB caused the mis-match

If I remove the “Open Next Bar” line from the user’s code, these are the results:

MultiWalk equity curve beside a TradeStation Strategy Performance Report equity curve, with a callout to remove the Open Next Bar line

MultiWalk data sheet and TradeStation Performance Summary both showing net profit of $87,550 after removing Open Next Bar

We now have a perfect match between MultiWalk and TradeStation.

I have posted this issue to the TradeStation Forum:

https://community.tradestation.com/Discussions/Topic.aspx?Topic_ID=225712

 

Table of Contents