StockFetcher Forums · Filter Exchange · peaks and troughs filter<< 1 2 >>Post Follow-up
stockfetchervong
16 posts
msg #48302
Ignore stockfetchervong
12/1/2006 10:11:55 PM

please help me write a filter to bring only stocks that have a lower trough than the last trough and at the same time having macd histogram that have higher trough than the last macd histogram's trough - a divergence is happening- for long trade.

and write a filter do the opposite for short trade.



TheRumpledOne
6,411 posts
msg #48308
Ignore TheRumpledOne
modified
12/2/2006 12:19:47 PM

Fetcher[
set{dv2,count(close below close 2 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 2 days ago,1)}

set{dv3,count( close below close 3 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 3 days ago,1)}

set{dv4,count( close below close 4 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 4 days ago,1)}

set{dv5,count( close below close 5 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 5 days ago,1)}



Set{n2, dv5 * 1}
Set{n3, dv4 * 10}
Set{n4, dv3 * 100}
Set{n5, dv2 * 1000}

set{na, n2 + n3}
set{nb, na + n4}
Set{PD2345, nb + n5}

pd2345 above 0

close above 10
volume above 1000000
market is nasdaq

add column pd2345

add column MACD Histogram(12,26)
add column MACD Histogram(12,26) 52 week high
add column MACD Histogram(12,26) 52 week low

sort column 5 descending

draw MACD Histogram(12,26)
draw MACD Histogram(12,26) 52 week low
draw MACD Histogram(12,26) 52 week high

do not draw pd2345
]






Column PD2345 indicates when the POSITIVE DIVERGENCE occurred.

1000 means 2 days ago compared to today.
0100 means 3 days ago compared to today.
0010 means 4 days ago compared to today.
0001 means 5 days ago compared to today.

1100 means 2 and 3.

I posted an RSI(2) divergence filter a long time ago. I just replaced rsi(2) with MACD HISTOGRAM(12,36).

Due to SF limitations, at the time, 4 was the limit of how manys days I could test for.

HTH.






TheRumpledOne
6,411 posts
msg #48309
Ignore TheRumpledOne
modified
12/2/2006 12:23:27 PM

Fetcher[
/* PRICE MACD HISTOGRAM DIVERGENCE 2 - 6 DAYS */

set{dv2,count(close below close 2 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 2 days ago,1)}

set{dv3,count( close below close 3 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 3 days ago,1)}

set{dv4,count( close below close 4 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 4 days ago,1)}

set{dv5,count( close below close 5 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 5 days ago,1)}

set{dv6,count( close below close 6 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 6 days ago,1)}


Set{n2, dv6 * 1}
Set{n3, dv5 * 10}
Set{n4, dv4 * 100}
Set{n5, dv3 * 1000}
Set{n6, dv2 * 10000}

set{na, n2 + n3}
set{nb, na + n4}
set{nc, nb + n5}
Set{PD23456, nc + n6}

pd23456 above 0

close above 10
volume above 1000000
market is nasdaq

add column pd23456

add column MACD Histogram(12,26)
add column MACD Histogram(12,26) 52 week low

sort column 5 descending

draw MACD Histogram(12,26)
draw MACD Histogram(12,26) 52 week low
draw MACD Histogram(12,26) 52 week high

do not draw pd23456

]



I am an advanced subscriber... Let's see how far it can go!

6 DAYS WORKS.





TheRumpledOne
6,411 posts
msg #48318
Ignore TheRumpledOne
12/2/2006 12:49:01 PM

Fetcher[
set{dv2,count(close below close 2 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 2 days ago,1)}

set{dv3,count( close below close 3 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 3 days ago,1)}

set{dv4,count( close below close 4 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 4 days ago,1)}

set{dv5,count( close below close 5 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 5 days ago,1)}

set{dv6,count( close below close 6 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 6 days ago,1)}

set{dv7,count( close below close 7 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 7 days ago,1)}

set{dv8,count( close below close 8 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 8 days ago,1)}

set{dv9,count( close below close 9 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 9 days ago,1)}

set{dv10,count( close below close 10 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 10 days ago,1)}

set{dv11,count( close below close 11 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 11 days ago,1)}

set{dv12,count( close below close 12 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 12 days ago,1)}

set{dv13,count( close below close 13 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 13 days ago,1)}

set{dv14,count( close below close 14 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 14 days ago,1)}

Set{n14, dv14 * 10000000000}
Set{n13, dv13 * 1000000000}
Set{n12, dv12 * 100000000}
Set{n11, dv11 * 10000000}
Set{n10, dv10 * 1000000}
Set{n9, dv9 * 100000}
Set{n8, dv8 * 10000}
Set{n7, dv7 * 1000}
Set{n6, dv6 * 100}
Set{n5, dv5 * 10}
Set{n4, dv4 * 1}
Set{n3, dv3 * .10}
Set{n2, dv2 * .01}

set{nk, n14 + n13}
set{nj, nk + n12}
set{ni, nj + n11}
set{nh, ni + n10}
set{ng, nh + n9}
set{nf, ng + n8}
set{ne, nf + n7}
set{nd, ne + n6}
set{nc, nd + n5}
set{nb, nc + n4}
set{na, nb + n3}
Set{PD4321098765432, na + n2}

pd4321098765432 above 0

close above 10
volume above 1000000
market is nasdaq

add column pd4321098765432

add column MACD Histogram(12,26)
add column MACD Histogram(12,26) 52 week low

sort column 5 descending

draw MACD Histogram(12,26)
draw MACD Histogram(12,26) 52 week low
draw MACD Histogram(12,26) 52 week high

do not draw pd4321098765432
]



FINALLY PUSHED IT TO THE LIMIT!!

13 days is the max.




TheRumpledOne
6,411 posts
msg #48316
Ignore TheRumpledOne
modified
12/2/2006 12:49:23 PM

Fetcher[
set{dv2,count(close below close 2 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 2 days ago,1)}

set{dv3,count( close below close 3 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 3 days ago,1)}

set{dv4,count( close below close 4 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 4 days ago,1)}

set{dv5,count( close below close 5 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 5 days ago,1)}

set{dv6,count( close below close 6 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 6 days ago,1)}

set{dv7,count( close below close 7 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 7 days ago,1)}

set{dv8,count( close below close 8 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 8 days ago,1)}

set{dv9,count( close below close 9 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 9 days ago,1)}

set{dv10,count( close below close 10 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 10 days ago,1)}

set{dv11,count( close below close 11 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 11 days ago,1)}

set{dv12,count( close below close 12 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 12 days ago,1)}

set{dv13,count( close below close 13 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 13 days ago,1)}


Set{n13, dv13 * 100000000000}
Set{n12, dv12 * 10000000000}
Set{n11, dv11 * 1000000000}
Set{n10, dv10 * 100000000}
Set{n9, dv9 * 10000000}
Set{n8, dv8 * 1000000}
Set{n7, dv7 * 100000}
Set{n6, dv6 * 10000}
Set{n5, dv5 * 1000}
Set{n4, dv4 * 100}
Set{n3, dv3 * 10}

set{nj, n12 + n13}
set{ni, nj + n11}
set{nh, ni + n10}
set{ng, nh + n9}
set{nf, ng + n8}
set{ne, nf + n7}
set{nd, ne + n6}
set{nc, nd + n5}
set{nb, nc + n4}
set{na, nb + n3}
Set{PD321098765432, na + dv2}

pd321098765432 above 0

close above 10
volume above 1000000
market is nasdaq

add column pd321098765432

add column MACD Histogram(12,26)
add column MACD Histogram(12,26) 52 week low

sort column 5 descending

draw MACD Histogram(12,26)
draw MACD Histogram(12,26) 52 week low
draw MACD Histogram(12,26) 52 week high

do not draw pd321098765432
]



13 days works.

This power of this is AWESOME!




TheRumpledOne
6,411 posts
msg #48315
Ignore TheRumpledOne
modified
12/2/2006 12:49:45 PM

Fetcher[
set{dv2,count(close below close 2 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 2 days ago,1)}

set{dv3,count( close below close 3 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 3 days ago,1)}

set{dv4,count( close below close 4 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 4 days ago,1)}

set{dv5,count( close below close 5 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 5 days ago,1)}

set{dv6,count( close below close 6 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 6 days ago,1)}

set{dv7,count( close below close 7 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 7 days ago,1)}

set{dv8,count( close below close 8 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 8 days ago,1)}

set{dv9,count( close below close 9 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 9 days ago,1)}

set{dv10,count( close below close 10 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 10 days ago,1)}

set{dv11,count( close below close 11 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 11 days ago,1)}

set{dv12,count( close below close 12 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 12 days ago,1)}


Set{n12, dv12 * 10000000000}
Set{n11, dv11 * 1000000000}
Set{n10, dv10 * 100000000}
Set{n9, dv9 * 10000000}
Set{n8, dv8 * 1000000}
Set{n7, dv7 * 100000}
Set{n6, dv6 * 10000}
Set{n5, dv5 * 1000}
Set{n4, dv4 * 100}
Set{n3, dv3 * 10}


set{ni, n12 + n11}
set{nh, ni + n10}
set{ng, nh + n9}
set{nf, ng + n8}
set{ne, nf + n7}
set{nd, ne + n6}
set{nc, nd + n5}
set{nb, nc + n4}
set{na, nb + n3}
Set{PD21098765432, na + dv2}

pd21098765432 above 0

close above 10
volume above 1000000
market is nasdaq

add column pd21098765432

add column MACD Histogram(12,26)
add column MACD Histogram(12,26) 52 week low

sort column 5 descending

draw MACD Histogram(12,26)
draw MACD Histogram(12,26) 52 week low
draw MACD Histogram(12,26) 52 week high

do not draw pd21098765432
]



12 days works!

Is there a limit?





TheRumpledOne
6,411 posts
msg #48314
Ignore TheRumpledOne
modified
12/2/2006 12:50:10 PM

Fetcher[
set{dv2,count(close below close 2 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 2 days ago,1)}

set{dv3,count( close below close 3 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 3 days ago,1)}

set{dv4,count( close below close 4 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 4 days ago,1)}

set{dv5,count( close below close 5 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 5 days ago,1)}

set{dv6,count( close below close 6 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 6 days ago,1)}

set{dv7,count( close below close 7 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 7 days ago,1)}

set{dv8,count( close below close 8 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 8 days ago,1)}

set{dv9,count( close below close 9 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 9 days ago,1)}

set{dv10,count( close below close 10 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 10 days ago,1)}

set{dv11,count( close below close 11 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 11 days ago,1)}

Set{n11, dv11 * 1000000000}
Set{n10, dv10 * 100000000}
Set{n9, dv9 * 10000000}
Set{n8, dv8 * 1000000}
Set{n7, dv7 * 100000}
Set{n6, dv6 * 10000}
Set{n5, dv5 * 1000}
Set{n4, dv4 * 100}
Set{n3, dv3 * 10}

set{nh, n10 + n11}
set{ng, nh + n9}
set{nf, ng + n8}
set{ne, nf + n7}
set{nd, ne + n6}
set{nc, nd + n5}
set{nb, nc + n4}
set{na, nb + n3}
Set{PD1098765432, na + dv2}

pd1098765432 above 0

close above 10
volume above 1000000
market is nasdaq

add column pd1098765432

add column MACD Histogram(12,26)
add column MACD Histogram(12,26) 52 week low

sort column 5 descending

draw MACD Histogram(12,26)
draw MACD Histogram(12,26) 52 week low
draw MACD Histogram(12,26) 52 week high

do not draw pd1098765432
]



11 days works... wonder how far I can go...




TheRumpledOne
6,411 posts
msg #48310
Ignore TheRumpledOne
modified
12/2/2006 12:50:29 PM

Fetcher[
set{dv2,count(close below close 2 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 2 days ago,1)}

set{dv3,count( close below close 3 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 3 days ago,1)}

set{dv4,count( close below close 4 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 4 days ago,1)}

set{dv5,count( close below close 5 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 5 days ago,1)}

set{dv6,count( close below close 6 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 6 days ago,1)}

set{dv7,count( close below close 7 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 7 days ago,1)}

Set{n7, dv7 * 100000}
Set{n6, dv6 * 10000}
Set{n5, dv5 * 1000}
Set{n4, dv4 * 100}
Set{n3, dv3 * 10}

set{nd, n6 + n7}
set{nc, nd + n5}
set{nb, nc + n4}
set{na, nb + n3}
Set{PD765432, na + dv2}

pd765432 above 0

close above 10
volume above 1000000
market is nasdaq

add column pd765432

add column MACD Histogram(12,26)
add column MACD Histogram(12,26) 52 week low

sort column 5 descending

draw MACD Histogram(12,26)
draw MACD Histogram(12,26) 52 week low
draw MACD Histogram(12,26) 52 week high

do not draw pd765432
]



7 days works!

I reversed the order of the PD column so it's easier to add to it.





TheRumpledOne
6,411 posts
msg #48311
Ignore TheRumpledOne
modified
12/2/2006 12:50:44 PM

Fetcher[
set{dv2,count(close below close 2 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 2 days ago,1)}

set{dv3,count( close below close 3 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 3 days ago,1)}

set{dv4,count( close below close 4 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 4 days ago,1)}

set{dv5,count( close below close 5 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 5 days ago,1)}

set{dv6,count( close below close 6 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 6 days ago,1)}

set{dv7,count( close below close 7 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 7 days ago,1)}

set{dv8,count( close below close 8 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 8 days ago,1)}

Set{n8, dv8 * 1000000}
Set{n7, dv7 * 100000}
Set{n6, dv6 * 10000}
Set{n5, dv5 * 1000}
Set{n4, dv4 * 100}
Set{n3, dv3 * 10}

set{ne, n8 + n7}
set{nd, ne + n6}
set{nc, nd + n5}
set{nb, nc + n4}
set{na, nb + n3}
Set{PD8765432, na + dv2}

pd8765432 above 0

close above 10
volume above 1000000
market is nasdaq

add column pd8765432

add column MACD Histogram(12,26)
add column MACD Histogram(12,26) 52 week low

sort column 5 descending

draw MACD Histogram(12,26)
draw MACD Histogram(12,26) 52 week low
draw MACD Histogram(12,26) 52 week high

do not draw pd8765432
]



8 days works!!




TheRumpledOne
6,411 posts
msg #48312
Ignore TheRumpledOne
modified
12/2/2006 12:50:56 PM

Fetcher[
set{dv2,count(close below close 2 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 2 days ago,1)}

set{dv3,count( close below close 3 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 3 days ago,1)}

set{dv4,count( close below close 4 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 4 days ago,1)}

set{dv5,count( close below close 5 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 5 days ago,1)}

set{dv6,count( close below close 6 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 6 days ago,1)}

set{dv7,count( close below close 7 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 7 days ago,1)}

set{dv8,count( close below close 8 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 8 days ago,1)}

set{dv9,count( close below close 9 days ago,1) * count( MACD Histogram(12,26) above MACD Histogram(12,26) 9 days ago,1)}


Set{n9, dv9 * 10000000}
Set{n8, dv8 * 1000000}
Set{n7, dv7 * 100000}
Set{n6, dv6 * 10000}
Set{n5, dv5 * 1000}
Set{n4, dv4 * 100}
Set{n3, dv3 * 10}

set{nf, n8 + n9}
set{ne, nf + n7}
set{nd, ne + n6}
set{nc, nd + n5}
set{nb, nc + n4}
set{na, nb + n3}
Set{PD98765432, na + dv2}

pd98765432 above 0

close above 10
volume above 1000000
market is nasdaq

add column pd98765432

add column MACD Histogram(12,26)
add column MACD Histogram(12,26) 52 week low

sort column 5 descending

draw MACD Histogram(12,26)
draw MACD Histogram(12,26) 52 week low
draw MACD Histogram(12,26) 52 week high

do not draw pd98765432
]



9 days works.



StockFetcher Forums · Filter Exchange · peaks and troughs filter<< 1 2 >>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.