StockFetcher Forums · Filter Exchange · Random Collection of Filters<< >>Post Follow-up
sandjco
648 posts
msg #140632
Ignore sandjco
modified
1/3/2018 6:43:21 PM

As I only have a limit of 100 filters and there doesn't seem to be any handy repository for filters; I thought I'd start one for filters that I was fortunate to come across as they were either interesting or provided a coding style for me to learn from.

My advanced apologies to the original authors as in my haste, I didn't bother to collect or label their names onto it and I MAY have done some alterations to the original.

Feel free to add yours. The only thing I ask for is for the thread not to be littered with comments. Than you.

Think of this as a "Library" of SF codes

sandjco
648 posts
msg #140633
Ignore sandjco
1/3/2018 6:44:30 PM

Using "X"
Fetcher[
low > 10
volume > 321321
draw low 10 week low
draw high 10 week high

set{xx, low 10 week low}
set{y, high 10 week high}
set{x, count(low equals xx,7)}
draw x > 6
add column x
]



sandjco
648 posts
msg #140634
Ignore sandjco
1/3/2018 6:47:44 PM

Pair trading

Fetcher[
/*FIRST DETERMINE HISTORICAL RATIO OF S&P STOCK TO THE SPY OVER THE LAST 16 DAYS*/
SET{PRICERATIO, CLOSE / IND(^SPX,CLOSE)}
SET{RATIOMA16, CMA(PRICERATIO,16)}
SET{RATIOSTD16, CSTDDEV(PRICERATIO,16)}
SET{DIFF16, PRICERATIO - RATIOMA16}
SET{ZSCORE16, DIFF16 / RATIOSTD16}
SET{THRESHOLD16, RATIOSTD16 * 2}

/*NEXT, SET CRITERIA NECESSARY TO TRIGGER A PAIR TRADE*/

SET{UPPERBAND16, RATIOMA16 + THRESHOLD16}
SET{LOWERBAND16, RATIOMA16 - THRESHOLD16}

ZSCORE16 BELOW -2
WILLIAMS %R(16) BELOW -94
CLOSE BELOW LOWER BOLLINGER BAND(16,2)
CLOSE ABOVE MA(200)

//DRAW LOWERBAND16 ON PLOT PRICERATIO//
//DRAW UPPERBAND16 ON PLOT PRICERATIO//
DRAW BOLLINGER BANDS(16,2)
ADD COLUMN ZSCORE16 {Z-score}
ADD COLUMN WILLIAMS %R(16)

DRAW ZSCORE16 LINE AT -1
DRAW ZSCORE16 LINE AT -2
DRAW ZSCORE16 LINE AT 0

SORT ON COLUMN 5 ASCENDING
CHART-TIME IS 6 MONTHS
]



sandjco
648 posts
msg #140635
Ignore sandjco
modified
1/3/2018 6:51:17 PM

Data Fetcher

Fetcher[
apply to watchlist
add column open
add column high
add column low
add column close
add column volume
add column open 1 day ago
add column high 1 day ago
add column low 1 day ago
add column close 1 day ago
add column volume 1 day ago
]



sandjco
648 posts
msg #140636
Ignore sandjco
1/3/2018 6:53:25 PM

CROCKPOT kind of...
Fetcher[

/* TRO STAT SCAN for SWING TRADERS - use only on Saturday and Sunday */
/*set up for 2.5% gain 9.5% loss*/
/*find weekly profit*/
set{whiop, weekly high - weekly open}
set{Long_Profit, whiop / weekly open }
set{wkProfitPct, 100 * Long_Profit }

/* find weekly losss */
set{wloop, weekly low - weekly open}
set{Long_Loss, wloop / weekly open }
set{wkLossPct, 100 * Long_Loss }

set{win, count(long_profit > 0.0249, 1)}
set{win_count, count(win > .9, 52)}

/*define the gray area*/
set{gray01, count(Long_Profit < .025, 1)}
set{gray02, count(Long_Loss > -0.095, 1)}
set{gray03, gray01 + gray02}
set{ties, gray03 - 1}
set{gray_count, count(gray03 > 1.9, 52)}

set{loss, count(Long_Loss < -0.095, 1)}
set{loss_count, count(loss > .9, 52)}

add column separator
add column win_count{wins}
add column gray_count{ties}
add column loss_count{losses}
draw rsi(2)

set{Win_loss_ratio, win_count / loss_count}
add column separator
add column win_loss_ratio
and win_loss_ratio > 3
sort on column 10 descending
do not draw win
do not draw loss
do not draw wkprofitpct
do not draw wkprofitpct line at 2.5
do not draw wklosspct on plot wkprofitpct
do not draw wklosspct line at -9.5
do not draw win_loss_ratio
do not draw win_loss_ratio line at 50

not OTCBB
Average Volume(30) > 123456
close > 5
chart-display is weekly
chart-time is 2 years
volume above 2000000
set{s_days, days(slow stochastic(5,1) fast %k below 30, 2)}
add column s_days
s_days equals 1
draw slow stochastic(5,1) fast %k
draw slow stochastic(5,1) fast %k line at 30

set{i_days, days(IFT(2,1) below 0, 2)}
add column i_days
i_days equals 1
do not draw IFT(2,1)
do not draw IFT(2,1) line at 0

do not draw s_days
do not draw i_days
Average Day Range(10) > 6

draw ema(3)
draw ema(4)
draw ema(5)
draw ema(6)
draw ema(7)
draw ema(8)
draw ema(9)
draw ema(10)
draw ema(11)
draw ema(12)
draw ema(13)
draw ema(14)
draw ema(15)
draw ema(30)
draw ema(35)
draw ema(40)
draw ema(45)
draw ema(50)
draw ema(60)
]



sandjco
648 posts
msg #140637
Ignore sandjco
1/3/2018 7:01:35 PM

CROCKPOT simplified

Fetcher[

/* TRO STAT SCAN for SWING TRADERS - use only on Saturday and Sunday */
/*set up for 4% gain 8% loss*/
/*find weekly profit*/
set{whiop, weekly high - weekly open}
set{Long_Profit, whiop / weekly open }
set{wkProfitPct, 100 * Long_Profit }
set{Avg13WkProfit, CEMA(wkprofitpct, 13)}
draw Avg13WkProfit
/* find weekly losss */
set{wloop, weekly low - weekly open}
set{Long_Loss, wloop / weekly open }
set{wkLossPct, 100 * Long_Loss }

set{win, count(long_profit > 0.04, 1)}/*set profit limit here*/
set{win_count, count(win > .9, 52)}

/*define the gray area*/
set{gray01, count(Long_Profit < .04, 1)}/*set profit limit here*/
set{gray02, count(Long_Loss > -0.08, 1)}/*set loss limit here*/
set{gray03, gray01 + gray02}
set{ties, gray03 - 1}
set{gray_count, count(gray03 > 1.9, 52)}
set{loss, count(Long_Loss < -0.08, 1)}/*set loss limit here*/
set{loss_count, count(loss > .9, 52)}
add column separator
add column win_count{wins}
add column gray_count{ties}
add column loss_count{losses}
add column separator
set{sort01, win_count - loss_count}
set{x, gray_count / 2}
set{sortnum, sort01 - x}
add column sortnum
sort on column 10 descending
add column wkprofitpct
add column Avg13WkProfit
draw win
draw loss
draw wkprofitpct
draw wkprofitpct line at 4/*set profit limit here*/
draw wklosspct on plot wkprofitpct
draw wklosspct line at -8/*set loss limit here*/
draw EMA(13)
/*set{HighHopes, weekly open * 1.04}
draw highhopes on plot price
plottype{highhopes, dot}
set{ohshit, weekly open * .92}
draw ohshit on plot price
plottype{ohshit, dot}*/
not OTCBB
Average Volume(30) > 123456
close > 1
chart-display is weekly
chart-time is 1 year
]



sandjco
648 posts
msg #140638
Ignore sandjco
1/3/2018 7:05:33 PM

Sell or Buy Pairs
Fetcher[
SYMLIST(xiv,vxx)

/*CALCULATE THE PAIR RATIO*/
SET{RATIO, IND(xiv,CLOSE) / IND(vxx,CLOSE)}

/*DETERMINE THE 14 DAY MOVING AVERAGE FOR THE RATIO*/
SET{RATIOMA14, CMA(RATIO,14)}

/*DETERMINE THE PERCENT ABOVE/BELOW THE MA(14) FOR THE RATIO*/
SET{RATIOPCT1, RATIO / RATIOMA14}
SET{RATIOPCT2, RATIOPCT1 - 1}
SET{RATIOPCT, RATIOPCT2 * 100}

/*DETERMINE THE 14 DAY ZSCORE FOR THE RATIO*/
SET{RATIOSTD14, CSTDDEV(RATIO,14)}
SET{RATIO2STD, 2 * RATIOSTD14}
SET{RATIOUPPERBB, RATIOMA14 + RATIO2STD}
SET{RATIOLOWERBB, RATIOMA14 - RATIO2STD}
SET{RATIODIFF14, RATIO - RATIOMA14}
SET{RATIOZSCORE, RATIODIFF14 / RATIOSTD14}

/*DETERMINE DIRECTION OF PAIR TRADE AND THE NUMBER OF SHARES TO BE BOUGHT OR SOLD*/
SET{BELOWLBB, COUNT(RATIOZSCORE BELOW -2,1)}
SET{ABOVEUBB, COUNT(RATIOZSCORE ABOVE 2,1)}

SET{xivSHARES1, 10000 / IND(xiv,CLOSE)}
SET{xivSHARES, ROUND(xivSHARES1, 0)}
SET{xivLONG, BELOWLBB * xivSHARES}
SET{xivSHORT, ABOVEUBB * xivSHARES}

SET{vxxSHARES1, 10000 / IND(vxx,CLOSE)}
SET{vxxSHARES, ROUND(vxxSHARES1, 0)}
SET{vxxLONG, ABOVEUBB * vxxSHARES}
SET{vxxSHORT, BELOWLBB * vxxSHARES}

/*FORMAT FILTER COLUMN OUTPUT*/
ADD COLUMN RATIO {RATIO}
ADD COLUMN RATIOMA14
ADD COLUMN RATIOZSCORE {RATIO Z-SCORE}
ADD COLUMN RATIOPCT {PERCENT AWAY FROM MEAN}
ADD COLUMN SEPARATOR
ADD COLUMN xivLONG {xiv - SHARES LONG}
ADD COLUMN vxxSHORT {vxx - SHARES SHORT}
ADD COLUMN SEPARATOR
ADD COLUMN xivSHORT {xiv - SHARES SHORT}
ADD COLUMN vxxLONG {vxx - SHARES LONG}

/*DRAW RATIO PLOT AND ZSCORE*/
DRAW RATIO ON PLOT RATIOMA14
DRAW RATIOUPPERBB ON PLOT RATIOMA14
DRAW RATIOLOWERBB ON PLOT RATIOMA14

PLOTTYPE{RATIOZSCORE, ZEROBAR}
DRAW RATIOZSCORE LINE AT 2
DRAW RATIOZSCORE LINE AT -2
DRAW RATIOZSCORE LINE AT 0

CHART-TIME IS 6 MONTHS
]



sandjco
648 posts
msg #140639
Ignore sandjco
1/3/2018 7:07:30 PM

Muddy's Zone
Fetcher[
set{x,count(volume 1 day ago above volume 2 days ago,1)*2}
and set{y,count(volume 1 day ago above average volume(90),3)}
and set{z,x+y} and z is above 1.1
and close 1 day ago had been decreasing over the last 3 days
and average volume(90) 1 day ago is above 100000
and close 1 day ago is between 1 and 10
and low 1 day ago is below lower bollinger band(20) 1 day ago
and count(close 1 day ago above open 1 day ago,3) is below 2.1
and day change is below 0
and set{a,count(volume above volume 1 day ago,1)}
and set{toptail,high-open} /* no negative sign between high and open, added it */
and set{bottail,close-low}
and set{taildelta,bottail-toptail}
and set{b,count(taildelta is above 0,1)}
and set{c,a+b} and c is above 0
]



StockFetcher Forums · Filter Exchange · Random Collection of Filters<< >>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 2022 - 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


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.