I am getting suspiciously good outcome with a test so I suspect I'm doing something wrong. I've dragged and dropped only (no code writing). I want to backtest a strategy where I use a dataset of say, nasdaq 100 stocks, and trade weekly on Mondays, buy with price greater than 5, volume greater than 100,000, price above MA200 and below MA5, RSI 2-day below 5, and sell one week later on Monday also (but exit early if RSI 2-day hits overbought at 50 or price falls below MA5.) Date range 3/1/2000 forward. When I drag and drop "day of the week" Monday for the buy and sell criteria will it hold for 1 week only and sell 1 week later, every week? If not, how do I test a weekly trading strategy (when I will never be able to figure out coding).
Size:
Color:
Generally, to test purely Weekly Strategies you don't have to do anything differently except to choose the Weekly scale for the data. However, the indicators in your strategy sound like Daily, and since you want to exit mid-week for the RSI condition, you must test and trade using a Daily chart, not Weekly. (The price exit could actually be done with a Weekly chart too using a Stop order.)
QUOTE:
When I drag and drop "day of the week" Monday
If you want the trade to occur on Monday morning, then you need to select Friday, not Monday. That's because when you update the data on Friday, you're analyzing it to enter trades for Monday. Unfortunately, this particular rule won't work for short weeks, like for the Thanksgiving holidays, so you'll need to do a little mod by hand once you get the basic Strategy set up.
Anyway, see the User Guide for using the Strategy Builder. When you stack rules, they're "ANDed" together, which means they all have to be true to trigger the trade. For your RSI exit conditions, you'll need to drag the "OR Divider" to create "either/or" conditions.
QUOTE:
buy with price greater than 5,
Make sure that you using the "(backtest)" Price (or Volume) Action rules. The "backtest" price rules account for splits in order to use the actual price traded when future splits exist. If you didn't use this type of price rule, it would be peeking since the past data is adjusted for future splits.
Size:
Color:
I found the "or" and switched to Fridays.
But where is "(backtest) Price (or Volume) Action rules"?
Size:
Color:
Conditions tab, Price (or Volume) Action group -- look for the two entries contaning "(backtest)" in their titles.
Size:
Color:
Say I want to test results on a set of stocks (say IBM, MSFT, INTC) for a one week hold for one particular week, buy and sell at Monday open. I've set the conditions to day of the week and specified "Friday" per your suggestion. Do I use a date range of the Friday before the Monday purchase to the Friday after the Monday sale? What particular dates to I specify? Monday's day of the month to Monday day of the month? e.g. if I want to test Monday 12/29/08 to one week later, 1/5/09. I'm getting zero trades so I'm not specifying the right dates.
Size:
Color:
If you're using the "Date is after/before a Calendar Date" the Date is the date of the current bar, whereas the Calendar Date is the date you're comparing the current bar's to. If you take a look at the code, you can see these details if the tooltips aren't sufficiently enlightening.
Size:
Color:
My question is what to put in the "DATE RANGE" in the "Data Range" in the upper left box where it says "SCALE", "DATA RANGE", and "POSITION SIZE".. If I want to trade Monday 12/29/08 and again Monday 1/5/09, to I use those days in the "DATE RANGE", or the preceding Friday, or following Friday for the sale date, or what? I don't understand your reply. What precise dates should I type in the box. I'm not using or drafting code, just the drop and drag and the box in the upper left as given by the program. SInce it is already confusing to put "Friday" as the "day of the week" when I'm trying to trade on Monday (but I am happy to do it), I don't know if the dates in the date box should also be a preceding Friday for the buy and the sell or not.
Size:
Color:
Answer: Put anything you want for those controls that make sense for the parameters of your strategy.
Please see the User Guide > Reference section about these controls. I think we already established, though, that you'll need to use the Daily scale instead of Weekly due to the RSI indicator/condition you want to use.
QUOTE:
I don't understand your reply. What precise dates should I type in the box.
Then I didn't understand what you were saying either. I was talking about the drag and drop rules that are available. In your previous post, you were specifying specific dates, so I was referring to the drag an drop rules that you can use to do that.
Size:
Color:
This is what I'm trying to do:
I have a set of stocks that changes weekly. I want to test each group each week to see the performance of them as I further filter them (say IBD100 stocks, or Zacks #1 stocks, filtered for low RSI2 rank). I can use drag and drop for all the further sub-filtering.
The help I need is figuring out what dates to specify in the upper left of the program to make it test for trading one particular Monday to one particular Monday (then for the next week I will advance the dates one week, but be using a different dataset of stocks).
Since you have me stating "Friday" as day of the week when I really want to trade on Mondays for my drag and drop day of the week criteria, the issue is to I use the preceding Friday in the "Data Range"'s "Date Range" for the beginning of the date range? Or do I use Monday the day I really want to trade? And for the sale date, the end of the date range, do I use the Friday before the actual Monday I want to sell one week later, or the Friday before that Monday? Or some other date? It isn't obvious to me, and I am often getting 0 trades no matter how wide the sub-criteria I am dragging and dropping, so I realize I must not be including the correct dates in the date range of the Data Range to be getting a Monday to Monday actual trade, my goal.
Size:
Color:
First I'll say that it sounds like your doing something very manually that should be programmed much more efficiently, but if you're a Wizard-user, then you're not going to get "there".
If I've got this straight, although you're using a 200-day moving average, etc., you really just want to know the trading results for one particular week of trading with a specific set of symbols?
(Hint: if you need a 200-day moving average plus one week, you'll need to load at least 205 daily bars to generate a trade)
Size:
Color:
I'm not using a 200 day moving average. I'm using a two-day RSI. But:
Let's assume I'm not dragging and dropping ANY criteria other than "day of the week" for buy and sell, which I'm setting to Friday to get an actual Monday but and sell.
Let's assume I'm using a dataset of 100 specified stocks.
1.What dates do I put in the Data Range's "date range" if I want to see how those stocks did in one week?
2. If I have a constantly changing group of stocks, but I know what the group is each week, and want to test holding a subset of each new set each week, wht is the way to program such a test? Is there a place on here to get paid help? The liklihood of me making sense of the code is below zero.
Size:
Color:
QUOTE:
I'm not using a 200 day moving average.
You're not the guy in the original post who said,
"...buy with price greater than 5, volume greater than 100,000, price above MA200 and below MA5,..."?1. The Date Range depends on the criteria. If you use a 200-day average (I guess you're not now), then you'll need at least 200 bars just to get the seed data for the indicator to be valid. After that, you'll need more data for the test period. If you only load 5 more bars of data for the week, then you better make sure that the strategy generates a trade
precisely when you want it to.
2. You can create a topic asking for paid help, but when you go that route be prepared to create a specification that a programmer can follow. Programming is precise, and if you're not, then you won't get what you want.
Size:
Color:
I AM trying to generate a trade PRECISELY when I want to: that is the very problem I'm trying to get an answer to. I'm trying to be as clear as I can but I am not getting an answer. What day of the week do I put in the "Date Range" field if I want to test one 5 day test period and have no data beyond a 2-day RSI (or even no data beyond the stocks in my dataset and the total return I want to see that they achieve in that 5 day window): if I want to trade on Mondays do I use Friday or Monday or some other day for the Date Range? I ask because when I drag and drop "day of the week" you have asked me to specify "Friday" when in fact I want to trade on Mondays, but I have no idea if that also is necessary when I put dates in the "Date Range" or not. I am not a programmer, and do not think in programmer terms. If the Monday I really want to trade on was January 5, do I use January 5 in the "Date Range" or instead January 2 the Friday before, or some other date; and for the sale date in the test do I use January 12, the Monday I want to sell on, or the preceding Friday, or some other date?
Also, are you telling me that if I specify a period it won't using underlying price or other data for each stock that lead up to such date, so I can't test the return in a one week period if I am testing say "stocks that went up 20% in the last 2 weeks"?
I can't know "what a programmer can follow" given that I am not a programmer. I can only know what an English user can follow, and I can be precise using English. I think I'm being pretty precise with English. I have a problem and need a solution. I cannot specify the solution to the problem since I do not know that solution. I have a set of symbols (say IBD100, or Zacks ranked) over time, so that those symbols change each week; I would like to test what return I would get holding those symbols for 1 week each, Monday to Monday, and then changing to the new symbols on the list that next week, until I have a series of returns that creates an overall compound annual growth rate, and the other usual metrics for a backtest over time. I would like to test doing the same thing to a subset of such ever-changing lists, e.g. by only including low RSI 2-day rank, say below 30 or below 5. I have no idea if that is considered "specific" from a programmers point of view or not; it seems pretty specific from a real-world and English language point of view. Is it specific enough from a programmers point of view? Ideally I would like to do it so I could "plug in" various initial universes of stocks.
Size:
Color:
Some basics and an example.
1. The Data Loading control specifies the data that will be loaded into the chart.
2. You cannot create a trade for a bar that doesn't exist on the chart.
3. If you create a trade for a future bar (does not yet exist), that's called an Alert.
4. A script that uses indicators needs seed data for indicators to make them valid. A 20-day moving average needs 20 daily bars just to get started. A 2-day RSI probably needs 6 or 8 bars minimum to stabilize. See:
Stability of IndicatorsExample:
Today is Friday and the U.S. market just closed. You update your data to run your EOD Strategy. What will be the last bar in the chart that the script has access to? (Answer: Friday, 26 June, 2009) What day do you want to create a trade on based on the information that you have today? (Answer: Monday, or whatever the next market day is.)
Hopefully from this example and basics, it's clear that to have created a trade last Monday at the open (AtMarket) and exited that trade today (AtClose) and open a new one next Monday (Alert), you would have needed to load data starting from last Friday (to create a trade last Monday) through today, at a minimum. Add a 2-day RSI, then I'd tack on at least 8 bars, minimum, in front of that. Furthermore, the conditions in your strategy to have created the trade on Monday must have triggered last Friday, and those to exit the trade at MOC must have occurred today.
QUOTE:
only including low RSI 2-day rank, say below 30 or below 5
Not specific enough. What's a 2-day rank? "30 or below 5" - which one? Is that the RSI level or the number of symbols to enter trades on in the rank? What happens if the lowest rank is above those values? Do you want a Strategy parameter that you can vary? (rhetorical questions, I'm not going to do this.)
Size:
Color:
I don't want to peak at the future nor create a trade for a future period, nor exit trades today; I only want to look at an historical period, say from last January, 1 week in that month. I am not trying to create a trade, just run a backtest. No Alerts. In every other backtest program I have used you can specify an historical period and run a backtest for that period and the program will be using data that precedes that period. Is that possible with Wealthlab or not? Your answer to me confuses me even more than when I started.
Can I test to see what price change IBM had in one particular week or not? If I make IBM the dataset and specify the dates for the week to be tested, to I get that result or not? I am not using charts, nor future bars. Does the program automatically look at old data or not when you run a backtest? If the Date Range in the backtester does not mean the date of the backtest what does it mean? Doesn't every backtest run look at data from earlier periods than the backtest period?
Size:
Color:
Musselmant, I think you confused Cone with "weekly" references making him think in terms of weekly price bars, when in actuality you mean to use a daily analysis using daily price bars, buying on Mondays, and selling on Mondays or earlier. Cone is too used to working with more sophisticated issues, and correctly saw difficulties if you were to use Weekly scaling.
I assume you have already created and temporarily 'finished' your basic drag and drop strategy. I think your strategy is basically applying a daily bar analysis, Buy at market open, Mondays, plus conditions; Sell at market open, Mondays plus conditions; or Sell earlier at market open if conditions met.
In choosing Scale, choose "Daily." In choosing Data Range, just choose "1 Year" for convenience of reference, and general safety of coverage (it then picks up about 250 bars (days) of daily data) for your watchlist. The program's calculation will automatically use technical periods ending with Friday's data in applying your conditions. When you have more experience, you may have reason to consider other Data Ranges.
If you want to test for Buying "Monday" say first week of January 2000, and Selling Monday second week of January 2000, then you should pad the Data Range say 12 months to start maybe January 1, 1998 through Monday January 10, 2000. Of course first Monday January 3, 2000 is a trading holiday so the Buy will not execute unless you modify the logic.
You can easily create and add new watchlists of any size, at any time to have your strategy run over (perhaps subject to your PC's ram limitations). You can then run your strategy on each week's IBD 100 or whatever to date, and can then easily see differentials.
It is questionable you can have the program easily calculate and render an incremental comparison of each week's new IBD100 on top of prior IBD100's. You will probably have to save each week's new IBD100 performance output to a new file / print it out, and manually compare the data, or manually put it into an Excel worksheet and compare them.
Please note that this simplistic perspective would generate "Performance" from base line of 250 bars ago. So to get incremental last week's performance, you need to look in the Trades tab, scroll to bottom, and compare the last two trading dates.
Alternative is to create your strategy script using WL version 4.X which allows you to specify "Lead Bars" of say 250, and then you can directly fine tune your evaluative time frame "Date Range" to just 1 week any time history.
However, WL 5.X eliminated the "Lead Bar" input, because it confused users, and "Date Range" that is set must now be sufficient in span to feed required technical indicator periods; otherwise program will not work.
Very sophisticated users might be able to craft a multiple watchlist rotational strategy to bang out a comparative analysis, but I doubt it is worth the extra effort over just making incremental strategy runs.
Cheers.
Size:
Color:
This has nothing to do with peeking into the future. Whether you're aware of it or not, the way you trade (and backtest) is by analyzing the data that you have and creating trades on the next bar. Using AtClose signals is an exception, but you still have to analyze the bar's complete data and "act as if" you were able to exit the trade on precisely the closing value of the same bar that you just took time to analyze (bordering on peeking).
Sorry I can't help.
Size:
Color:
Thank you both. I hate to be obtuse!
So let's say I only care about a particular Monday to Monday trading period (hold for a week) on a specific group of stocks (that week's IBD100), and I drag and drop the criteria I want (day of the week stating "Friday" to get Monday trades), rsi2<30), and I specify a time period in the Data Range of 2 years (because if I don't include some long period Wealthlab doesn't automatically collect all the historical data backwards from each tested backtest date, and that historical datalength needed will vary depending on what criteria I have dragged and dropped into the criteria window). If I only care about the return on the trades that one week in that 2 year interval, is the best way to determine them to look at "Trades" for that one week?
And then do the same thing with a new dataset (IBD100 for the following week) and look at "Trades" for that following week?
And then put each week's return into Excel to determine a longer term result of say doing that 52 times to get a 1 year CAGR?
So specifying a small time period in the Data Range window does not work in Wealthlab since all prior data is not available to that backtest when you do that.
Am I there?
("Is there any "there", there?)
Size:
Color:
Musselmant,
You have over conceptualized your requirements a priori and will therefore be disappointed a priori. You want to be more relaxed, and put yourself in a more light hearted exploratory, surprise yourself mode. Because you will find that WL's power, ease of use (once you start running some patterns), and quickness will lead you to being very pleasantly surprised and open up other avenues of analytical development perspectives.
You will find that you can do plenty of adequate comparative analysis on IBD100 by using 1 year data , 1 year back tests, in running each IBD set as they are announced. Forget for the moment of trying to focus in on 1 week performance data.
So if you have been collecting IBD100 lists for say last 20 weeks, you can on same day, run 20 comparative performance evaluations for those IBD100 sets comparing their performance over the past year. Generally you will find that the earlier sets will taper off in performance strength as time goes along and the earlier data sets grow long in the tooth. Newer more recent IBD100 sets will have a coat tail penumbra affect that might continue to last several weeks. One might keep a rolling list of the last 4 weeks of IBD 100s to run trading strategies on, and this will provide some good performance. Been there, done that, moved on beyond that to the point that my favored strategy generally does better (or "appears to do better") in back tests without the IBD100.
Stop moaning and groaning. Just go ahead and do it; run your strategies for 1 year back tests against a number of watchlists, and evaluate what you have. Enjoy tweaking your strategies to improve their performance for a while, then step back and ask more questions.
Just jump into the water (you won't drown, it's not deep, you won't break your PC), experiment, and enjoy such process for a while.
Cheers, good luck, and stay relaxed.
Size:
Color:
Actually, musselmant is on to something. We can easily generate the strategy to buy on Monday if RSI(Close, 2) < 30 and sell the Position at the close on Friday. He can put all of the stocks that appear in any of his lists into a single DataSet and run a multi-symbol backtest (MSB) in Raw Profit mode so that all trades are executed. With those results he can do some Excel magic by grouping the results (perhaps using Pivot tables) of the IBD lists, for example.
Here's the Strategy (with the early exit if RSI > 50) to run the MSB in the Daily scale -
CODE:
Please log in to see this code.
Please see the User or Programming Guides about "How to Run Example Code" in the Introduction. In case there's any doubt, the code above is a "complete" script.
Size:
Color:
What does this error message mean and how do I avoid the error:
"Index was out of range. Must be non-negative and less than the size of the collection."
I used criteria p>5 and volume>100,000 using yahoo split-adjusted data and only 2 years of data on symbols like IWOV and TMTA that lead to that message.
Size:
Color:
What criteria is p>5? If you've changed the code, show us how you changed it, exactly.
Size:
Color:
I use drag and drop only to specify criteria.
I dragged and dropped:
"Day of the week" and specified Friday for entry and exit.
"RSI" and specified 2 day as the period and below 5 as the entry.
"Price is above a value (backtest)." Then i specify >5 for price specifying yahoo split data, and volume>100,000 specifying same.
I used a dataset composed of Zacks #1 and 2 stocks (combined).
Then I get the error message for ALDN,ESALY,GNLB,IWOV, and TMTA.
Size:
Color:
I'm also getting alot of frozen runs where the program stops running as it calculates at the end of the run, forcing me to terminate the program. I don't know if the software has a problem; I am not having problems with other programs. Should I re-download the whole program?
Size:
Color:
QUOTE:
Should I re-download the whole program?
Generally, never. Certainly not for this.
ALDN,ESALY,GNLB,IWOV, and TMTA are currently non-trading symbols, so you can't download data for them from Fidelity. Do you have data for some time in the past?
QUOTE:
stops running as it calculates at the end of the run
Disable on-demand data collection, File menu. It sounds to me like you're trying to update your data and it's not possible for many of your symbols. The app probably isn't hanging up, you probably just need to give it more time to do what you're asking (download data).
Size:
Color:
Sr. Cone-
There are also some parentheses missing I think in your code in this thread, and I can't figure out where they should go but am getting error messages suggesting as much if I read them correctly.
Size:
Color:
No, sorry, the code is complete and executes properly.
Edit - (accidentally posted in your post before)
When you paste the code into the Editor, it should look precisely as it does above, nothing more, nothing less.
Size:
Color:
Can dragged and dropped created backtests be optimized? I don't see a way to type into the optimization page.
If not is there some simple automatic translation to the form that can be?
Size:
Color:
QUOTE:
Can dragged and dropped created backtests be optimized?
Yes: see
Strategy Window > Optimization > Optimization Control > Optimizing Rule-based Strategies in the Wealth-Lab User Guide.
QUOTE:
I don't see a way to type into the optimization page.
Possible reasons are summed up below, one of them applies:
Can't optimize a Strategy. What am I missing?
Size:
Color: