Why is WL6.1 missing some trades (EMA)?
Author: evan100
Creation Date: 6/5/2011 7:14 PM
profile picture

evan100

#1
Hi,

I recently spent a considerable amount of time backtesting trading strategies on Wealth Lab Pro Version 6.1. I correlated the hypothetical trades on Wealth Lab Pro with what my actual trades would have been and found that Wealth Lab Pro missed a considerable number of actual trades. I am thankful that I discovered this prior to implementing these strategies with real money but am quite irritated that Fidelity would release such an error prone program. Has anyone else encountered this problem?
profile picture

DaveAronow

#2
This is analogous to finding a compiler bug when you're programming in Visual C++. Yes there is a 1/1000000 chance you found a bug, but it always turns out to be user error. Google PEBCAK.

Why don't you post the details of your issue and see if it is an actual problem or if you are misusing the software? Posting that it doesn't work without any details is useless for you and anyone else (especially if you really did find an issue). Based on your description it sounds as if you are not using enough cash for the simulations and you are not clear how trades get skipped under this scenario.

Regards,
Dave
profile picture

novendeh

#3
I agree with Dave's comment. Recently I had a problem and thought there was something wrong with the simulation portion of WL 6. After posting the code and explaining in detail, Eugene did a great job in helping me understand how WL works, improving my coding, and explaining of my mis-understanding of the simulation mode. Posting details of the problem really helps it get resolved quickly. The folks who respond to questions/problems on this site are really extremely knowledgeable.
profile picture

evan100

#4
An example of this is I used the backtesting function for VTI from 1/1/09 to the present with a 50 vs 200 day moving average crossover for a buy and a sell. The performance stated that no trades were perfomed over this time period. However there were moving average crossovers during this time period therefore trades should have been performed. This happened many times. I was using the drag and drop "build and backtest function" and my data was from yahoo finance. If these were user errors then please explain to me how to correct them.
profile picture

Eugene

#5
evan100,

Your report misses the key fact: position sizing. For your future reference: How to properly report a Problem?

I have not really that much to add to Dave's reply. Most likely, and based on experience and the fact that you never mentioned your position sizing settings (which is by far the most influential aspect in this context), it's the lack of capital to take the trade due to a position size near 100% (of course the actual size/percentage can be much less if it's a portfolio). Read this carefully:

Wealth-Lab User Guide > Strategy Window > Backtesting Strategies > 100% of Equity Sizing
profile picture

evan100

#6
I appreciate your suggestion and read page 95 of the manual but it did not fix the problem. I ran this backtest with a single ETF and a fixed position of $10,000 as well as 100 shares, both of which resulted in the same erroneous result. If you have any other suggestions them please share them with me.
profile picture

Eugene

#7
The link above also suggests to provide such information as your Data Loading Control settings. Thanks in advance for saving the forum from guesswork next time. ;)

How many bars of data did you load? Hint: should be 200 bars minimum or an equivalent amount of data loaded e.g. >= 1 year. The point here is that if there wasn't enough data loaded, you won't see any trades.
profile picture

evan100

#8
The results say that I have loaded 609 bars of data. The test was run from 1/1/09. Therefore this should meet the above criteria and does not explain the results. Please share any other suggestions.
profile picture

Eugene

#9
Again for the Nth time both the technician(s) and the community members tell the same thing: you are not providing the details of your issue properly. This is why the checklist above should be used as the guideline. The rule is to minimize the guesswork involved so that we can effectively provide a solution/explanation of the issue. As the ancients said, "A wise man's question contains half the answer."

Please provide the essential information:

* Which exact Rules did you use to build that particular strategy? Don't forget to include the exit rules, and the DataSeries used for each moving average (we know the periods).

Type them in here exactly as they appear in the wizard or take and upload a screenshot, click the "IMG" button and paste the URL in between the pair of IMG tags that appeared.


P.S. You might want to include the trading costs and Symbol Info Manager settings (if used).
profile picture

evan100

#10
Wealth Lab Pro Version 6.1 64 bit edition
Scale: Daily
Date Range: 1/1/09 to 6/2/11
Position Size: $10,000
Data Sets: VTI either from Yahoo Finance or Fidelity
Rules using pulldown menu:

Buy at close > Fast moving average crosses above slow moving average (EMAModern, Close, Fast period 50, Slow period 200, Single open position)
Sell at close > Fast moving average crosses below slow moving average (EMAModern, Close, Fast period 50, Slow period 200, Single open position)

Performance: 0 trades and 0 profit

The above is exactly what I entered. I appreciate your patience and if there is any other data that I am leaving out then please let me know.
profile picture

Eugene

#11
Thank you.

With Yahoo data, there were NO crossovers during that date range. The fast moving average (the 50-day EMA) have not crossed the 200-day EMA, even once. At the risk of repeating: there was NO crossover, including (and especially) 09/01/2010.

Even though it is very easy to see on a chart of VTI that the fast MA never came closer to the slow MA than 1% (ONE percent) on 09/01/2010, let me suggest taking a look in the manual. Hit F11, start typing the first letters of CrossOver, and note what does a CrossOver/CrossUnder mean.
profile picture

Cone

#12
For sure there's much better than a 1/1000000 chance finding a bug in WLP. As we mention in Our Support Policy, the source of a problem is often not clear and we'll work with you to discover what's going on. In this case, the key is that you're not loading enough data. Let's explain this in steps.

First, it's of great importance that you know that WLP will only work with the data that you load in the chart or any other tool. (This is different than AT Pro.)

Second, an EMA is a special type of indicator (essentially an IIR filter); in layman's terms we refer to this class of indicator as "unstable". For a discussion on this, please see Help > WealthScript Programming Guide > Indicators > Stability of Indicators. As you'll read, the rule of thumb is that unstable indicators require three times their period to reach stability in their values at a particular bar.

Putting it all together, for a 200-bar EMA you should load at least 600 bars before starting to look for trades. Nonetheless, the "FirstValidValue" reported by EMA is it's period bars (200 in this case), and you may consider that a bug. However, this was a design decision because it's possible that you won't have 3x the seed data required for a particular instrument, but you want to use the EMA anyway.

The only solution here is to make sure you properly seed your unstable indicators, open the Strategy in a Strategy Window, and adjust the starting bar of the trading loop like this:

CODE:
Please log in to see this code.
profile picture

evan100

#13
Eugene,

The 50 EMA daily clearly crossed the 200 EMA daily from below in July of 2010 on my stockcharts daily chart of VTI which should have triggered a buy signal. Since my dates began at 1/1/09, this trade was clearly missed by Wealth Lab Pro when I used both the Fidelity and Yahoo Finance data.

profile picture

Eugene

#14
That's a serious argument: WL should blindly do what my 3rd party chart does regardless of a) difference in EMA calculation [you probably noticed there's EMAModern and EMALegacy, which dialect does stocksharts speak?] and other factors such as b) possibly different OHLC [different vendor, dividend/split adjustment applied or not, different adjustment formula] and c) likely different data loading range (as stressed by Cone's reply above).
profile picture

Cone

#15
Let's make this crystal clear for all the readers right here. The following charts are running the EMA 50/200 crossover system described above. The only difference is the number of bars loaded in each chart - 400, 600, 800, and 1000 bars. Note that some crossovers still change "dates" between the 800 and 1000-bar charts.









I hope it's clear now!
profile picture

evan100

#16
Cone,

Thank you very much for the great explanation. When I reran the backtests with a larger data set (at least 3.5x the longest moving average) Wealth Lab Pro picks up all of the trades. I have regained my confidence in this software.
profile picture

Cone

#17
Whew, almost lost one! :)
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).