StockFetcher Forums · Filter Exchange · 2nd/3rd/4th/etc. lowest/highest close within the last X number days<< >>Post Follow-up
styliten
314 posts
msg #161758
Ignore styliten
modified
4/2/2025 3:13:12 PM

As shown in the heading, is there any easy way to show:

2nd/3rd/4th/etc. lowest/highest close/ema(10)/etc., etc. within the last X number days?

i.e.,

set{var101, sum of (5 highest closes in the last 10 days) minus sum of (5 lowest closes in the last 10 days)}



xarlor
596 posts
msg #161759
Ignore xarlor
4/3/2025 8:53:00 AM

We can do this when there are only three values. However, without arrays, I'm not sure this can be accomplished with SF's limited framework.

Fetcher[
symlist(spy,qqq,dia)

set{c0,close}
set{c1,close 1 day ago}
set{c2,close 2 days ago}

set{m1,max(c0,c1)}
set{1st,max(m1,c2)}

set{L1,min(c0,c1)}
set{3rd,min(L1,c2)}

set{MID1,c0 + c1}
set{MID2,MID1 + c2}
set{MID3,MID2 - 1st}
set{2nd,MID3 - 3rd}

add column separator
add column 1st
add column 2nd
add column 3rd
]



styliten
314 posts
msg #161775
Ignore styliten
4/10/2025 1:46:38 PM

@ xarlor

Didn't want to accept this verdict, but thanks for the confirmation nonetheless!

TheRumpledOne
6,525 posts
msg #161776
Ignore TheRumpledOne
modified
4/10/2025 6:17:20 PM

@styliten

What are you trying to accomplish? I am not asking about the math.

Fetcher[

add column close 2 day low
add column close 3 day low 1 day ago
add column close 4 day low 2 days ago
add column close 5 day low 3 days ago
add column close 6 day low 4 days ago
add column close 7 day low 5 days ago
add column close 8 day low 6 days ago
add column close 9 day low 7 days ago
add column close 10 day low 8 days ago


symlist(qqq,spy,dia)
]



TheRumpledOne
6,525 posts
msg #161777
Ignore TheRumpledOne
modified
4/10/2025 6:27:57 PM


A little closer.

Fetcher[
add column close 2 day low
add column close 2 day low 1 day ago
add column close 2 day low 2 days ago
add column close 2 day low 3 days ago
add column close 2 day low 4 days ago
add column close 2 day low 5 days ago
add column close 2 day low 6 days ago
add column close 2 day low 7 days ago
add column close 2 day low 8 days ago

symlist(qqq,spy,dia)
]




xarlor
596 posts
msg #161781
Ignore xarlor
4/14/2025 10:10:46 AM

@TRO, I believe what styliten is asking is take the last 10 values of a given indicator, e.g. close, and rank them from lowest to highest, or vice versa.

So say we have an array of the closing prices:

Today: 100
1 day ago: 98
2 days ago: 95
3 days ago: 105
4 days ago: 90
5 days ago: 94
6 days ago: 93
7 days ago: 101
8 days ago: 102
9 days ago: 99


He wants to know the highest, 2nd highest, 3rd highest, all the way to lowest. So he would like the order to be:

105, 102, 101, 100, 99, 98, 95, 94, 93, 90

and be able to call back any position in the array.

We can get highest and lowest with SF commands, but not anything in between without arrays.

TheRumpledOne
6,525 posts
msg #161782
Ignore TheRumpledOne
4/14/2025 11:55:17 AM

Understood.

But that's only a step or process to what they want.

I am asking, "What do they want?"





nibor100
1,081 posts
msg #161783
Ignore nibor100
4/14/2025 2:03:41 PM

I’m also curious about what Styliten wants to accomplish after subtracting the lowest 5 closes from the sum of the highest 5 closes?

105, 102, 101, 100, 99, 98, 95, 94, 93, 90 From Xarlor’s example, 507 minus 470 leaves him with 37, then what???

Ed S

nibor100
1,081 posts
msg #161797
Ignore nibor100
4/17/2025 3:24:26 PM

Expanding on Xarlor's approach I have come up with a way to get 4 in a row, which may be expandable to more in a row using some of the ideas in it.
Also at the end of my filter I added a section that shifts Xarlors 1st,2nd,3rd 3 days in the future to get a 2nd set of 3 in row, might be worth playing around with that approach.
Ed S.

Fetcher[
symlist(spy,qqq,dia,tqqq,amt,max)

set{c0,close}
set{c1,close 1 day ago}
set{c2,close 2 days ago}

set{m1,max(c0,c1)}
set{1st,max(m1,c2)}

set{L1,min(c0,c1)}
set{3rd,min(L1,c2)}

set{MID1,c0 + c1}
set{MID2,MID1 + c2}
set{MID3,MID2 - 1st}
set{2nd,MID3 - 3rd}

add column separator
add column 1st
add column 2nd
add column 3rd

set{c4,close 3 days ago}

set{4new1st, c4*count(c4 equals close 4 day high,1)} add column 4new1st

set{4th, c4*count(c4 equals close 4 day low,1)} add column 4th

set{mab2nd, count(c4 < 1st,1)*count(c4 > 2nd,1)} /*add column mab2nd*/
add column c4 multiplied by mab2nd{4new 2nd}

set{mab3rd, count(c4 < 2nd,1)*count(c4 > 3rd,1)} /*add column mab3rd*/
add column c4 multiplied by mab3rd{4new 3rd}

chart-time is 4 weeks

add column separator
add column 1st 3 days ago
add column 2nd 3 days ago
add column 3rd 3 days ago
]



StockFetcher Forums · Filter Exchange · 2nd/3rd/4th/etc. lowest/highest close within the last X number days<< >>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.