StockFetcher Forums · General Discussion · Problem with Variable in Count Phrase<< >>Post Follow-up
sswan
2 posts
msg #85475
Ignore sswan
1/3/2010 8:27:56 PM

I setup watchlist(TEMP) containing only stock ticker LLY to test the problem.

Here's the code to count how man times the High gets over the NearHigh hurdle in a 30 day period. The correct answer is 3. StockFetcher returns 11.

set{RecentHigh, High 30 day high}

set{NearHigh, RecentHigh * 0.9934}

set{Counter, count(High >= NearHigh, 30)}

show stocks

and add column RecentHigh
and add column NearHigh
and add column Counter

and apply to watchlist(TEMP)


If I substitute 37.75 (which is the value for NearHigh I get the correct answer, 3.


set{RecentHigh, High 30 day high}

set{Counter, count(High >= 37.75, 30)}

show stocks

and add column RecentHigh
and add column Counter

and apply to watchlist(TEMP)



Sheldon Swan

chetron
2,817 posts
msg #85476
Ignore chetron
1/3/2010 8:42:05 PM

the reason is that 37.75 was not the nearhigh for the last 30 days, but only for the last 17ish. you are counting for the last 30 days and 30 days ago the nearhigh was as low as 35.82.


hth

sswan
2 posts
msg #85478
Ignore sswan
1/3/2010 9:18:18 PM

In the above example for Eli Lilly (LLY), the RecentHigh in the last 30 days is 38.00

Therefor the variable NearHigh gets set to 37.75 for this stock. This become a hurdle. High only gets over this hurdle 3 times in 30 days.

Stock Fetcher gets it right when the constant 37.75 is used, but when the variable of the same value gets substituted, it gets it wrong.

The variable NearHigh shouldn't change , as you are indicating.



traderseb
36 posts
msg #85554
Ignore traderseb
1/5/2010 8:04:20 AM

The variable RecentHigh covers a finite previous 30 day period. The count function uses that same variable for each 30 day period so at the beginning of the 30 day count period the previous 30 days are used to calculate the RecentHigh variable. Same thing occurs every day of the count function across the confines you imposed, ie. 30. Therefore NearHigh is not a static constant for the 30 days in the count function unless you define it as a constant. It can be confusing and seems counterintuitive but hope this helps.

StockFetcher Forums · General Discussion · Problem with Variable in Count Phrase<< >>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 2016 - 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