StockFetcher Forums · General Discussion · code not returning expected results<< >>Post Follow-up
push5280
201 posts
msg #156979
Ignore push5280
6/12/2021 11:55:44 PM

I have an indicator that I'm trying to create however my code is not delivering the expected result, any help would be appreciated. I'm trying to find stocks that are within 20% of the 3 month high of my liquidity calculation. That is defined as: set{liquidity_guage50, close * average volume(50)}.

If I add the 3 month high and 3 month low it plots correctly:
Fetcher[
set{liquidity_guage50, close * average volume(50)}
draw liquidity_guage50
draw liquidity_guage50 3 month low
draw liquidity_guage50 3 month high
]



Where the problem lies or where I get the unexpected result is when I try to find stocks that are within 20% of the liquidity_guage50 3 month high line. My code is returning 80% of the close. I don't know if it's my code or a Stockfetcher bug/feature.
Fetcher[
/* Liquidity Calculations*/
set{liquidity_guage50, close * average volume(50)}
set{lg50_range, liquidity_guage50 3 month high - liquidity_guage50 3 month low}
set{range_percent, lg50_range * .8}
set{80percent_line, range_percent + liquidity_guage50 3 month low}
/* Liquidity Plots*/
draw liquidity_guage50
draw liquidity_guage50 3 month low
draw liquidity_guage50 3 month high
draw 80percent_line on plot liquidity_guage50
]



xarlor
587 posts
msg #156980
Ignore xarlor
6/13/2021 8:51:49 AM

You had some math errors mostly. Don't need to subtract high from low, then multiply by .8. Just need to multiply .8 by the high.

Also, SF sometimes doesn't like using "x day high" within a set statement, so have to give it its own variable first, then call it in.

Lastly, this has no bearing on the filter itself, but I kept messing up the variables since I was spelling gauge and you misspelled it "guage" so I changed them all.

Fetcher[
/* Liquidity Calculations*/
set{liquidity_gauge50, close * average volume(50)}
set{lg3mh,liquidity_gauge50 3 month high}
set{range_percent, lg3mh * .8}

liquidity_gauge50 > range_percent

/* Liquidity Plots*/
draw liquidity_gauge50
draw liquidity_gauge50 3 month low
draw liquidity_gauge50 3 month high
draw range_percent on plot liquidity_gauge50
]



push5280
201 posts
msg #156983
Ignore push5280
6/13/2021 4:04:16 PM

Thank you Xarlor! Exactly what I was looking for!

StockFetcher Forums · General Discussion · code not returning expected results<< >>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.