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.
|
byebyemoney 31 posts msg #144351 - Ignore byebyemoney |
8/8/2018 4:37:31 PM
can you define a variable as constant?
|
graftonian 1,089 posts msg #144357 - Ignore graftonian |
8/9/2018 3:18:47 PM
|