Ratio of two indexes as indicator
Author: rcstonermdaf
Creation Date: 9/1/2015 8:06 AM

rcstonermdaf

#1
I want to trade a stock based on the ratio of two indexes (external), i.e. when it goes above sell, when it falls below buy. How do I do that?

Eugene

#2
There are numerous examples of ratio trading across published strategies, forum discussions etc. but I want to make sure we're talking about the right one. What does "external" mean? Please clarify your idea a bit to point you to a suitable example.

rcstonermdaf

#3
I'm completely new to this program, so of course I sound like a noob... I used the term external because 'external indicator' was the term I found in the program that got closest to what I want to do. So I could use the price of that one index to set buy and sell points. But I could not figure out how to set buy and sell points based on a calculated value (the ratio of two indexes).

Eugene

#4
As I said there's no shortage in examples. Here's something for "external symbol" and indicator based on it:

- External Symbol with Indicator
- Create strategy using one instrument's price action
- Need an Alert created when DJI SPX & IXIC have all moved up or down by 1% during the trading day

As it's still not exactly clear what you're after, here's for "pair/ratio trading" too:

- Inverse ETF Switching system
- ActiveTrader 2010-10 | Market-neutral VIX-based pair strategy

So if you could expand on your idea, I'd try to create a more precise strategy example for you.

KEVINP

#5
When you say indexes, do you mean tickers like DIA and SPY ? These 2 ETFs track the Dow Jones Industrials and S&P 500.

When you say ratio of the two, do you mean DIA divided by SPY? A ratio of these two DIA/SPY is called Price Relative. It is a form of Relative Performance or Relative Strength. It measures out-performance or under-performance of the numerator.

Plotting this ratio shows a line, if the line is moving higher, DIA is outperforming SPY. So, you would want to find an entry for DIA. For example, if the line is above an EMA of itself, then find an entry.

Is this what you are talking about?

#6
Hi,

Is there a way to plot the DIA/SPY Price Relative in Wealth-lab just like plotting DIA or SPY? An example of this is when you plot DIAS:SPY at stockcharts.com (link: http://stockcharts.com/h-sc/ui?s=dia%3Aspy). If yes, can you show me how? If not, can you make this plot available?

Eugene

#7
Hi Chunhua Qin,

Sure it's possible. Put DIA and SPY in a DataSet, click "Update DataSet", then execute this code via "Run the Strategy". Drag the slider on the bottomleft to change visibility:

CODE:

#8
Thanks for the quick response, Eugene.

The code worked, and generated what I asked for. But a few questions:
1. The symbols are hard coded, can you modify the code, so the symbol 1 is a symbol in the DataSet shown in the left panel (e.g. QQQ), and symbol 2 can be changed as needed (e.g. SPY or IWM or something else)?
2. The current plot is not in the main panel, and not compatible with adding indicators. Anyway to modify it?

Eugene

#9
QUOTE:
1. The symbols are hard coded, can you modify the code, so the symbol 1 is a symbol in the DataSet shown in the left panel (e.g. QQQ), and symbol 2 can be changed as needed (e.g. SPY or IWM or something else)?
2. The current plot is not in the main panel, and not compatible with adding indicators. Anyway to modify it?

Well, this trickery is possible via modifying the Bars object's DataSeries:

CODE: