StockFetcher Forums · Filter Exchange · Statistical Report / Filter Help<< >>Post Follow-up
djones000buck
206 posts
msg #96785
Ignore djones000buck
10/6/2010 5:59:02 PM

Working on my SF coding skills a bit lately and am having trouble with the following filter. Pieced together and built with some references/terminology from other filters (thanks to you if any of it seems familiar).

What I was attempting to do was build a filter that would report statistics on the occurrence of a trigger from the close of stocks price high 1, 2, and 3 days after the occurrence of the trigger. The version i show below looks at rsi(2) and defines a trigger as an increase of rsi(2) greater than 35. Then reports back the number of times the stocks high the following 3 days gained 1,2,and 3 percent from the trigger day's close.

Then by changing the top two sections of the code for the triggers, you could apply the statistics to any trigger you wanted to use (ie a moving average crossover)

So here is the filter:.

Fetcher[/* Pick a trigger, this case rsi(2) strength */
set{rz10, rsi(2) - rsi(2) one day ago}

/* Set your trigger in this case number of times that 1 day rsi(2) difference is greater than 35 */
set{trigger0, count(rz10 > 35,1)}
set{trigger00, count(rz10 > 35,100)}
set{trigger1, count(rz10 one day ago > 35,1)}
set{trigger2, count(rz10 two days ago > 35,1)}
set{trigger3, count(rz10 three days ago > 35,1)}

/*Define MA Indicator average - just a display I like*/
set{rb0, ma(21) - upper bollinger bands(10,.1)}
set{rb1, ma(21) one day ago - upper bollinger bands(10,.1) one day ago}
set{rb2, ma(21) two days ago - upper bollinger bands(10,.1) two days ago}
set{rb3, rb0 + rb1}
set{rb4, rb2 + rb3}
set{rba, rb4 / 3}

/*Define BB Indicator average - just a display I like*/
set{hb0, high - upper bollinger bands(10,.1)}
set{hb1, high one day ago - upper bollinger bands(10,.1) one day ago}
set{hb2, high two days ago - upper bollinger bands(10,.1) two days ago}
set{hb3, hb0 + hb1}
set{hb4, hb2 + hb3}
set{hba, hb4 / 3}
set{hbz, hb1 - hb0}

/*Define averages of the BB indicator above*/
set{Maxhba , hba 100 day high }
set{Amaxhba, maxhba * .75}
set{bmaxhba, maxhba * .65}
set{Minhba , hba 100 day low }
set{Avghba , CMA( hba , 100 )}
set{Aminhba, minhba * .75}
set{bminhba, minhba * .85}

/* Close Statements */
set{1pc1d, close 1 day ago * 1.01}
set{1pc2d, close 2 days ago * 1.01}
set{1pc3d, close 3 days ago * 1.01}

set{2pc1d, close 1 day ago * 1.02}
set{2pc2d, close 2 days ago * 1.02}
set{2pc3d, close 3 days ago * 1.02}

set{3pc1d, close 1 day ago * 1.03}
set{3pc2d, close 2 days ago * 1.03}
set{3pc3d, close 3 days ago * 1.03}

/* High Statements */
set{1phiopc1, count( high > 1pc1d,1)}
set{1phiopc2, count( high > 1pc2d,1)}
set{1phiopc3, count( high > 1pc3d,1)}

set{2phiopc1, count( high > 2pc1d,1)}
set{2phiopc2, count( high > 2pc2d,1)}
set{2phiopc3, count( high > 2pc3d,1)}

set{3phiopc1, count( high > 3pc1d,1)}
set{3phiopc2, count( high > 3pc2d,1)}
set{3phiopc3, count( high > 3pc3d,1)}

/* 1 percent Trigger Statements */
set{1pt1, 1phiopc1 + trigger1}
set{1pt1a, count(1pt1 > 1.9,1)}
set{1pt1b, count(1pt1a > .9,100)}
set{1pday1, 1pt1b / trigger00}

set{1pt2, 1phiopc2 + trigger2}
set{1pt2a, count(1pt2 > 1.9,1)}
set{1pt2b, count(1pt2a > .9,100)}
set{1pday2, 1pt2b / trigger00}

set{1pt3, 1phiopc3 + trigger3}
set{1pt3a, count(1pt3 > 1.9,1)}
set{1pt3b, count(1pt3a > .9,100)}
set{1pday3, 1pt3b / trigger00}

/* 2 percent Trigger Statements */
set{2pt1, 2phiopc1 + trigger1}
set{2pt1a, count(2pt1 > 1.9,1)}
set{2pt1b, count(2pt1a > .9,100)}
set{2pday1, 2pt1b / trigger00}

set{2pt2, 2phiopc2 + trigger2}
set{2pt2a, count(2pt2 > 1.9,1)}
set{2pt2b, count(2pt2a > .9,100)}
set{2pday2, 2pt2b / trigger00}

set{2pt3, 2phiopc3 + trigger3}
set{2pt3a, count(2pt3 > 1.9,1)}
set{2pt3b, count(2pt3a > .9,100)}
set{2pday3, 2pt3b / trigger00}

/* 3 percent Trigger Statements */
set{3pt1, 3phiopc1 + trigger1}
set{3pt1a, count(3pt1 > 1.9,1)}
set{3pt1b, count(3pt1a > .9,100)}
set{3pday1, 3pt1b / trigger00}

set{3pt2, 3phiopc2 + trigger2}
set{3pt2a, count(3pt2 > 1.9,1)}
set{3pt2b, count(3pt2a > .9,100)}
set{3pday2, 3pt2b / trigger00}

set{3pt3, 3phiopc3 + trigger3}
set{3pt3a, count(3pt3 > 1.9,1)}
set{3pt3b, count(3pt3a > .9,100)}
set{3pday3, 3pt3b / trigger00}

/*sum up 1pct percentage triggers for one occurrence in 3days*/
set{1ptvar1, count(1pt2a one day ago > .9,1)}
set{1ptvar2, count(1pt1a two days ago > .9,1)}
set{1ptvar3, 1pt3a + 1ptvar1}
set{1ptvar4, 1ptvar3 + 1ptvar2}
/*set{1ptvar5, count(1ptvar4 > .9,1)} */
/*set{1ptvar6, count(1ptvar4 > .9,100)} */

/*sum up 2pct percentage triggers for one occurrence in 3days*/
set{2ptvar1, count(2pt2a one day ago > .9,1)}
set{2ptvar2, count(2pt1a two days ago > .9,1)}
set{2ptvar3, 2pt3a + 2ptvar1}
set{2ptvar4, 2ptvar3 + 2ptvar2}
/*set{2ptvar5, count(2ptvar4 > .9,1)} */
/*set{2ptvar6, count(2ptvar4 > .9,100)} */

/*sum up 3pct percentage triggers for one occurrence in 3days*/
set{3ptvar1, count(3pt2a one day ago > .9,1)}
set{3ptvar2, count(3pt1a two days ago > .9,1)}
set{3ptvar3, 3pt3a + 3ptvar1}
set{3ptvar4, 3ptvar3 + 3ptvar2}
/*set{3ptvar5, count(3ptvar4 > .9,1)} */
/*set{3ptvar5, count(3ptvar4 > .9,100)} */

/* Add statistical display information for sorting */
add column 1pday1
add column 1pday2
add column 1pday3
add column 2pday1
add column 2pday2
add column 2pday3
add column 3pday1
add column 3pday2
add column 3pday3

/* Add chart display information */
and draw hba
and draw rba on plot hba
and draw trigger0
and draw 1ptvar4
and draw 2ptvar4
and draw 3ptvar4
and draw wma(21)
and draw bollinger bands(10,.1)

/* add stock selection criteria */
trigger0 > 0
average volume(90) > 500000
1pday3 > .5
and do not draw 1pday3
price < 100
]



The problem I am having is in the 5th and 6th variables that I have for each percent (1,2, &3) right here:

/*sum up 1pct percentage triggers for one occurrence in 3days*/
set{1ptvar1, count(1pt2a one day ago > .9,1)}
set{1ptvar2, count(1pt1a two days ago > .9,1)}
set{1ptvar3, 1pt3a + 1ptvar1}
set{1ptvar4, 1ptvar3 + 1ptvar2}
/*set{1ptvar5, count(1ptvar4 > .9,1)} */
/*set{1ptvar6, count(1ptvar4 > .9,100)} */

As it is the filter reports the statistics on the stock making the percentages that are defined for each 1 2 and 3 days after the trigger... So if 1ptvar4 is 1 that means that one of the three days after the trigger occurred, the stocks high price reached 1% or greater than the trigger days close. If 1ptvar4 is 2, the stock made one percent 2 of the 3 days after the trigger, and if 1ptvar4 is 3, then the stock made one percent 3 of 3 days after the close.

So to complete the filter, what I am attempting to do is define statistically that if 1ptvar4 is greater than 1, then count it as one occurrence to apply towards the statistics..

Sorry if I reinvented the wheel, but I am stumped and can't figure out the error when I activate any of the 5th or 6th variables for each percentage...

If I left out any info please feel free to let me know... Thanks!

It might look a bit complicated and long, which wouldn't suprise me that there is an easier way to do this.... :-)




StockFetcher Forums · Filter Exchange · Statistical Report / Filter Help<< >>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