StockFetcher Forums · Filter Exchange · ATR BAND Filter by four and durgin<< >>Post Follow-up
ron22
255 posts
msg #151935
Ignore ron22
4/27/2020 6:56:40 PM

Is it possible to track the number of consecutive days A) closing price is above and below the upper ATR line and B) closing price is above and below MA14? I would greatly appreciate it if someone would please add these 4 counts to this filter. Thank you very much. Ron


Fetcher[
/* ATR BAND FILTER */
draw ma(14)
set{ tmp , atr(14)}
set{ line_upper, ma(14) + tmp }
set{ line_lower, ma(14) - tmp }


draw line_upper on plot close
draw line_lower on plot close

do not draw Keltner bands

close above 20
volume above 20000000
]



Mactheriverrat
3,153 posts
msg #151937
Ignore Mactheriverrat
4/27/2020 7:21:43 PM

Interesting code there .

Cheese
1,374 posts
msg #151938
Ignore Cheese
modified
4/27/2020 8:11:54 PM

@ron22,
Is this what you are looking for?

Fetcher[
/* https://www.stockfetcher.com/forums/Filter-Exchange/ATR-BAND-Filter-by-four-and-durgin/151935 */
/* ATR BAND FILTER */
/* code by Cheese 4/27/2020 8:11:54 PM */

draw ma(14)
set{ tmp , atr(14)}
set{ line_upper, ma(14) + tmp }
set{ line_lower, ma(14) - tmp }


draw line_upper on plot close
draw line_lower on plot close

do not draw Keltner bands

close above 20
volume above 20000000

chart-time 5 months
set{above_line_upper,days( close is BELOW line_upper ,252)}
set{below_line_upper,days( close is ABOVE line_upper ,252)}
add column above_line_upper {above_line_upper}
add column below_line_upper {below_line_upper}
PlotType{above_line_upper,zerobar}
PlotType{below_line_upper,zerobar}
draw above_line_upper
draw below_line_upper
set{diff_line_upper, above_line_upper - below_line_upper}
draw diff_line_upper line at 0

set{above_ma14,days( close is BELOW ma(14) ,252)}
set{below_ma14,days( close is ABOVE ma(14) ,252)}
add column above_ma14 {above_ma14}
add column below_ma14 {below_ma14}
PlotType{above_ma14,zerobar}
PlotType{below_ma14,zerobar}
draw above_ma14
draw below_ma14
set{diff_ma14, above_ma14 - below_ma14}
draw diff_ma14 line at 0
]




ron22
255 posts
msg #151940
Ignore ron22
4/27/2020 10:25:20 PM

@Cheese, That is exactly what I was looking for. Thank you very much and Good Trading! Ron

xarlor
581 posts
msg #151942
Ignore xarlor
4/28/2020 9:29:31 AM

Nice filter ron22! Trying to identify possible trading strategies and came up with a quick swing trade. I wish SF still had the backtesting function.

Fetcher[
/* Enter long when close crosses above lower line. Exit if close below lower line or above ma(14). */

/* ATR BAND FILTER */
draw ma(14)
set{ tmp , atr(14)}
set{ line_upper, ma(14) + tmp }
set{ line_lower, ma(14) - tmp }


draw line_upper on plot close
draw line_lower on plot close

do not draw Keltner bands

close above 20
volume above 20000000

set{long1,count(close crossed above line_lower,1)}
set{long2,count(high below ma(14),1)}
set{LONG,long1 * long2}
LONG > 0
]



ron22
255 posts
msg #151945
Ignore ron22
4/28/2020 6:23:04 PM

@xarlor, I hope that the swing trade strategy works out for you. Using the lower line for an exit is smart. The lower line can act as support.

StockFetcher Forums · Filter Exchange · ATR BAND Filter by four and durgin<< >>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.