StockFetcher Forums · Filter Exchange · Risk/Reward for 11 Sector ETFs<< >>Post Follow-up
glgene
625 posts
msg #162212
- Ignore glgene
11/15/2026 7:18:17 PM

I'm trying to develop a script to compute the "Risk/Reward" for the 11 Sector ETFs (from State Street).

I couldn't figure it out myself, so I did a Google Gemini search, which produced the following script ... but it doesn't work. It merely produces this message: "No Stocks Matched."

Fetcher[

/* 1. Restrict universe to the 11 State Street Select Sector SPDR ETFs */
symlist(XLB, XLC, XLE, XLF, XLI, XLK, XLP, XLRE, XLU, XLV, XLY)

/* 2. Calculate 3-Month (63-day) Percentage Return (Reward) */
set{Ret_63d, ((close / close 63 days ago) - 1) * 100}

/* 3. Calculate Normalized Volatility using 14-day ATR as a % of Price (Risk) */
set{ATR_Pct, (atr(14) / close) * 100}

/* 4. Calculate 63-day Price Standard Deviation as a % of Price (Alternative Risk) */
set{StdDev_Pct, (stddev(close, 63) / close) * 100}

/* 5. Calculate Risk/Reward Ratios (Higher = Better Reward per Unit of Risk) */
set{RR_ATR, Ret_63d / ATR_Pct}
set{RR_StdDev, Ret_63d / StdDev_Pct}

/* 6. Output results as custom table columns and sort by best Risk/Reward */

add column Ret_63d
add column ATR_Pct
add column StdDev_Pct
add column RR_ATR
add column RR_StdDev

sort column 9 descending
]



Does this script need a major overhaul ... or just a tune-up?

THANK YOU ... in advance ... if you can get my car running.
-- Gene in FL

xarlor
649 posts
msg #162213
- Ignore xarlor
11/16/2026 8:05:59 AM

Here is the prompt in Gemini to correct this:

This StockFetcher filter does not work because there is more than a single operation per line. Fix all the lines with more than one operation by providing multiple set statements per line:Pasted filter

And here is what it returned:

Fetcher[
/* 1. Restrict universe to the 11 State Street Select Sector SPDR ETFs */
symlist(XLB, XLC, XLE, XLF, XLI, XLK, XLP, XLRE, XLU, XLV, XLY)

/* 2. Calculate 3-Month (63-day) Percentage Return (Reward) */
set{Price_Ratio, close / close 63 days ago}
set{Ret_Dec, Price_Ratio - 1}
set{Ret_63d, Ret_Dec * 100}

/* 3. Calculate Normalized Volatility using 14-day ATR as a % of Price (Risk) */
set{ATR_Raw, atr(14)}
set{ATR_Dec, ATR_Raw / close}
set{ATR_Pct, ATR_Dec * 100}

/* 4. Calculate 63-day Price Standard Deviation as a % of Price (Alternative Risk) */
set{StdDev_Raw, stddev(close, 63)}
set{StdDev_Dec, StdDev_Raw / close}
set{StdDev_Pct, StdDev_Dec * 100}

/* 5. Calculate Risk/Reward Ratios (Higher = Better Reward per Unit of Risk) */
set{RR_ATR, Ret_63d / ATR_Pct}
set{RR_StdDev, Ret_63d / StdDev_Pct}

/* 6. Output results as custom table columns and sort by best Risk/Reward */
add column Ret_63d
add column ATR_Pct
add column StdDev_Pct
add column RR_ATR
add column RR_StdDev

sort column 9 descending
]



glgene
625 posts
msg #162214
- Ignore glgene
11/16/2026 10:29:21 AM

Thank you, Xalor ... Well done! Your 'fix' makes SENSE. The 11 Sectors = a Q4/2026 project of mine. I've been in XLP, XLV, and XLU the past several days ... while I somewhat 'reduced' my Tech stocks (in XLK and QQQ), accordingly. Diversification should help (singles/doubles ... instead of trying for triples/home runs). Babe Ruth was well known for his home runs, but he also struck out a lot.

Now that you repaired my Risk/Reward script, I can further my journey. My car has new spark plugs.

-- Gene in FL

StockFetcher Forums · Filter Exchange · Risk/Reward for 11 Sector ETFs<< >>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 2026 - 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.