Volatility contraction screener help
Forums › ProRealTime English forum › ProScreener support › Volatility contraction screener help
- This topic has 11 replies, 6 voices, and was last updated 5 years ago by andyj.
-
-
01/10/2018 at 3:33 AM #58789
Hi all,
I’m looking to write a basic volatility contraction screener. The idea is to find stocks in a trend by looking at the relationships between the various moving average. I would then find those that have moved into a pattern of consolidation by looking for stocks that have moved through the 9 day moving average multiple times over a 2 week period (e.g., the high-low range of 3 daily candles goes through the 9 day MA in a 10 day period). I’ve been trying to write the step that will count the number of times the range passes through the 9 day moving average but keep getting an error. The code I’ve written is as follows.
counting candles crossing up through 9 day MA1234567891011121314countdays = 10 //number of days to testupcrosses = 0 //number of crossesFOR d = 1 TO countdays DOIF Low[d]>average[9] AND High[d]<average[9] THENupcrosses = upcrosses +1ENDIFc1 = upcrosses > 3screener [c1]I have had a look through other code where people have used the FOR TO DO but am not sure if I’ve missed some logic in the argument.
Thanks for any assistance,
David
01/10/2018 at 11:31 PM #58940HI,
I realised I didn’t actually say what my problem was with the code. Basically, it doesn’t run. I get an error message telling me to complete the syntax of line 14, which is the final line. I’ve spent another hour or so trying to get this code to run, so any suggestions would be appreciated. (I have fixed having the < and > the wrong way around as well). Error message pictured below.
01/10/2018 at 11:37 PM #5894301/11/2018 at 12:35 AM #58945Thanks Vonasi, I had just worked that out and was coming on here to update the post. I have to admit, coming from a very limited programming background, I find this a little slow to get through. The help on these forums has been great though and I do appreciate people taking the time to assist relatively inexperienced people like myself. I will continue to try reading other people’s screeners and the PRT screener manual before bothering people on the forum though 🙂
01/11/2018 at 12:41 AM #5894701/11/2018 at 2:28 AM #5895201/12/2018 at 12:16 AM #59129Hi Alain,
I’m happy to share the code, though it feels simplistic compared to some of the things I’ve seen posted on these forums. I’ve defined an uptrend as any stock that has had the 100 day simple moving average rise each day for 3 months (60 days). I’ve then looked for a contraction of the trend by looking for stocks where the candles have a low that is below the 9 day moving average and a high above the 9 day moving average. The screener requires more than 3 of these crosses to occur in a 10 day period. If you have any experience with coding you can probably easily improve what I’ve written. If you’re new, I have included comments about what each section does so you can modify it to suit your needs.
Stocks in uptrend that cross 9 day MA multiple times in 10 days1234567891011121314151617181920212223242526272829//Counting candles that span the 9 day moving average for shares in an established uptrendcountdays = 10 //number of days to look back in counting crosses of the 9 day MAccrosses = 0MA9 = average[9]//count the number of candles spanning the 9 day moving averageFOR d = 1 TO countdays DOIF Close[d]>MA9 AND Open[d]<MA9 THENccrosses = ccrosses +1ENDIFNEXTc1 = ccrosses > 3 //defines the number of crosses required for the screener//define an uptrend as the 100 day moving average moving up for 60 days in a rowMA100=average[100]c2 = summation[60](MA100>MA100[1])=60 //defines the number of days the moving average must be risingcondition = c1 and c2screener [condition]I’ve been reasonably happy with what this screener has returned as some of the stocks look like they are setting up and are worth watching.
I am planning to write a similar screener that looks for a contraction in the range of the candles, eg the previous 10 candles have an average range that is perhaps 70% of the 3 month average. I think volatility contraction patterns are interesting but am not sure of the best way to find them without simply looking through lots of charts 🙂
Regards,
David
01/12/2018 at 1:02 AM #5913201/12/2018 at 1:37 AM #5913302/16/2019 at 10:54 PM #9154602/18/2019 at 9:58 AM #91606I think that Brisvegas was talking about a code like this:
1234period1 = 10period2 = 60volat = AverageTrueRange[period1]/AverageTrueRange[period2]The “volat” variable returns the volatility over the last 10 days as a coefficient of the volatility over the last 60 days (periods).
02/23/2019 at 2:11 PM #92121 -
AuthorPosts
Find exclusive trading pro-tools on