Plotting ROC of multiple symbols on same chart
Author: bobydesi123
Creation Date: 2/13/2010 9:27 AM
profile picture

bobydesi123

#1
Hi,
I would like to plot ROC(or any other indicator) in ONE SINGLE pane of all the symbols from a dataset. e.g. suppose I have IBM,AAPL,INTC in a dataset and i would like to plot ROC for each one of them on top of each other. I tried searching for it in forum but did not see it, if this had been discussed before, please point me to the aapropriate topic. Thank you.
profile picture

Eugene

#2
Hi,

Here you go:
CODE:
Please log in to see this code.

See the WealthScript Programming Guide > Indicators > Indicators of Secondary Symbols and look up DataSetSymbols the QuickRef.
profile picture

bobydesi123

#3
Thank Eugene,
As usual ur extremly helpful & ........................................etc. ;:)
profile picture

Bionian

#4
Would this provide the same results as "performance charts," where one can compare the relative performance of various symbols over time, using the same price/time axes and the same beginning x/y coordinates? I have been wondering how to do this. I currently obtain that information by an online vendor, but I am limited to daily data. I would like to be able to do this for hourly data.

Thanks-
Rick
profile picture

Eugene

#5
Rick,

The code plots ROC of multiple symbols. For performance charts, you need to slightly modify the formula. See how it's done in WL4: ChartScript - Relative Performance Charting.
profile picture

Eugene

#6
Here's Relative Performance Charting of all symbols from a DataSet:
CODE:
Please log in to see this code.
profile picture

Bionian

#7
Sorry for the stupid question, but I tried to copy and paste this code into the editor, but it all appeared on one line. What do I need to do to keep the formating as it appears in the post?

Thanks-
Rick
profile picture

Bionian

#8
Also, when I ran the ROC comparison it worked, but when I ran the above code for the Relative Performance Charts on the same data set, I got the following messages:

Error processing symbol UWM DataSeries do not have equal number of values for mathematical operation
Error processing symbol UXI DataSeries do not have equal number of values for mathematical operation
Error processing symbol UYM DataSeries do not have equal number of values for mathematical operation
Error processing symbol VAW DataSeries do not have equal number of values for mathematical operation
Error processing symbol VUG DataSeries do not have equal number of values for mathematical operation
Error processing symbol WOOD DataSeries do not have equal number of values for mathematical operation

Thanks for your help.
-Rick
profile picture

Eugene

#9
Re: "code on one line"

Sorry, that's a known bug with IE7/IE8 and this forum. Either copy and then paste to Wordpad, copy from there, paste in WL5, or simply use Firefox.

Re: error messages

See what the Wealth-Lab 5 Wiki says on DataSeries do not have equal number of values for mathematical operation
profile picture

Bionian

#10
Thanks, Eugene for the link. In order to compare the performance the symbols in a data set over a specific timeframe, is it possible to modify the code so that all the symbols begin at the same x-axis coordinate- e.g., at the median value of the x-axis range, with the x-axis values being percentages, and the values ranging from the highest percentage gain (or loss) in the data set on top to the lowest percentage gain (loss)?

-Rick
profile picture

Eugene

#11
In code #2, all the symbols already start from the same coordinate (i.e. 0), the x-axis will always be "time", and the "y" axis is always a percentage. Seems like I don't understand what is the point of assigning percentages to the x-axis, what will be the y-axis then, and consequently, what you're after.
profile picture

Bionian

#12
Eugene-

Sorry- I meant for them to start at the same point on the "y" axis, or at % = 0. This more easily allows direct comparisons of the various symbols in the data set over time, because they are all beginning at the same point- 0%. Can this be accomplished?
profile picture

Eugene

#13
But they do start at the very same point = 0% - speaking about code #2. On which DataSet do you run it, what are your bar scale and data loading settings?
profile picture

Bionian

#14
Based on you last comments, I compressed the bars to get all the chart's data on one screen.

One issue I have discovered is that if I try to run some data sets in too short a time frame, such as 20 days of data with 30-minute bars, I get the error message, "Runtime error: DataSeries do not have equal number of values for mathematical operation
at WealthLab.Strategies.MyStrategy.Execute()
at WealthLab.DataSeries.op_RightShift(DataSeries ds1.Int32value)

even though all data in the set is supposed to be 15-minute data. If I increase the time period, say to 30 days, I can get the chart, but since I am interested in shorter time scales, such as the last 10 days, how can I avoid having too long a time scale on the chart without getting the error message? My data should be current, since I updated all my data this evening.

Also, is there a way that I can provice a screenshot to show you what I am getting? Some of the results are hart to describe.
profile picture

Eugene

#15
QUOTE:
at WealthLab.DataSeries.op_RightShift(DataSeries ds1.Int32value)

If you rewrite this snippet:
CODE:
Please log in to see this code.

This way:
CODE:
Please log in to see this code.

It will get slower, but does the error persist? I can't reproduce it either way on a DataSet where the symbols are up to date, start from the same date, on demand update turned off.

QUOTE:
Also, is there a way that I can provice a screenshot to show you what I am getting?

Any image hoster on the web + link for the uploaded image they provide = paste it between a pair of IMG tags (right next to CODE, QUOTE...)
profile picture

Bionian

#16
I couldn't get the IMG to work, so I'll try posting the links...

Two things-

When I run the new code the symbols on the chart do begin at y coordinate = 0, but at the first x coordinate they jump to other values and don't look as I expected them to;

http://www.flickr.com/photos/rick-patton/4463887860/sizes/l/in/set-72157623573128163/

The default time frame for this data set is 15-minutes.

Also, when change the time frame to 60-minutes, I get no plots:

http://www.flickr.com/photos/rick-patton/4463110049/sizes/l/in/set-72157623573128163/

Any thoughts?
profile picture

Eugene

#17
I could not get the pictures as it prompts me to log in. Let me kindly suggest you for the future, to use any free image hoster that doesn't require logging in and provides direct image links. The only step left then is to paste that link between a pair of IMG tags. To name a few: tinypic.com, imagebam.com, imageshack.us.
QUOTE:
the chart do begin at y coordinate = 0, but at the first x coordinate they jump to other values

Try changing the starting date. If they won't "jump", then there was probably a gap, or the data for symbols doesn't start at the same date (synchronization).
QUOTE:
Also, when change the time frame to 60-minutes, I get no plots:

Sorry, can't tell, haven't seen the picture and do not know there's enough data loaded for all the symbols.
profile picture

Bionian

#18
Ok- let's see if the images appear now...

Two things-

When I run the new code the symbols on the chart do begin at y coordinate = 0, but at the first x coordinate they jump to other values and don't look as I expected them to;

The default time frame for this data set is 15-minutes.

Also, when change the time frame to Daily bars, I get no plots:

Any thoughts?
profile picture

Eugene

#19
Thank you for posting these images. Please re-read my commentary above from 3/26/2010 8:25 AM. I can't add much to what's already said there.
QUOTE:
Also, when change the time frame to Daily bars, I get no plots:

Like already suggested above: not enough data. 12 months is just 252 trading days while the code requires at least 260 bars of data just to warm up. It is up to you to edit the code so it would reflect your trading horizon.
QUOTE:
but at the first x coordinate they jump to other values and don't look as I expected them to;

Try changing the starting date. If they won't "jump", then there was probably a gap, or the data for symbols doesn't start at the same date (synchronization).
profile picture

Bionian

#20
Thanks for all your help so far.

I'm still having some problems with the appearance of the comparison charts. Note the chart below:


The flat-line lead is present in all timeframes, and it is always the first symbol ine the data set. If I change data sets, it is still there, and if I delete the first symbol in the data set, then the next first symbol is "flat lined."


I appreciate your continued help.
profile picture

Eugene

#21
QUOTE:
The flat-line lead is present in all timeframes, and it is always the first symbol ine the data set. If I change data sets, it is still there, and if I delete the first symbol in the data set, then the next first symbol is "flat lined."

The flat line is absolutely expected, it lasts for the first 260 bars of data (note: it's the Daily bar scale thing, probably related to approx. 250-260 trading sessions in a year. Does 260 have specific meaning for you on 15-minute charts? If so, that's fine by me.) These 260 bars - or whichever value the StartBar takes - are the seed data required to build the indicator series.
profile picture

Bionian

#22
Eugene-

There is no reason for the 260-bars of seed data. It remains from the first code you wrote for this strategy, which was based on daily bars.

What is the rule of thumb for the amount of seed data necessary for any given timeframe for this kind of chart? I use multiple time frames in analysis, so I am inclined to use data anywhere from 5-minute bars to daily bars. I understand data integrity requirements for moving averages, but what is the data integrity requirement for a performance comparison chart?

Thanks
profile picture

Eugene

#23
QUOTE:
What is the rule of thumb for the amount of seed data necessary for any given timeframe for this kind of chart? I

The amount of seed data entirely depends on the specified ROC period (e.g. 260 bars) which measures the security's performance over N bars.
profile picture

Bionian

#24
I am sorry for all the questions, but if you would indulge one more: Since I have inadvertently highjacked this thread into one about relative price performance rather than ROC, is any seed data even required for relative price performance, since no historical data is required to calculate price?
profile picture

Eugene

#25
Good point. No, if your formula calculates relative price performance starting from bar 0.
profile picture

Eugene

#26
From your question, I think you're probably looking for a different formula - other than the trailing relative performance (compared to shifted value of a series 260 bars ago):
CODE:
Please log in to see this code.

Try changing that line to this to compare relative performance to the very first bar:
CODE:
Please log in to see this code.

Or even substitute the "StartBar" here to a different starting bar number:
CODE:
Please log in to see this code.
profile picture

Bionian

#27
Voila'!!

The line, rocList.Add( ( extClose - (extClose[StartBar]) ) / (extClose[StartBar]) * 100.0 );
produced exactly what I wanted. I and my equity curve both thank you!

-Rick
profile picture

Eugene

#28
Rick,

That's good news to hear. :)
profile picture

Partha

#29
Hello Eugene

Can you please help me by modifying the code you provided by making the following changes

1) the default pricepane is hidden and all the curves are plotted on a single pane
2) plot the growth on a hypothetical $10,000 over a given period when start date is given as an input in the code

Thanks in advance
profile picture

Eugene

#30
QUOTE:
1) the default pricepane is hidden and all the curves are plotted on a single pane

Hiding the PricePane isn't allowed but there's a workaround. As usual, you can find them in our Knowledge Base (a.k.a. Wealth-Lab Wiki):

FAQ | Strategies and WealthScript > I want to chart an indicator, but without the stock price. Can I hide the PricePane?

Now to the 2nd part of your request, that makes it no longer align with topic's title i.e. "Plotting ROC of multiple symbols..."
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).