Hi! I know this is an old conversation, but I keep bumping into these unique graphs now and again and I absolutely love them. If I've got the chops, I wouldn't mind spending some of my own time to get something working in QuantShare! One small snag: a group called RRG Research which appears to have trademarked the name. But that's not a patent, so there doesn't seem to be anything getting in the way of making a copy of it. Only giving it the official name.
Anyhow, let me puzzle out here real quick what it might take to implement these...
I don't think the calculations themselves are going to be a problem. They're based on a benchmark and one or more securities. For each security you're plotting its relative strength (x axis) and its relative momentum (y axis) as compared to the benchmark. There are a number of webpages which describe it (in various levels of detail):
...and I suspect there would be plenty of 3rd party scripts for one of the many other platforms that could be translated into QuantShare if it comes to that. With a formula in-hand, it's pretty easy to test it against a known reference to make sure it is giving good numbers. Here's one such online RRG Webtool...
https://stockcharts.com/freecharts/rrg/
The graph itself really isn't all that complex, is it? It is a standard X/Y plot with (0,0) in the middle (or 100%, 100% in the middle since we're comparing it to a benchmark at that position). This divides the graph into four named and color-coded quadrants which is very easy to handle. The only special added touch is the trail which is often applied to each of the securities that are plotted, but that isn't very challenging. The hard part though is trying to fit it into how QuantShare works. I'm hoping that Azouz might have some comments here.
Something like PlotFixed seems like an appropriate base to begin with because you don't want the plotted points shifting left/right as you scroll forward and backwards in time. (But you might want it to recalculate the graph each time you've moved to a new time period. That seems to make sense.) You'd need to color and to label the four quadrants, and that shouldn't be too tough either. I think the only hard part is actually doing the plotting itself? My experience with PlotFixed is that it wants to plot 'buckets' along the X axis and not so much as a linear number. So I'm not sure how to get smooth X,Y plots done (and then to label each of them).
*Azouz:*
How would you recommend going about creating a fixed plot (no horizontal scrolling) with (0,0) (or 100,100) in the center and the ability to plot (and hopefully label) any X,Y position on the graph? Being able to match something like this (perhaps adding in a "tail" of recent values) would be great:
It seems like it is going to take a bit more than the built-in QuantShare Script commands to pull this off. Are there some C# functions you'd recommend to someone who's interested in implementing this? (Is any existing downloadable going to make a good reference?) Or is it going to require some additions to QuantShare itself for these kind of graphs to happen?
PS: I noticed we've got the ZedGraph library which can be referenced when creating custom function. (Can a function with this reference be shared?) I've located a large cache of sample graphs, tutorials, and documentation for ZedGraph. This thing is more than capable for the job! If you could get me started with a blank FixedPlot kind of situation, I'm pretty confident that I'm going to be able to code a chart that Alexander, myself, and no doubt many others are interested in.
Let me know? This looks like fun!
Josh McCormick
DISCLAIMER (just to keep any lawyers happy):
Relative Rotation Graphs and RRG Charts are registered trademarks of RRG Research.
Unfortunately, this is not possible to achieve in QuantShare chart. You cannot also use any C# code to plot this on the QS chart.
You can create your own C# library using any chart library to draw these but in all cases, it will be displayed outside QuantShare chart.
But seriously, you were probably speaking specifically about the ZedGraph library. And I do have to ask you to forgive my ignorance here. I'm out of my depth. I've never programmed in a C# or in Windows environment before, so I appreciate your patience with my awkwardly probing questions!
Mind you, the code was set to add new elements to the chart at the same time I was scrolling. I had placed the box and the label a little out-of-bounds, but you get the idea. It is a complete part of the chart. It disappears very cleanly. You can scroll left-and-right on the timeline and it'll disappear and reappear like anything else.
As shown in the screenshot, with a custom script, I was able to draw a number of objects and attach them to the chart (scrolling off-screen and back on-screen as they should). I'm extremely confident that, from an appearance standpoint, I'm going to be able to create these relative rotation graphs. But... and you might have been referring to this as well...I wasn't able to tell QuantShare to draw these simple objects while I'm editing *a function*. Is this the limitation here?
If so, I'm thinking that retrieving the stock data and performing all the mathematical calculations could be done by a simple QS Formula or maybe a custom function. Once the results are processed, it could pass the ticker symbols and their relative X,Y positions to a QuantShare script (C#) which would have the ability to generate these stylized graphs (and have them fully integrated in the QuantShare interface just about the same as any other graph) . Such a script might always be running in the background, either waiting to detect the correct chart or function or waiting for data to be passed to it via some mechanism , and then it could plot one of these graphs, yes?
Other than that, I think I have just one follow-up question:
Does a custom function have the ability to launch or execute an existing script? Could I have a custom function do all of the analysis and then (with or without passing parameters to it) call a local script to actually do the rendering? I'm able to create the graphs just how I want them with everything that's built-in to QuantShare's user-created scripts. The problem just seems how the script is launched, and how the data is passed to it to get it to plot what we want. Thoughts?
UPDATE: It looks like I can create a custom function to do the calculation. To actually graph it, it looks like I'd call a local graphing script with a command like Global.ExecuteScript("RelativeRotation.azf") ... but that command doesn't pass any parameters to the script. So I figure that our data on what needs to be plotted could be communicated a number of different ways, but I'm thinking that they could be stored in global variables? I dunno. What do you think?
Within limitations, I appear to be able to add graphical elements to existing charts, but I've run into a few questions. I'll take them to email.
Regarding an RRG indicator, my preliminary research says that part of the calculation involves a proprietary ranking of securities (which seems like an unnecessary choice from a technical perspective) making it difficult to reproduce precisely. BUT... if one really likes the concept of a rotational display (four quadrants created by a benchmark security in the middle, X axis with relative strength, y axis with relative momentum) then there's little preventing something different but equivalent from being produced. I suspect that most people like the concept and the layout more than the exact implementation. I'm still looking into it.
Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.