I’ve written this rule:
ShowVar(@Cnt,LoopSum(“Hi(CTR) >= HighVal(99, CTR, #High)”, 99))
…to count the number of new 99-day highs in the last 99 days of the stocks I’m screening.
I’d also like to know if SPY has hit any new 99-day highs within the past 99 days. It looks like I can convert the first reference to:
Hi(CTR, GetSeries(“SPY”))
…but I can’t figure out how to replace #High with the high values of SPY using GetSeries. Or do I need to use a different function?
Or do I need to use closing prices instead?
I’m lost.
Randy - first create a custom formula $SPY = GetSeries(“SPY”)
Then your rule is:
ShowVar(@Cnt,LoopSum(“Hi(CTR) >= HighVal(99, CTR, $SPY)”, 99))
I suggest changing your rule to:
ShowVar(@Cnt,LoopSum(“Hi(CTR) > HighVal(99, CTR+1, $SPY)”, 99))
Steve
Your formula still has the same problem I was trying to resolve – getting HighVal() to get the highest high price from the $SPY vectors. As you have it, it will get the highest closing price of $SPY.
Is there a way to get the series of high prices from $SPY?
P.S. In your formula, Hi(CTR) would need to be Hi(CTR, $SPY).
Randy - you are right on both counts. Here is something that MAY work but is extremely slow and P123 may not appreciate people doing this
Change the custom formula to: $SPY = LoopMax(“BenchHi(CTR+1)”,99)
Set the benchmark to SPDR S&P 500 ETF Trust
The rule is:
ShowVar(@Cnt,LoopSum(“BenchHi(CTR) > $SPY”, 99))
At least it doesn’t give an error. I suspect the loop inside the loop will be a problem with both using CTR as a variable.
Use of BenchHi may give you some ideas. Also I suggest that you raise a feature request to allow use of BenchHi / BenchLo in custom series. Right now, only BenchClose is supported. Either that or allow an ETF custom universe within a custom series. Use of a custom series should solve this problem.
Steve