After I back-test a strategy and produce a list of hypothetical transactions, is it possible to (a) add columns indicating what various technical indicators were at the time of the entry and exit, and (b) export this list into excel?
Size:
Color:
Without modification of the Trades tab, it may be possible to assign the indicator value at the time of entry/exit to the Position.EntrySignal/ExitSignal property. Then it will show up in the respective columns. Export is done via right click, Copy then paste elsewhere.
The key question here is why would you want to export the list to Excel? Can you name what kind of analysis do you think is not possible in WL?
Size:
Color:
Thanks Eugene, I am able to copy/paste the data into excel now.
Regarding the Position.EntrySignal/ExitSignal property: How do I get this column to appear?
The reason I want to export the trades to excel is to see if certain levels of given technical indicators produce better win/loss rates than other levels. The analysis I think is not possible in WL is a pivot table.
A pivot table will allow me to stratify a given technical indicator into groups (example: Group 1 is where entry ADX was 0 to 9, Group 2 is where entry ADX is 10 to 19, etc.). Then I can see the win/loss rate of each group. Furthermore, any of those groups could be further stratified into groups for a 2nd technical indicator like RSI.
Size:
Color:
QUOTE:
to see if certain levels of given technical indicators produce better win/loss rates than other levels.
So why not place the indicator of interest in a determining position of the entry or exit code, then let the optimizer tweak its parameters accordingly? And then you can rotate different indicators in its place as necessary with the optimizer tweaking each of them. And then use the
Performance tab--or other WL
Performance Visualizers--to compare their merits. That's what I do in the "final stages".
In my initial stages, I just drag-and-drop different indicators onto the Chart window to see how they perform at established trading points. I do that until I narrow my choices down to two or three indicators, then I apply the above paragraph to the winners.
---
Occasionally, I do produce histograms of WL program output on Excel. The method I use there is to append the individual, tab-delimited, newline-terminated, output strings to a StringBuilder type (a StreamWriter "string" type would be better for accumulated results over 20K bytes to avoid excessive garbage collection produced by StringBuilder), then I dump that concatenated result to the clipboard, which I paste to Excel. I use the
Copy to Clipboard WL component to perform the actual dump to the clipboard.
http://www2.wealth-lab.com/WL5Wiki/Clipboard.ashxIt's possible export directly to Excel, but that's more complicated. The StringBuilder and Copy-to-Clipboard approach I can do in a couple lines.
Size:
Color:
QUOTE:
The reason I want to export the trades to excel is to see if certain levels of given technical indicators produce better win/loss rates than other levels. The analysis I think is not possible in WL is a pivot table.
That's why I asked. You don't need Excel for this. Just as many
other visualizers available in WL as extensions, your pivot table reinvents the Analysis Series tab found in the
Extra Visualizers library. No more columns, no more copy/paste to Excel or other antique techniques. Check this out:
Testing Trading System Filters with Analysis Series ViewIf you like to start using it please
create a support ticket to verify your WLP entitlement by Fidelity. Once we're through with it you'd simply install the extension, restart WLP, check "Analysis Series" in Preferences > Visualizers, and open a Strategy window with indicators in its code.
Size:
Color:
Thank you both, I have completed a support ticket to request permission to download this visualizer.
Size:
Color:
You're welcome. You got the permission. Feel free to share your feedback re: this analysis type.
Size:
Color:
As a follow-up to the thread above: I have used the Analysis Series tab in Wealth Lab for a couple months now and, while I find it to be a helpful visual tool, I would still like to create a pivot table of my back-tested trades so that I can look at hard numbers rather than visual charts. Is there a way I can add columns to the Trades tab to include what certain technical indicators were at the time of entry?
Size:
Color:
There isn't a way to modify any 'canned' visualizer i.e. the one that came with WLP like Equity, Trades, By Symbol etc. Follow suggestion in my post #2 and look up those two properties in the QuickRef if unsure how to use them in Strategy code. Note that no column would appear - just the values in the Entry Name / Exit Name columns (if you coded it according to the QuickRef code examples).
Size:
Color:
I like the idea of getting the Entry Name column to populate with what an indicator was at the time of entry. I'm trying to follow the instructions but I'm stuck.
INSTRUCTIONS: In #2 above, you said "it may be possible to assign the indicator value at the time of entry/exit to the Position.EntrySignal/ExitSignal property." In #9 above, you said "look up those two properties in the QuickRef if unsure how to use them in Strategy code."
MY ATTEMPT TO FOLLOW: I opened the QuickRef guide and found "EntrySignal" under "Position Objects". It shows me an example string of code. I then went to my strategy rules and viewed the code in the Editor tab, and noted their similarities.
MY CONCLUSIONS: I concluded that (a) you must want me to modify the code in the Editor tab by adding something similar to the code found in the QuickRef guide, (b) If I do so correctly, then after I run the strategy, the Entry Name column of the Trades tab will populate with a given indicator at the time of entry, and (c) changing the code won't have changed the results of the strategy, just what I can see in the Entry Name column.
MY QUESTIONS:
1.) Are my conclusions above correct? If so, can you recommend anyone that might be willing to help me change the code? I have no programing experience.
2.) Would following the guidance above allow me to see what multiple indicators were at the time of entry? RSI, ADX, or OBV for instance?
3.) I wonder if there is an easier way to get the info I'm looking for. Specifically, in the Analysis Series tab, is there a way to export the underlying data that I'm viewing on the chart at a given time?
Size:
Color:
Your conclusions are correct yet I'm not convinced that exporting the indicator values is the correct objective.
The simplest way to see the underlying data that you're viewing on the chart at a given time is the Data window (Function toolbar). Highlight a trade entry/exit and the value of all plotted indicators will appear in the table. No programming required - and you can look at hard numbers and review whatever technical indicators were at the time of entry.
If this is still not what you're looking for, let's approach it from a different perspective. Let me focus on finding an optimal solution for you. Why would you want to export the indicator values? What kind of analysis are you after?
Size:
Color:
Thanks for your help Eugene. I tried hitting the Data Window button on the function toolbar but the window that pops up is blank (screenshot attached). I tried clicking on various tabs and charts before opening the window but it remains blank every time.
Regarding your question: "Why would you want to export the indicator values? What kind of analysis are you after?" In a nutshell, I want a single chart to show me the win/loss rate for each possible combination of multiple technical indicators at one time. Here's an example:
In excel, I manually tracked about 30 different paper trades using a strategy I'm working on. I then made a pivot table (screenshot attached) that examines many possible combinations of three different technical indicators at time of entry: RSI, ADX and Volume Oscillator. In a single chart, I can quickly see which combinations have the highest win rates. For example, where RSI ranges from 20 to 25, ADX ranges from 20 to 25 and Volume Oscillator ranges from 20 to 40, I see 2 wins and no losses. Of course the sample size isn't big enough to be conclusive, but imagine if there were thousands of transactions in the analysis.
Do you know of any add-ins that would create this chart without having to export to excel and make a pivot table? If not, I'm happy to do the analysis in excel, but the only thing stopping me is that I can't get the technical indicators at time of entry into my excel exports.
Size:
Color:
Jeff, the difference between the Analysis Series visualizer and your pivot table is that the latter lets you review the combination of multiple indicators at a glance.
It works for you if all the indicators oscillate within same boundaries i.e. 0 to 100. The Analysis Series is agnostic to this and can adapt to any indicator values but there's no way it can combine multiple indicators on a single graph plot. Such visualizer modification is not considered as that would take a rewrite.
Although you're using it incorrectly (look it up in the User Guide), the Data window is not going to help either. The idea is to mouse over a chart and point towards each trade entry/exit, then the plotted indicator values appear in the tool window. But after seeing your pivot chart I can say that no other extension would create this chart.
Your conclusions from post #10 are correct. You have to export the trade data to Excel. Here's sample code which illustrates how to modify your Strategy to show indicators at time of entry/exit in the Trades tab:
CODE:
Please log in to see this code.
Size:
Color:
If Profit $ on the trades tab has comma as 1,000 separator then when copying trades manually it is best to use the tab delimiter with no comma embedded in the entry and exit signals. In Excel, the tab delimiter should be active under the TextToColumn settings. The comma delimiter should not be active. Try:
CODE:
Please log in to see this code.
Size:
Color:
Good point. Code above edited.
Size:
Color:
@jholmberg083
I thought about developing a new performance visualizer to help you create those Pivot tables straight in WLP but cannot say that I'm convinced. With more than one substrata the output becomes confusing (hard to interpret). One way or another, the pivot table does not appear to me as illustrative as the Analysis Series. So in its present form, the approach doesn't look universal to justify the creation of the visualizer.
Size:
Color:
Eugene,
Thanks for the help, I will try playing with the code using the guidance you provided.
Above, you noted: “With more than one substrata the output becomes confusing”. Suppose I only had one substrata (for instance, ADX stratas within each RSI strata). Would you be more likely to develop a visualizer for that? I.e, would it help other people too?
Size:
Color:
I'm always open to ideas. Although the Pivot table may make sense to you it doesn't look very intuitive to me. Personally I'd prefer to see the whole picture with the visuals of Analysis Series rather than try to understand what those counts might mean and how they relate to each other (like "is 4 okay and 12 cool?" etc.) The idea has potential but requires some careful thought to become universal and catchy.
Size:
Color:
I tried playing with the code in my strategy to incorporate parts of your example code above, for instance, I copied and pasted this section under the "protected override void" section:
CODE:
Please log in to see this code.
But I get an error message: "error CS1002 @ (17,16) : ; expected"
I'm sure that the only problem here is that I have no experience with coding and am failing to follow a basic principle, like someone forgetting to add an equal sign to the beginning of a formula in excel. If you think there's an easy fix here, I'm happy to hear it, but I'm guessing that you teaching me the necessary coding skill is beyond the scope of your duties.
If that's the case, what do you suggest? Are there any members of the Wealth Lab community who edit code for hire? I've tried looking for students near me to help with this, there's potential but it's been slow moving.
Size:
Color:
You're right, the problem is that you have to understand C# syntax before trying to copy/paste code. Please refer to
How do I start with C# ? in the Wealth-Lab Wiki FAQ and learn C# 101.
Size:
Color:
QUOTE:
Although the Pivot table may make sense ..., it doesn't look very intuitive ... Personally, I'd prefer to see the whole picture with the visuals of Analysis Series
To visualized the pivot table, you need to render a 3D plot with
two (not three) indicators on the x- and y-axes, and then the outcome of the corresponding trade (i.e. its merit) on the z-axis.
I'm all for visualizers, but in order to populate the 3D plot with enough points to be revealing (And this would only be for just two, not three, indicators.), you would need over 100 trades. Otherwise, you just don't have enough points to render a "meaningful" 3D plot. (You could do this for three indicators [instead of two], but then you would be producing a 4D plot with 1000 trades.)
When I evaluate a
single stock against a strategy (for its inclusion into a specific DataSet), I'm lucky to get 10 trades out of that stock. There would be no way I could get enough trades from
one stock to populate a 3D plot for tuning indicator parameters. So any tuning of indicator parameters would have to be based on herd statistics (over many stocks).
---
Neural Networks (NN) is off topic here, but
if you know which three indicators are important (Do you?), you should be able to run their values (along with their outcomes) through an NN to compute a "composite score" you can use for trading. This would be easier than using pivot tables or 3D visualizers. Disclaimer: I have not used any of Wealth-Lab's NN features, and I can't say how well they work for synthesizing composite scores for trading in Wealth-Lab. But if this approach sounds interesting, start a new NN topic to discuss it.
Size:
Color:
Mark, NN sounds like a good idea.
@jholmberg083
Note that Neuro-Lab is an extension:
https://www.wealth-lab.com/Extensions/Details/20. After you install it and restart WLP, check out the Wealth-Lab User Guide for the simplest of all examples of feeding two indicators to a neural network: Neuro-Lab® chapter > Defining a Neural Network >
Input Script.
Size:
Color:
Thanks Mark and Eugene.
RE: PIVOT TABLES & VISUALIZERS: My intention was not to use the 3-indicator pivot table (screenshot in #12) to create visual charts like the scatter plots and bar graphs in the Analysis Series tab. Rather, the pivot table would help me identify which combinations of indicator ranges had the best win/loss rates. From there I could go back to Wealth Lab and see all the visuals I need after filtering my search to the indicator ranges I found in the pivot table. Also, I agree that this analysis is only meaningful when there are many transactions in the population. I've been doing searches with 100 stocks at a time generating thousands of results.
RE: NEURAL NETWORKS: I'm very interested in using these one day, but for now I'm going to crawl before I try to sprint.
RE: LEARNING C#: I want to learn this for myself eventually, especially if I transitioned to full-time day trading. But right now I think my best bet is to leverage the skills of others who already know C#. I work long hours and it's been a struggle to devote 30 minutes a day to the pursuit of trading. If I used those 30 minutes learn C# every day, I imagine that would consume at least a year or so before I was competent enough to readily make code changes like the ones you've shared throughout this thread. Does that seem like a fair assessment?
CODING FOR HIRE: I'd like to put up a post inviting other members of the Wealth-Lab community to write the code for me (for pay) so that I can copy/paste it into my screen. Is that permitted? Which topic do you think I should post it under?
Size:
Color:
QUOTE:
CODING FOR HIRE: I'd like to put up a post inviting other members of the Wealth-Lab community to write the code for me (for pay) so that I can copy/paste it into my screen. Is that permitted? Which topic do you think I should post it under?
We try to help with code on the forum when not busy with our tasks. You might want to give it a try first. How complex are your strategy's rules?
For custom development I'd like to recommend Yuri Zolotarev, check this out:
Custom Strategy/Extension Design and Tutoring
Size:
Color:
QUOTE:
If I used those 30 minutes learn C# every day, I imagine that would consume at least a year or so before I was competent enough to readily make code changes like the ones you've shared throughout this thread. Does that seem like a fair assessment?
A great deal of this depends on you and your previous experience. If you already know an object oriented language (e.g. C++, Java), then picking up C# is no big deal. If you're new to object oriented design, then it would be easier to take a class at a community college learning Java (or something) first. Once you learn one object oriented language, you kind of have the design pattern to pick up the others. Also, you don't have to be that great a programmer to use Wealth Lab if you're just writing and running strategy code.
EDITED by Eugene:Let's focus on solving topic starter's problem. Thanks in advance for avoiding lengthy offtopic content.
Size:
Color:
@ Superticker: Thanks for the feedback, it's my hope to add this to my skill set one day.
@ Eugene: The strategy isn't too complex I believe, the code for it is below. Is there an easy tweak that would allow it to populate the Entry Name column with the RSI, ADX and OBV indicators at time of entry? Thanks for sharing Yuri's info, I'll look into that.
CODE:
Please log in to see this code.
Size:
Color:
Here goes.
Note that since the ADX and RSI indicators are unstable I prefer to set the start bar 3-4 times greater than the biggest period (and not #21 as the Rule Wizard has done here automatically). See Indicators >
Stability of Indicators in the WealthScript Programming Guide (Help menu).
CODE:
Please log in to see this code.
Size:
Color:
Eugene: I copied your code over and was able to get the entry indicators to populate in the trades tab. Thank you so much for all of your help.
Size:
Color:
Glad to have helped.
Size:
Color:
Eugene: As an update to this issue, I used the code you provided in #27 above to produce thousands of search results on a large group of stocks, then made a pivot table to look for combinations of ADX/RSI with high win rates. I found some great combinations with >50% win rates and decided to build a drag/drop strategy with these parameters, hoping to achieve this same win/loss rate in a Wealth-Lab backtest. However, I got different results than expected.
The only difference I can think of is that the drag/drop strategy uses default settings to calculate RSI and ADX, whereas the code you provided has modified those calculations to stabilize them. I've concluded that I should do my search using your code rather than the drag/drop strategy builder, but that I need to modify the code to allow the 3 indicators (OBV, RSI and ADX) to be searched for as ranges. For example: I'd want to search for RSI between 10 and 25 rather than just have RSI be less than 25. Once the code is in place, I know how to change the numbers in these ranges if I want to play with the numbers.
Could I trouble you to post a copy of the code in #27 above, but allowing RSI and ADX to be searched for as ranges? Or is there a way to use the drag/drop strategy builder to calc RSI and ADX the way you did in #27? Thanks again for your help!
Size:
Color:
Jeff, there's a way to accomplish both tasks. Here's the code tweak as you request. The range boundaries and indicator periods are configurable:
CODE:
Please log in to see this code.
P.S.
As you know, the strategy code in post #27 and here start their calculations from bar 60 to stabilize the indicator values. Furthermore, here the starting bar can be dynamic as you drag the parameter sliders on the bottom left. Rule-based Strategies do not do this but you can adjust them by:
a) taking notice of the greatest period of an unstable indicator (say 14-period ADX) and
b) modifying the starting bar in code manually using "Open code in new Strategy window" to start at 3-4 times the greatest period (14*4).
A pretty mechanical task. For example:
CODE:
Please log in to see this code.
The code change cannot be "backported" to Rules, though.
Size:
Color: