Performance versus reality
Author: BCode
Creation Date: 9/12/2016 9:39 PM
profile picture


I have recently started writing my own strategies in Wealth Lab and evaluating their performance over different scales. I have noticed an issue with how the purchase price and sale price are reported relative to the time frame in which the strategy was evaluated.

This may seem confusing, so let me break it down.

Scale:15 minutes (so every 15 minutes my strategy is run)
For each 15 minute bar there is an "open" (at the beginning of the first minute) and "close" (at the last second of the 15th minute).
So on the 15th minute my strategy is run, and say for instance my MACD crosses and my program is supposed to execute a BuyAtMarket. The price it reports as the buy price is the "open" price of the bar which occurred 15 minutes before I could actually make the purchase. Since the price was rising, the actual price I could purchase the stock at is significantly higher and thus affects the profit margin.
This is true for my sell orders as well (SellAtMarket) (the stock price is decreasing and thus the MACD crosses again) which means the price at which I can actually sell the stock is typically much lower than reported by Wealth Lab.

Is there a way to change how Wealth Lab reports the purchase price based on the signals it gets from my code or will it always revert to the "open" price?

Any help would be great. It is really hard to evaluate the success of a program if the software doesn't actually do what it says it is doing.

profile picture


Hi Brian. Thanks for the question.
If you take a look at the many examples of scripts included with Wealth-Lab (and those that can be downloaded from the "Strategy Download" feature in the Strategy Explorer: Ctrl+O), you'll see that the bar number passed to all Buy/SellAtMarket, Buy/SellAtLimit, and Buy/SellAtStop orders is bar + 1, not just bar.

Using bar + 1, is important for 2 reasons: 1) Precisely for the reason you described - when you detect a trigger, you need to buy on the next bar, and, 2) you must pass a bar number greater than the last bar of the chart to trigger a trading "Alert". In other words, if the trigger condition occurs on the last bar of the chart, passing bar + 1 to a trading signal (BuyAt, SellAt, etc) will generate an actionable Alert.

If you still have doubts, let us know!
profile picture


Yes, I used (bar+1) initially but hoped I could get a much more real time purchase buy making it (bar). In reality it is now clear I was forcing a purchase from the past. Thanks for the clarification. I'll adjust my strategy to compensate for this.

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).