StockFetcher Forums · Filter Exchange · ANY THOUGHTS ON WHY THIS IS NOT WORKING?<< >>Post Follow-up
Kevin_in_GA
4,548 posts
msg #102238
Ignore Kevin_in_GA
8/13/2011 1:24:40 PM

I'm trying to write a simple rank function for 4 ETFs, as shown below. To do this I am using the "count" function for any time an ETF indicator is above the same indicator for each of the other stocks, as shown below;

Fetcher[

SET{RANK1A, COUNT(WEEKLY ROC(14,1) ABOVE IND(SPY, WEEKLY ROC(14,1)),1)}
SET{RANK1B, COUNT(WEEKLY ROC(14,1) ABOVE IND(IWM, WEEKLY ROC(14,1)),1)}
SET{RANK1C, COUNT(WEEKLY ROC(14,1) ABOVE IND(EFA, WEEKLY ROC(14,1)),1)}
SET{RANK1D, COUNT(WEEKLY ROC(14,1) ABOVE IND(BND, WEEKLY ROC(14,1)),1)}
SET{RANK2, RANK1A + RANK1B}
SET{RANK3, RANK2 + RANK1C}
SET{RANK4, RANK3 + RANK1D}
SET{RANK, 4 - RANK4}
ADD COLUMN RANK1A {ABOVE SPY}
ADD COLUMN RANK1B {ABOVE IWM}
ADD COLUMN RANK1C {ABOVE EFA}
ADD COLUMN RANK1D {ABOVE BND}
ADD COLUMN RANK

SYMLIST(IWM,EFA,SPY,BND)
ADD COLUMN SEPARATOR
ADD COLUMN WEEKLY ROC(14,1) {14 week performance}
SORT ON COLUMN 11 DESCENDING
chart-display is weekly
CHART-TIME IS 26 WEEKS

]



What should happen is that for this week BND should be given a rank of 1, SPY a rank of 2, EFA a rank of 3, and IWM a rank of 4. Clearly this is not the case, but for the life of me I can't explain why (nor can I explain why BND is not properly compared to itself, where it should get a 0 as the result).

Any thoughts on this from either the SF team or the forum members would be greatly appreciated.

Kevin

wantonellis
102 posts
msg #102239
Ignore wantonellis
modified
8/13/2011 2:22:11 PM



mahkoh
892 posts
msg #102240
Ignore mahkoh
modified
8/13/2011 2:48:53 PM

I've had troubles with weekly syntax when coding weekly pivot points. It turned out that I had to use not weekly high, low and close but weekly high one week ago etc to get the correct numbers.
I tried this on your filter and I think this makes it accurate.

Fetcher[


SET{RANK1A, COUNT(WEEKLY ROC 1 week ago(14,1) ABOVE IND(SPY, WEEKLY ROC 1 week ago(14,1)),1)}
SET{RANK1B, COUNT(WEEKLY ROC 1 week ago(14,1) ABOVE IND(IWM, WEEKLY ROC 1 week ago(14,1)),1)}
SET{RANK1C, COUNT(WEEKLY ROC 1 week ago(14,1) ABOVE IND(EFA, WEEKLY ROC 1 week ago(14,1)),1)}
SET{RANK1D, COUNT(WEEKLY ROC 1 week ago(14,1) ABOVE IND(BND, WEEKLY ROC 1 week ago(14,1)),1)}
SET{RANK2, RANK1A + RANK1B}
SET{RANK3, RANK2 + RANK1C}
SET{RANK4, RANK3 + RANK1D}
SET{RANK, 4 - RANK4}
ADD COLUMN RANK1A {ABOVE SPY}
ADD COLUMN RANK1B {ABOVE IWM}
ADD COLUMN RANK1C {ABOVE EFA}
ADD COLUMN RANK1D {ABOVE BND}
ADD COLUMN RANK

SYMLIST(IWM,EFA,SPY,BND)
ADD COLUMN SEPARATOR
ADD COLUMN WEEKLY ROC(14,1) {14 week performance}
SORT ON COLUMN 11 DESCENDING
chart-display is weekly
CHART-TIME IS 26 WEEKS
]



Kevin_in_GA
4,548 posts
msg #102295
Ignore Kevin_in_GA
8/16/2011 1:10:41 PM

This seems to work, although it requires more thought and coding to recreate the ROC function on a weekly basis. Not sure why the addition of "weekly" to this function is causing problems, but since no one from SF has bothered to respond I guess we'll never know.

Fetcher[
set{spyROC1, IND(SPY, weekly close) - IND(SPY, weekly close 14 weeks ago)}
set{iwmROC1, IND(iwm, weekly close) - IND(iwm, weekly close 14 weeks ago)}
set{efaROC1, IND(efa, weekly close) - IND(efa, weekly close 14 weeks ago)}
set{bndROC1, IND(bnd, weekly close) - IND(bnd, weekly close 14 weeks ago)}

set{spyROC, SPYROC1 / IND(SPY, weekly close 14 weeks ago)}
set{iwmROC, iwmROC1 / IND(iwm, weekly close 14 weeks ago)}
set{efaROC, efaROC1 / IND(efa, weekly close 14 weeks ago)}
set{bndROC, bndROC1 / IND(bnd, weekly close 14 weeks ago)}

SET{ETFROC1, weekly close - weekly close 14 weeks ago}
SET{ETFROC, ETFROC1 / weekly close 14 weeks ago}
SET{ETFROC2, ETFROC * 100}


SET{RANK1A, COUNT(ETFROC ABOVE SPYROC, 1)}
SET{RANK1B, COUNT(ETFROC ABOVE IWMROC, 1)}
SET{RANK1C, COUNT(ETFROC ABOVE EFAROC, 1)}
SET{RANK1D, COUNT(ETFROC ABOVE BNDROC, 1)}
SET{RANK2, RANK1A + RANK1B}
SET{RANK3, RANK2 + RANK1C}
SET{RANK4, RANK3 + RANK1D}
SET{RANK, 4 - RANK4}
ADD COLUMN RANK1A {ABOVE SPY}
ADD COLUMN RANK1B {ABOVE IWM}
ADD COLUMN RANK1C {ABOVE EFA}
ADD COLUMN RANK1D {ABOVE BND}
ADD COLUMN RANK

SYMLIST(IWM,EFA,SPY,BND)
ADD COLUMN SEPARATOR
ADD COLUMN ETFROC2 {14 week performance}
SORT ON COLUMN 11 DESCENDING
CHART-TIME IS 26 WEEKS
]



heypa
283 posts
msg #102296
Ignore heypa
8/16/2011 1:24:54 PM

Perhaps it is because the weekly scan is correct on only one day a week,namely Monday.

mahkoh
892 posts
msg #102298
Ignore mahkoh
8/16/2011 1:49:41 PM

No need to use "weekly close", for the current week this is the same as "close"

Fetcher[
symlist(spy)
add column weekly close
add column close
]



I was wondering,do you think this has implications for your 401K filter?

stockfetcher
963 posts
msg #102299
8/16/2011 3:06:37 PM

Hi -

The issue is related to how custom variables and counts handle weekly data. Once you create a custom variable, the variable is established as a "daily" variable.

While not an ideal solution, the example below may do what you are looking for.

Fetcher[
set{var1,WEEKLY ROC(14,1)}
set{var1a, IND(SPY, var1)}
set{var1b, IND(IWM, var1)}
set{var1c, IND(EFA, var1)}
set{var1d, IND(BND, var1)}

SET{RANK1A, COUNT(var1 is above var1a,1)}
SET{RANK1B, COUNT(var1 is above var1b,1)}
SET{RANK1C, COUNT(var1 is above var1c,1)}
SET{RANK1D, COUNT(var1 is above var1d,1)}
SET{RANK2, RANK1A + RANK1B}
SET{RANK3, RANK2 + RANK1C}
SET{RANK4, RANK3 + RANK1D}
SET{RANK, 4 - RANK4}
ADD COLUMN RANK1A {ABOVE SPY}
ADD COLUMN RANK1B {ABOVE IWM}
ADD COLUMN RANK1C {ABOVE EFA}
ADD COLUMN RANK1D {ABOVE BND}
ADD COLUMN RANK

SYMLIST(IWM,EFA,SPY,BND)
ADD COLUMN SEPARATOR
ADD COLUMN WEEKLY ROC(14,1) {14 week performance}
SORT ON COLUMN 11 DESCENDING
chart-display is weekly
CHART-TIME IS 26 WEEKS
]



Kevin_in_GA
4,548 posts
msg #102307
Ignore Kevin_in_GA
8/16/2011 5:18:33 PM

I actually like this approach. It allows you to modify var1 only once versus in every line of code that refers to it.

StockFetcher Forums · Filter Exchange · ANY THOUGHTS ON WHY THIS IS NOT WORKING?<< >>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 2016 - 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