punking315 4 posts msg #59458 - Ignore punking315 |
2/3/2008 8:31:47 PM
I am trying to start developing a filter(s) for finding flag patterns and in the process have hit a brick wall with the following:
/*--------develop the flagpole here, (currently this line is commented out)-----*/
/*find stock where 20 day slope of the close 4 days ago is above .2*/
/*---------now we try to develop some type of flag-----------*/
/* here we gather the highs of the past 5 days*/
Set{4H,high 4 days ago}
Set{3H,high 3 days ago}
Set{2H,high 2 days ago}
Set{1H,high 1 day ago}
Set{H,high}
/*here we sum them and get an average*/
set{sumH1, 4H + 3H}
set{sumH2, sumH1 + 2H}
set{sumH3, sumH2 + 1H}
set{sumH, sumH3 + H}
Set{avgH,sumH/5}
/* This increment number can be set to anything above zero. */
Set{Increment,.05}
/* this is where we create the distance above and below the average high */
Set{incAbove,1+Increment}
Set{incBelow,1-Increment}
/* here we determine the range of the high for each of the past days*/
Set{h4H,avgH*incAbove}
Set{l4H,avgH*incBelow}
And 4H is between h4H and l4H
Set{h3H,avgH*incAbove}
Set{l3H,avgH*incBelow}
And 3H is between h3H and l3H
Set{h2H,avgH*incAbove}
Set{l2H,avgH*incBelow}
And 2H is between h2H and l2H
Set{h1H,avgH*incAbove}
Set{l1H,avgH*incBelow}
And 1H is between h1H and l1H
Set{hH,avgH*incAbove}
Set{lH,avgH*incBelow}
And H is between hH and lH
somewhere I am missing the logic or syntax, any insight would be helpful
Thank You,
punking315
|
TheRumpledOne 6,411 posts msg #59459 - Ignore TheRumpledOne |
2/3/2008 11:10:38 PM
|
punking315 4 posts msg #59462 - Ignore punking315 |
2/4/2008 3:27:14 AM
TRO do you get an error when you run this too?
punking315
|
nikoschopen 2,824 posts msg #59469 - Ignore nikoschopen |
2/4/2008 4:00:33 PM
As far as I know, only numeric strings are accepted for the "between" modifier. Therefore, SF will recognize
4H is between 1 and 2
as valid statement but it prolly will not recognize
4H is between h4H and l4H
Another possible problem in ure filter is that while the 5-day average of the high (eg. avgH) remains constant, the daily highs (eg, 4H, 3H, 2H, 1H) used "to determine the range of the high for each of the past days" are not. I would have used a rolling period of daily averages to each daily high, namely, 5-day average for 5H, 4-day average for 4H, etc.
BTW, there's a simpler way to write the following lines.
/* here we gather the highs of the past 5 days*/
Set{4H,high 4 days ago}
Set{3H,high 3 days ago}
Set{2H,high 2 days ago}
Set{1H,high 1 day ago}
Set{H,high}
/*here we sum them and get an average*/
set{sumH1, 4H + 3H}
set{sumH2, sumH1 + 2H}
set{sumH3, sumH2 + 1H}
set{sumH, sumH3 + H}
Set{avgH,sumH/5}
This could be written simply as:
set{avgH, sum(high,5) / 5}
Hope that helps.
|
chetron 2,817 posts msg #59470 - Ignore chetron |
2/4/2008 4:07:45 PM
without errors....
|
punking315 4 posts msg #59476 - Ignore punking315 |
2/4/2008 8:33:34 PM
thank you all for the great suggestions and help.
Indeed there is a flaw in the logic, RE: rolling averages, I will be working on this as an ongoing project.
also, I greatly appreciate the working version posted, this helped me tremendously.
thanks all!
punking315
|