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

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?
profile picture

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.
profile picture

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).

Thanks for your help!
profile picture

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:

- downloadable strategies inside the "Intermarket" folder. Make sure to have downloaded all publicly available strategies first by clicking "Download..." from Wealth-Lab's "Open Strategy" dialog. Here they are:
- Inverse ETF Switching system
- Pairs Trading
- 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.
profile picture

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?
profile picture

trader998

#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?
profile picture

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:
Please log in to see this code.
profile picture

trader998

#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?
profile picture

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:
Please log in to see this code.
profile picture

trader998

#10
Very nice improvement. A few more questions:

1. When indicator (e.g. Bollinger band) is added, one can't switch from daily to weekly chart - has to delete the indicator to get the price plot back.
2. Using OHLC bar, you can see that the high and low may have to be redefined, otherwise, the bars are broken.
3. Because the ratio values are small, O,H,L,C are often displayed as the same value, the right side price axle needs to be 1/1000th or 1/10000th.
profile picture

Eugene

#11
This is a workaround so no wonder it comes with tradeoffs. For the standard way see my post #7 above and apply indicators in code.
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).