Quick question haven't been able to find the answer to. I am running an intraday strategy on Wealth-Lab (not Pro) on 200+ symbols with 5-min data. If I run this backtest consecutively, I receive the same results, HOWEVER if after running this strategy on all data, I proceed to run in on a single symbol, and then run it again on all data, the all-data backtest outputs a different P&L! I notice that the trades taken on the former and latter all-data backtests are completely different. What am I missing? Is there a maximum number of symbols that you can backtest at once on intraday data?

Thank you for your response. However, I would like to see the result of taking EVERY trade in one backtest. So to do this I did a little test. There should be about 4000 trades in an all-data backtest and most of the stocks are under $20. So I set my capital at $20M and a fixed position size of 100 shares. Yet, the backtest still only generates about 50 trades. At an average cost of $20/share, each position requires $2000 about. With $20M in capital, I should roughly be able to handle 2000 positions at once. But the test doesn't come near that.

Maybe I am still missing something? Do I still need to work with "priorities" even if the capital is so large?

First of all, your strategy peeks into the future. You can't just use *AtStop(bar) the way you did that in real life because the High/Low prices of the bar are not available until close. I mean, for example, lines 142 and 163. Please see this KB article for more:Bars, Loops, and Bar + 1

Your code will not generate a single alert because you're passing bar-1 to the trading functions (instead of bar+1). Please review the KB article link above.

In addition, your code is somewhat too long to be readable, would you mind creating a more compact version for troubleshooting by creating dummy conditions instead of the actual production logic? Thank you.

- just check to make sure that it's sufficiently high to enable the purchase of at least 1 share. In other words, if your RP size is $1,000, you won't be able to create trades on BRK/B (trading around $3000/share), for example, since even in RP mode you cannot buy 1 share.

I've created a simplified version, in some cases simply using written text to convey what I am trying to accomplish. This may be a start to help figure out the problem I having. And in response to Cone, I've attempted to use Raw Profit Mode by setting a Fixed Position Size to enter with on every trade, rather than setting a Fixed Dollar amount per trade. Because of this, I should not be having any problems related to lack of available funds. Thanks for your input though.

Also, as of now, I am not too interested in having the strategy generate alerts. I just want to be able to generate a backtest with every single trade so that I can determine if the strategy is even profitable across a broad range of securities.

QUOTE:It turns out that this is a good technique to developing a program or application - break it down into small parts so that you can concentrate on a manageable piece. Start with one piece, define the specific requirements, and think about how you'll integrate it into the finished product.

What was on my mind is not explaining the rules in plain English, but rather stripping them out completely, leaving just a skeleton with the structure. Rules are well could be random entries and exits. Anyway, it's not important. To generate a backtest with every single trade, you need to fix the obvious peeking errors (SellAtStop(bar-1), BuyAtStop(bar) etc). This is a prerequisite to determine the number of signals in Raw Profit mode. After troubleshooting your code and verifying that it works according to your design, it becomes reasonable to approach the portfolio backtest mode.

Thanks for your patience with this. In regards to peeking, I am a bit confused. How is "SellAtStop(bar - 1)" considered code that peeks, given that the referenced bar has already closed. Although, admittedly, it seems unorthodox to me, given that the position is not closed until the ensuing bar, it does not seem to be an example of peeking. Am I incorrect here? Having read the KB article you sent me, I understand passing "bar + 1" to a trading signal to avoid entering a position on the open, while utilizing an indicator value that is calculated at the close. I certainly understand this as peeking. But I am not quite sure I understand "peeking" in reference to how I have utilized "bar - 1".

Also, I certainly agree that building a program in increments is more simple to manage. In fact, I did just that with this program, starting with the trade setup, working to entries, and then finishing off with exits. How would you like me to better convey the skeleton of the program?

QUOTE: But I am not quite sure I understand "peeking" in reference to how I have utilized "bar - 1".

Imagine you have created a position today (bar) on a stop (let's put aside the fact that it's impossible to enter on a stop at bar, utilizing the high(bar) price), how could you close that position yesterday with sellatstop(bar-1) ?

How would you suggest entering a position on a stop? Could you do the following:

CODE:Please log in to see this code.

What I don't like about this solution is that although the position is recorded as entered on the correct bar, the strategy does not actually record the entry until the following bar. It does not seem possible to me to utilize the bar + 1 setup when entering on stops.

Okay, it's Thursday night, and lets say you want to buy on a stop if MSFT hits 21 on Friday. Further, lets assume that MSFT does cross 21 tomorrow and closes at 22. How will you enter this order with your broker?

Are you going wait until Monday to place your order for the previous bar (bar - 1), or, are you going to enter your stop order tonight (or any time on or before the opening bell) so that it can be live tomorrow when the price event takes place?

Oh, I think Cone's comment sparked a realization! Prior to using WealthLab, I used eSignal, whose broker language required that I enter the prices at which positions were either opened and closed. This language had no way to decide if my stop price was hit or not; it simply executed and I had to use conditional statements to control access to this broker language. But with WealthLab, it seems as though the broker terms, such as BuyAtStop and SellAtStop, will only execute if the indicated price is hit. Am I correct about this?

sunyata, i was looking at your code and thought for a second i was looking at some of my code with all of the PrintDebug("got here") messages. fwiw, i downloaded and installed SharpDevelop (it's free) and followed Eugene's very well written links on how to debug strategy code using SharpDevelop. It's saved me hours since. Just in case your not familiar with it. At the top of this forum post are the links to the directions:/Forum/Posts/Is-it-possible-to-debug-into-stepping-the-code-lik-29198

We sent an Verification
Code to your email address. If you don't receive this code within the next 5 minutes.
Please click here to
request a new code.
New Verification Code sent. Please check your Inbox.Please enter your Email to receive a new Verification Code