StockFetcher Forums · Filter Exchange · Combining the value of 2 stocks<< 1 2 >>Post Follow-up
glgene
616 posts
msg #102711
Ignore glgene
9/25/2011 10:48:46 PM

9/25/2011 10:44:03 PM

Is there a way of combining the pricing of, say, the value of 2 stock symbols? Such as VTI and JJC.

I tried this script, and it didn't work. Said I needed to debug it.


Fetcher[
symlist(vti,jjc)
set{a,vti}
set{b,jjc}
set{c,a+b}
add column c
]



If this doable, I would then add other info to the script. In essence, I would like to use the combined value in MA and other indicator calculations. But first...is it doable? If so, how would I rewrite the script above to get the combined value of VTI and JJC?

Many thanks in advance.

Gene

four
5,087 posts
msg #102714
Ignore four
9/26/2011 12:05:06 AM

Fetcher[
symlist(vti,jjc)
set{a, ind(vti,close)}
set{b, ind(jjc,close)}
set{c, a + b}
add column c
]



glgene
616 posts
msg #102717
Ignore glgene
9/26/2011 9:03:53 AM

four,

Yup, that does it. Thanks! But could you tell me the significance of IND in your script? I have looked it up in Help, and am not quite sure. Could you put it (IND) in a simple English statement, that even my mother would understand?

Gene

Kevin_in_GA
4,599 posts
msg #102718
Ignore Kevin_in_GA
9/26/2011 9:09:03 AM

IND = indicator

IND will return the value for a specific stock or index. The typical syntax looks like these examples:

IND(^spx,close) = returns the clsosing value for the S&P 500 index
IND(AAPL, rsi(2)) = returns the rsi(2) value for Apple

You can also create custom user variables, then have them referred to within IND:

set{ophi, open / high}
ind(APPL, ophi)

Useful bit of code - more people should be aware of it and how it can be used.

glgene
616 posts
msg #102719
Ignore glgene
9/26/2011 9:46:22 AM

Thanks, Kevin.

So....I added this line to four's script (above) and I don't think I got the right answer. Seems too low

set{d, ind(c,ema(20))}
add column d

What I am after is the EMA(20) of c (the combined value of VTI + JJC).

???

glgene
616 posts
msg #102727
Ignore glgene
9/26/2011 1:29:45 PM

Here is my attempted script (using four's original idea, and trying to add an EMA(20) to the mix. My addition can't be correct, based on the results.

Fetcher[
symlist(vti,jjc)
set{a, ind(vti,close)}
set{b, ind(jjc,close)}
set{c, a + b}
add column ema(20)
add column separator
add column c{VTI+JJC}
set{d, ind(c,ema(20))}
add column d{EMA(20), VTI+JJC}
draw c
draw d
]



This line must be wrong:
set{d, ind(c,ema(20))}

My objective is to print (and draw) the combined EMA(20) of VTI+JJC.

Any help here? The acid test is the result of the combined EMA(20) of VTI + JJC. My resulting number can't be correct (it is way too low), considering the EMA(20) of VTI and JJC (as shown in the column output).

???

Why am I attempting this? Because I have read that the action of copper (JJC as my proxy) is a precursor for the broad market. Rather than accepting that statement completely, I would like to merge JJC and VTI to get a combined result. Thus, I'm not relying soley on JJC or VTI, but combining the two and measuring that combined price against its combined EMA(20).

Any help on fixing my one line of script (as shown above) would be appreciated. Thanks.


Gene

four
5,087 posts
msg #102734
Ignore four
9/26/2011 9:19:06 PM

Fetcher[
symlist(vti,jjc)
set{a, ind(vti,close)}
set{b, ind(jjc,close)}
set{c, a + b}
add column ema(20)
add column separator
add column c{VTIJJC}
set{d, cema(c,20)}
add column d{EMA(20)VTIJJC}
draw c
draw d


]



glgene
616 posts
msg #102735
Ignore glgene
9/26/2011 9:45:27 PM

four,
Bingo! You corrected my mistake. Thank you.

Based on your suggested revised script, here are my most recent findings to test my "logic" of using JJC as part of the barometer of the overall market. That is, VTI+JJC. That combined field got you an EMA(20) crossover on 4/29/11 (sell). Since that date VTI is -16.03%. What a time to be in cash (or short).

Using strictly a VTI EMA(20) crossover, it would have generated a 'sell' on 5/5/11, after which there has been a 14.09% drop in VTI.

I realize that just one testing period does not constitute ample testing. But it's a start. I'll do more testing and post my results here.

By the way, after looking at your output, I think I should have averaged (instead of added) VTI and JJC values. The crossovers should be identical. An average value just looks more realistic. Do you agree or disagree?

Gene

glgene
616 posts
msg #102769
Ignore glgene
9/29/2011 2:24:30 PM

The link below was included in the 9-28-2011 WSJ online service, regarding Copper and its comparative chart with SP:

http://blogs.wsj.com/marketbeat/2011/09/28/dr-coppers-diagnosis-still-dire/?mod=google_news_blog

Using the SF script initially thought by me (but edited correctly by 'four'), one would use the combined price of VTI and JJC and compare that to the combined EMA(20) of those two symbols. If the combined price > combined EMA(20) that would signal a buy (for the broad mkt.). Less, a sell. Right now (1:10 pm, 9-29-11), that would not favor a long position (price is 93.4% of EMA).

Maybe, or maybe not, the EMA(20) is the best parameter. I haven't tried any other number.

FWIW,
Gene

glgene
616 posts
msg #102770
Ignore glgene
9/29/2011 6:42:25 PM

There are addt'l changes to my script for this message, basically to show the "bottom line" result of dividing the duo price of VTI + JJC by the duo EMA(20) of VTI + JJC. Shows it in % form.

For example, close of day, 9-29-2011shows a Duo price of $101.72 / Duo EMA(20) of $107.80, which = 93.71%. Anything less than 100% would indicate NOT to be long in VTI (or other broad-based, equity-type ETF if you used this Duo indicator as a barometer for an overall buy-sell signal.

I'm still not showing one thing, though, in the Chart view, that I would like to display: the Price/EMA crossover lines --- not only for the Duo result, but also the original VTI and JJC price/EMA crossovers. I must have faulty draw commands. ??

Any help would be appreciated. Thanks.

Gene

Fetcher[
symlist(vti,jjc)
set{a, ind(vti,close)}
set{b, ind(jjc,close)}
set{c, a + b}
add column ema(20)
set{a2,close}
set{a3,ema(20)}
set{a4,a2/a3}
set{a5,a4*100}
add column a5{Price / EMA %}
add column separator
add column c{VTI & JJC}
set{d, cema(c,20)}
add column d{EMA(20)VTI & JJC}
set{e,c/d}
set{f,e*100}
add column f{Duo.Price / Duo.EMA %}
add column separator
draw a
draw b
draw c
draw d
]



StockFetcher Forums · Filter Exchange · Combining the value of 2 stocks<< 1 2 >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.