StockFetcher Forums · Filter Exchange · Average Open-to-High and Average Open-to-Low in percent -- not working<< >>Post Follow-up
fotchstecker
206 posts
msg #152953
Ignore fotchstecker
7/4/2020 11:48:37 PM

I'm trying to get:
-the average open-to-high of the last 100 days
-the average open-to-low of the last 100 days


My code below doesn't appear to be right. Anyone have any ideas?


/* avg open to high, 100 days, pct */
set{OpenHi, high - open}
set{GoHi, count(OpenHi > 0, 1)}
set{AvgOpenHi100,sum(GoHi,100) / 100}

/* avg open to low, 100 days, pct */
set{OpenLow, open - low}
set{GoLo, count(OpenLow > 0, 1)}
set{AvgOpenLow100,sum(GoLo,100) / 100}

add column AvgOpenHi100
add column AvgOpenLow100

wantonellis
107 posts
msg #152955
Ignore wantonellis
7/5/2020 8:53:13 AM

Fetcher[

market cap > 200

/* hmo=high minus low. avg open to high, 100 days, pct */
set{avg_hmo, sum(high minus open,100) / 100}
set{avg_hmo_open, sum(open,100) / 100}
set{avg_hmo_pct_value, avg_hmo / avg_hmo_open}
set{avg_hmo_pct, avg_hmo_pct_value * 100}
add column avg_hmo
add column avg_hmo_open
add column avg_hmo_pct_value
add column avg_hmo_pct


/* oml=open minus low. avg open to low, 100 days, pct */
set{avg_oml, sum(open minus low,100) / 100}
set{avg_oml_low, sum(low,100) / 100}
set{avg_oml_pct_value, avg_oml / avg_oml_low}
set{avg_oml_pct, avg_oml_pct_value * 100}
add column avg_oml
add column avg_oml_low
add column avg_oml_pct_value
add column avg_oml_pct
]



fotchstecker
206 posts
msg #152961
Ignore fotchstecker
7/5/2020 4:54:12 PM

Many thanks, Wantonellis.

JoeyVinyl
120 posts
msg #152981
Ignore JoeyVinyl
7/6/2020 11:38:51 AM

@fotchstecker

I think part of why you weren't getting what you wanted in your code there was that you were counting the number of days the high was above the open instead of finding the difference and averaging it, as wantonellis did nicely. It's not bad code because that info could be useful depending on what you're filtering for. It's just different than what you needed.

I'd also be careful about variable names. I wonder if using "open" as part of the variable name caused issues. I'm going to say it probably didn't since it wasn't by itself, but I don't know for sure. Personally I like to abbreviate words that might be problematic in variable names, like using "op" for open, "cl" for close - things like that.

fotchstecker
206 posts
msg #152998
Ignore fotchstecker
7/7/2020 10:34:28 AM

Good points, Joey. I think my approach was based on something I had worked out in the past but wasn't really going to work for this. Also, I'm not sure if "open" was causing issues but I should have probably not used it all, to your point.

StockFetcher Forums · Filter Exchange · Average Open-to-High and Average Open-to-Low in percent -- 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 2018 - 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.