8x Multicolour Market States
Forums › ProRealTime English forum › ProBuilder support › 8x Multicolour Market States
- This topic has 28 replies, 5 voices, and was last updated 4 years ago by Bard.
Tagged: BB, bollinger bands, market, phases
-
-
05/05/2020 at 2:41 AM #129950
So I had this idea years ago that I was going to sit down one day and classify the markets as to whether they were trending, ranging, volatile or calm. The idea came from
Randy Stuckey who used to develop and sell trading systems with his company Mindfire Systems:123456789101112//Trending and Volatile//1 Trending Up and Volatile = DARK GREEN (0,150,0)//2 Trending Down and Volatile = DARK RED (153,0,0)//Trending and Calm//3 Trending Up and Calm = LIGHT GREEN (204,255,153)//4 Trending Down and Calm = LIGHT RED (255,102,102)//Ranging and Volatile//5 Ranging Up and Volatile = DARK BLUE (0,0,204) Consolidation Up//6 Ranging Down and Volatile = DARK ORANGE (76,153,0) Consolidation Down//Ranging and Calm//7 Ranging Up and Calm = LIGHT AQUA (153,255,255) Consolidation Up//8 Ranging Down and Calm = LIGHT PINK (255,153,255) Consolidation UpI then saw this interesting Multicolour Bollinger Bands indicator by @Supertiti: https://www.prorealcode.com/prorealtime-indicators/multicolour-bollinger-bands-market-phases/
which spurred me on to develop one using implied volatility, the Kaufman Efficiency Ratio and a Bear/Bull indicator I developed a while back that uses the responsive ALMA moving
Average.It’s a second “draft,” I just wondered if anyone had any ideas, perhaps to make the colour zones more solid and longer lasting as in the Supertiti version?
I wasn’t sure if it was respecting all the rules particularly with the moving averages and closes and there didn’t seem to be enough dark green sections?Either way it appears to give an immediate sense of what kind of market environment you’re in.
Let me know what you think and/or how it could be improved?
Cheers
BardPs/ If you tag me it’s @Brad. Slight admin b^&*s up. Don’t ask… 😀
“8x Multicolour Market States”
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292// Bard’s 8x Multicolour Market States//04/05/2019 v2//P = 20 //bb20 period --- Add in VARIABLES//Dev = 2.0 //std deviation factor --- Add in VARIABLES//X = 90 //background alpha --- Add in VARIABLES//Trending and Volatile//1 Trending Up and Volatile = DARK GREEN (0,150,0)//2 Trending Down and Volatile = DARK RED (153,0,0)//Trending and Calm//3 Trending Up and Calm = LIGHT GREEN (204,255,153)//4 Trending Down and Calm = LIGHT RED (255,102,102)//Ranging and Volatile//5 Ranging Up and Volatile = DARK BLUE (0,0,204) Consolidation Up//6 Ranging Down and Volatile = DARK ORANGE (76,153,0) Consolidation Down//Ranging and Calm//7 Ranging Up and Calm = LIGHT AQUA (153,255,255) Consolidation Up//8 Ranging Down and Calm = LIGHT PINK (255,153,255) Consolidation UpDEFPARAM CalculateOnLastBars = 5000EMA20 = ExponentialAverage[20](close)//ALMA//=================================================================//ShortMA = 50MediumMA = 100LongMA = 200Period = 50 //start with 50 periodsSeries = customcloseFOR j = 1 TO 3Sigma = 6Offset = 0.85m = ROUND(Offset * (Period - 1))s = Period / SigmaWtdSum = 0CumWt = 0FOR k = 0 TO Period - 1 DOWtd = EXP(-((k - m) * (k - m)) / (2 * s * s))WtdSum = WtdSum + Wtd * Series[Period - 1 - k]CumWt = CumWt + WtdNEXTIF CumWt <= 0 THENAFR = SeriesELSEAFR = WtdSum / CumWtENDIFIF j = 1 THENShortMA = AFRELSIF j = 2 THENMediumMA = AFRELSELongMA = AFRENDIFPeriod = Period * 2 //doubles the periodsNEXT//Bull Market increase in PricesBullC1 = Close[0] > ShortMABullC2 = Close[0] > MediumMABullC3 = Close[0] > LongMA//BullC4 = Close[0] >= (Close[200] * 1.2)//Bear Market decrease in PricesBearC5 = Close[0] < ShortMABearC6 = Close[0] < MediumMABearC7 = Close[0] < LongMAIf BullC1 = 0 and BullC2 = 0 and BullC3 = 0 and BearC5 = -0 and BearC6 = -0 and BearC7 = -0 thenNoBullorBear = 0Endif//=================================================================////BollingerBollUp =Average[PeriodBoll](close)+dev*std[PeriodBoll](close)BollDown = Average[PeriodBoll](close)-dev*std[PeriodBoll](close)//=================================================================////"Williams' VixFix IV R+P//Implied Volatility Rank and Percentile Indicator — MARKET TOPS//By Vonasi //Date 20191018//NEED 1000 UNITS FOR AQUA BLUE PEAK OUTS//SettingsHiLoPeriod = 365 //Highest/Lowest PeriodIVperiod = 22 //IVperiod//Inverse Vix Fix - Low IV Proxy//MODIFIED LOW VOL//Inverse Vix Fix - Low IV Proxy//MODIFIED LOW VOL//Correct but worse performing wvfinverse for spotting tops.//wvf = ((high-lowest[IVperiod](close))/(lowest[IVperiod](close)))*100//High Volatility Market Bottoms - Non Inverse Vix Fixwvf = ((highest[IVperiod](close)-low)/(lowest[IVperiod](close)))*100//Boundariesupper = highest[HiLoPeriod](wvf)lower = lowest[HiLoPeriod](wvf)//wvflev = 100-((wvf-lower)/(upper-lower)*100) //Doesn't Show Low Vol Topswvflev = ((wvf-lower)/(upper-lower)*100)//=================================================================////Kaufman's Efficiency RatioPeriodKER = 20Change = ABS(close - close[PeriodKER])calc = ABS(close - close[1])volat = summation[PeriodKER](calc)KER = Change / volat//Conditions//=================================================================////Trending and Volatile//1 Trending Up and Volatile = DARK GREEN (0,150,0)//ALMA BULL/BEARBullC1 = Close[0] > ShortMABullC2 = Close[0] > MediumMABullC3 = Close[0] > LongMA//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI1 = (CTI20 > 25)VixFix1 = (wvflev > 50)If BullC1 and BullC2 and BullC3 and VixFix1 thenIndicator = close //Indicator =1r=0g=150b=0Endif//=================================================================////2 Trending Down and Volatile = DARK RED (153,0,0)//ALMA BULL/BEARBearC5 = Close[0] < ShortMABearC6 = Close[0] < MediumMABearC7 = Close[0] < LongMA//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI2 = (CTI20 > 25)VixFix2 = (wvflev > 50)If BearC5 and BearC6 and BearC7 and VixFix2 thenIndicator = close //Indicator =1r=204g=0b=0Endif//=================================================================////Trending and Calm//3 Trending Up and Calm = LIGHT GREEN (204,255,153)//ALMA BULL/BEARBullC1 = Close[0] > ShortMABullC2 = Close[0] > MediumMABullC3 = Close[0] > LongMA//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI3 = (CTI20 > 25)VixFix3 = (wvflev < 50)If BullC1 and BullC2 and BullC3 and VixFix3 thenIndicator = close //Indicator =1r=204g=255b=153Endif//=================================================================////4 Trending Down and Calm = LIGHT RED (255,102,102)//ALMA BULL/BEARBearC5 = Close[0] < ShortMABearC6 = Close[0] < MediumMABearC7 = Close[0] < LongMA//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI4 = (CTI20 > 25)VixFix4 = (wvflev < 50)If BearC5 and BearC6 and BearC7 and VixFix4 thenIndicator = close //Indicator =1r=255g=102b=102Endif//=================================================================////Ranging and Volatile//5 Ranging Up and Volatile = DARK BLUE (0,0,204) Consolidation UpALMAC5=(ShortMA>LongMA)and(close>LongMA)and(close>MediumMA)//and((close<ShortMA))//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI5 = (CTI20 > 25)KER5 = (KER > 0.3)VixFix5 = (wvflev > 50)If ALMAC5 and KER5 and VixFix5 thenIndicator = close //Indicator =1r=0g=0b=204Endif//=================================================================////6 Ranging Down and Volatile = DARK ORANGE (76,153,0) Consolidation DownALMAC6=(ShortMA>LongMA)and(close>LongMA)and(close>MediumMA)//and((close<ShortMA))//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI6 = (CTI20 < 25)KER6 = (KER > 0.3)VixFix6 = (wvflev > 50)If ALMAC6 and KER6 and VixFix6 thenIndicator = close //Indicator =1r=76g=153b=0Endif//=================================================================////Ranging and Calm//7 Ranging Up and Calm = LIGHT AQUA (153,255,255) Consolidation UpALMAC7=(ShortMA>LongMA)and(close>LongMA)and(close>MediumMA) //and((close<ShortMA))//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI7 = (CTI20 < 25)BullBear7 = (NoBullorBear = 0)KER7 = (KER < 0.3)VixFix7 = (wvflev < 50)If ALMAC7 and BullBear7 and KER7 and VixFix7 thenIndicator = close //Indicator =1r= 153g=255b=255Endif//=================================================================////8 Ranging Down and Calm = LIGHT PINK (255,153,255) Consolidation UpALMAC8=(ShortMA<LongMA)and(close<LongMA)and(close<MediumMA)//and((close<ShortMA))//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI8 = (CTI20 < 25)BullBear8 = (NoBullorBear = 0)KER8 = (KER < 0.3)VixFix8 = (wvflev < 50)If ALMAC8 and BullBear8 and KER8 and VixFix8 thenIndicator = close //Indicator =1r=255g=153b=255Endifmax1=BollUpmin1=BollDownDRAWCANDLE(max1, min1, max1, min1)coloured(R,G,B,x)RETURN EMA20 style(line) as "EMA20", BollUp as "BollUp", BollDown as "BollDown", indicator05/06/2020 at 12:17 PM #13021505/06/2020 at 1:14 PM #13022605/06/2020 at 1:22 PM #13022905/06/2020 at 1:40 PM #130230Whoever wants to communicate with some users should use the contact form (Contact Us) to ask permission to Admin.
05/06/2020 at 1:46 PM #13023105/06/2020 at 2:44 PM #130246Thanks @Bel, it took many hours. Worth also checking out my posts on the work of Cynthia Kase (Kase Dev Stop v3) and John Ehlers.
Looking at Kase Dev Stop research and def on the list to explore. Kase bars also should be interesting imo:)
05/07/2020 at 8:22 AM #130381Thanks Bard, very interesting, I had trouble to make the indicator to work, so I attach the code with all settings available at the top.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292DEFPARAM CalculateOnLastBars = 5000// Bard’s 8x Multicolour Market States//04/05/2019 v2PeriodBoll = 20 //bb20 period --- Add in VARIABLESDev = 2.0 //std deviation factor --- Add in VARIABLESX = 50 //background alpha --- Add in VARIABLES//Trending and Volatile//1 Trending Up and Volatile = DARK GREEN (0,150,0)//2 Trending Down and Volatile = DARK RED (153,0,0)//Trending and Calm//3 Trending Up and Calm = LIGHT GREEN (204,255,153)//4 Trending Down and Calm = LIGHT RED (255,102,102)//Ranging and Volatile//5 Ranging Up and Volatile = DARK BLUE (0,0,204) Consolidation Up//6 Ranging Down and Volatile = DARK ORANGE (76,153,0) Consolidation Down//Ranging and Calm//7 Ranging Up and Calm = LIGHT AQUA (153,255,255) Consolidation Up//8 Ranging Down and Calm = LIGHT PINK (255,153,255) Consolidation UpEMA20 = ExponentialAverage[20](close)//ALMA//=================================================================//ShortMA = 50MediumMA = 100LongMA = 200Period = 50 //start with 50 periodsSeries = customcloseFOR j = 1 TO 3Sigma = 6Offset = 0.85m = ROUND(Offset * (Period - 1))s = Period / SigmaWtdSum = 0CumWt = 0FOR k = 0 TO Period - 1 DOWtd = EXP(-((k - m) * (k - m)) / (2 * s * s))WtdSum = WtdSum + Wtd * Series[Period - 1 - k]CumWt = CumWt + WtdNEXTIF CumWt <= 0 THENAFR = SeriesELSEAFR = WtdSum / CumWtENDIFIF j = 1 THENShortMA = AFRELSIF j = 2 THENMediumMA = AFRELSELongMA = AFRENDIFPeriod = Period * 2 //doubles the periodsNEXT//Bull Market increase in PricesBullC1 = Close[0] > ShortMABullC2 = Close[0] > MediumMABullC3 = Close[0] > LongMA//BullC4 = Close[0] >= (Close[200] * 1.2)//Bear Market decrease in PricesBearC5 = Close[0] < ShortMABearC6 = Close[0] < MediumMABearC7 = Close[0] < LongMAIf BullC1 = 0 and BullC2 = 0 and BullC3 = 0 and BearC5 = -0 and BearC6 = -0 and BearC7 = -0 thenNoBullorBear = 0Endif//=================================================================////BollingerBollUp =Average[PeriodBoll](close)+dev*std[PeriodBoll](close)BollDown = Average[PeriodBoll](close)-dev*std[PeriodBoll](close)//=================================================================////"Williams' VixFix IV R+P//Implied Volatility Rank and Percentile Indicator — MARKET TOPS//By Vonasi //Date 20191018//NEED 1000 UNITS FOR AQUA BLUE PEAK OUTS//SettingsHiLoPeriod = 365 //Highest/Lowest PeriodIVperiod = 22 //IVperiod//Inverse Vix Fix - Low IV Proxy//MODIFIED LOW VOL//Inverse Vix Fix - Low IV Proxy//MODIFIED LOW VOL//Correct but worse performing wvfinverse for spotting tops.//wvf = ((high-lowest[IVperiod](close))/(lowest[IVperiod](close)))*100//High Volatility Market Bottoms - Non Inverse Vix Fixwvf = ((highest[IVperiod](close)-low)/(lowest[IVperiod](close)))*100//Boundariesupper = highest[HiLoPeriod](wvf)lower = lowest[HiLoPeriod](wvf)//wvflev = 100-((wvf-lower)/(upper-lower)*100) //Doesn't Show Low Vol Topswvflev = ((wvf-lower)/(upper-lower)*100)//=================================================================////Kaufman's Efficiency RatioPeriodKER = 20Change = ABS(close - close[PeriodKER])calc = ABS(close - close[1])volat = summation[PeriodKER](calc)KER = Change / volat//Conditions//=================================================================////Trending and Volatile//1 Trending Up and Volatile = DARK GREEN (0,150,0)//ALMA BULL/BEARBullC1 = Close[0] > ShortMABullC2 = Close[0] > MediumMABullC3 = Close[0] > LongMA//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI1 = (CTI20 > 25)VixFix1 = (wvflev > 50)If BullC1 and BullC2 and BullC3 and VixFix1 thenIndicator = close //Indicator =1r=0g=150b=0Endif//=================================================================////2 Trending Down and Volatile = DARK RED (153,0,0)//ALMA BULL/BEARBearC5 = Close[0] < ShortMABearC6 = Close[0] < MediumMABearC7 = Close[0] < LongMA//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI2 = (CTI20 > 25)VixFix2 = (wvflev > 50)If BearC5 and BearC6 and BearC7 and VixFix2 thenIndicator = close //Indicator =1r=204g=0b=0Endif//=================================================================////Trending and Calm//3 Trending Up and Calm = LIGHT GREEN (204,255,153)//ALMA BULL/BEARBullC1 = Close[0] > ShortMABullC2 = Close[0] > MediumMABullC3 = Close[0] > LongMA//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI3 = (CTI20 > 25)VixFix3 = (wvflev < 50)If BullC1 and BullC2 and BullC3 and VixFix3 thenIndicator = close //Indicator =1r=204g=255b=153Endif//=================================================================////4 Trending Down and Calm = LIGHT RED (255,102,102)//ALMA BULL/BEARBearC5 = Close[0] < ShortMABearC6 = Close[0] < MediumMABearC7 = Close[0] < LongMA//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI4 = (CTI20 > 25)VixFix4 = (wvflev < 50)If BearC5 and BearC6 and BearC7 and VixFix4 thenIndicator = close //Indicator =1r=255g=102b=102Endif//=================================================================////Ranging and Volatile//5 Ranging Up and Volatile = DARK BLUE (0,0,204) Consolidation UpALMAC5=(ShortMA>LongMA)and(close>LongMA)and(close>MediumMA)//and((close<ShortMA))//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI5 = (CTI20 > 25)KER5 = (KER > 0.3)VixFix5 = (wvflev > 50)If ALMAC5 and KER5 and VixFix5 thenIndicator = close //Indicator =1r=0g=0b=204Endif//=================================================================////6 Ranging Down and Volatile = DARK ORANGE (76,153,0) Consolidation DownALMAC6=(ShortMA>LongMA)and(close>LongMA)and(close>MediumMA)//and((close<ShortMA))//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI6 = (CTI20 < 25)KER6 = (KER > 0.3)VixFix6 = (wvflev > 50)If ALMAC6 and KER6 and VixFix6 thenIndicator = close //Indicator =1r=76g=153b=0Endif//=================================================================////Ranging and Calm//7 Ranging Up and Calm = LIGHT AQUA (153,255,255) Consolidation UpALMAC7=(ShortMA>LongMA)and(close>LongMA)and(close>MediumMA) //and((close<ShortMA))//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI7 = (CTI20 < 25)BullBear7 = (NoBullorBear = 0)KER7 = (KER < 0.3)VixFix7 = (wvflev < 50)If ALMAC7 and BullBear7 and KER7 and VixFix7 thenIndicator = close //Indicator =1r= 153g=255b=255Endif//=================================================================////8 Ranging Down and Calm = LIGHT PINK (255,153,255) Consolidation UpALMAC8=(ShortMA<LongMA)and(close<LongMA)and(close<MediumMA)//and((close<ShortMA))//ignored, CTI20, ignored, ignored, ignored, ignored = CALL "Ehler's Correlation Trend R2X3"[5, 20, 40](close)//CTI8 = (CTI20 < 25)BullBear8 = (NoBullorBear = 0)KER8 = (KER < 0.3)VixFix8 = (wvflev < 50)If ALMAC8 and BullBear8 and KER8 and VixFix8 thenIndicator = close //Indicator =1r=255g=153b=255Endifmax1=BollUpmin1=BollDownDRAWCANDLE(max1, min1, max1, min1)coloured(R,G,B,x)bordercolor(r,g,b,0)RETURN EMA20 style(line) as "EMA20", BollUp as "BollUp", BollDown as "BollDown", indicator1 user thanked author for this post.
05/07/2020 at 11:53 AM #13042005/08/2020 at 8:44 AM #13055205/08/2020 at 10:28 AM #130578Hi Bel, no I haven’t. Have you backtested them to see if there is an edge? Maybe worth starting a new topic in a new thread?
Ps, I am reachable on @Brad but it’s actually “Bard,” despite what my profile link says (it was an admin error)! Lol.
05/08/2020 at 10:45 AM #130582Hi Bel, no I haven’t. Have you backtested them to see if there is an edge? Maybe worth starting a new topic in a new thread?
Ps, I am reachable on @brad but it’s actually “Bard,” despite what my profile link says (it was an admin error)! Lol.
Hi mate, no worries lol
I’d def worth to explore but would need to code them as there’s none in PRT language from what I was able to find.
Regards,
Bel.
05/08/2020 at 12:08 PM #130606just showing the first 4 defined market states,
Correction: Showing: Trending and Volatile, Trending and Calm, Ranging and Volatile and Ranging and Calm.
05/09/2020 at 12:01 AM #130681The multicolour multi state indicator shows high and low volatility markets trending either up or down.
Trend is determined by four ALMA moving averages and the volatility is based on a 22 period Williams Vix Fix / Percentile Rank indicator (coded by Vonasi) over 365 days, ranked as a percentage.
I might yet do a version with an advanced ADX indicator to depict ranging markets (both volatile and calm), that was actually the basis for what turned into this idicator.
Anyone who says there isn’t a relationship between volatility and trend hasn’t studied volatility and the options market:
High volatility is synonymous with market bottoms and low volatility with market tops. It’s not a perfect relationship but it is better to know how volatile a market is when you’re entering it and what the potential trend direction might be. A good example of a low volatility top is the peak before the current Covid19 market rout.
Implied volatility (IV) in the options market is measured over 365 days. The IV is derived from the Black Scholes Options Pricing Model. Higher IV (over historic volatility) implies higher options prices. Go long Puts and write/short Calls.
Possible improvements might be to add ranging (volatile and calm) markets and to replace the ALMA for a MA Type #65 Ehler’s Zero Lag moving average from the Average Filter Regression indicator on this forum. Next time!
4x Multicolour Trending/Volatility (No Ranging)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260// Bard’s 4x Multicolour Trending/Volatility (No Ranging)//08/05/2019 v1//P = 20 //bb20 period --- Add in VARIABLES//Dev = 2.0 //std deviation factor --- Add in VARIABLES//X = 75 //background alpha --- Add in VARIABLES//Trending Up and Volatile//Trending Down and Volatile//Trending Up and Calm//Trending Down and CalmDEFPARAM CalculateOnLastBars = 1000//=================================================================////ALMA//=================================================================////VShortMA = 25//ShortMA = 50//MediumMA = 100//LongMA = 200Period = 25 //start with 50 periodsSeries = customcloseFOR j = 1 TO 4Sigma = 6Offset = 0.85m = ROUND(Offset * (Period - 1))s = Period / SigmaWtdSum = 0CumWt = 0FOR k = 0 TO Period - 1 DOWtd = EXP(-((k - m) * (k - m)) / (2 * s * s))WtdSum = WtdSum + Wtd * Series[Period - 1 - k]CumWt = CumWt + WtdNEXTIF CumWt <= 0 THENAFR = SeriesELSEAFR = WtdSum / CumWtENDIFIF j = 1 THENVShortMA = AFRELSIF j = 2 THENShortMA = AFRELSIF j = 3 THENMediumMA = AFRELSELongMA = AFRENDIFPeriod = Period * 2 //doubles the periodsNEXT//ALMAve25 = WtdSum / CumWt//ALMAve25 = 0.5*AFR//ALMA25 = 0.5*AFR//Bull Market increase in Prices//BullC1 = Close[0] > ShortMA//BullC2 = Close[0] > MediumMA//BullC3 = Close[0] > LongMA//BullC4 = Close[0] >= (Close[200] * 1.2)//Bear Market decrease in Prices//BearC5 = Close[0] < ShortMA//BearC6 = Close[0] < MediumMA//BearC7 = Close[0] < LongMA//BearC8 = Close[0] <= (Close[200] * 1.2)//If BullC1 = 0 and BullC2 = 0 and BullC3 = 0 and BearC5 = -0 and BearC6 = -0 and BearC7 = -0 then//NoBullorBear = 0//Endif//=================================================================////"Williams' VixFix IV R+P//=================================================================////Implied Volatility Rank and Percentile Indicator — MARKET TOPS//By Vonasi //Date 20191018//NEED 1000 UNITS FOR AQUA BLUE PEAK OUTS//SettingsHiLoPeriod = 365 //Highest/Lowest PeriodIVperiod = 22 //IVperiod//Inverse Vix Fix - Low IV Proxy//MODIFIED LOW VOL//Inverse Vix Fix - Low IV Proxy//MODIFIED LOW VOL//Correct but worse performing wvfinverse for spotting tops.//wvf = ((high-lowest[IVperiod](close))/(lowest[IVperiod](close)))*100//High Volatility Market Bottoms - Non Inverse Vix Fixwvf = ((highest[IVperiod](close)-low)/(lowest[IVperiod](close)))*100//Boundariesupper = highest[HiLoPeriod](wvf)lower = lowest[HiLoPeriod](wvf)//wvflev = 100-((wvf-lower)/(upper-lower)*100) //Doesn't Show Low Vol Topswvflev = ((wvf-lower)/(upper-lower)*100)//=================================================================////Implied Volatility Rank and Percentile Indicator — MARKET TOPS//=================================================================////By Vonasi //Date 20191018//NEED 1000 UNITS//SettingsHiLoPeriod = 365 //Highest/Lowest PeriodIVperiod = 22 //IVperiod//Inverse Vix Fix - Low IV Proxy//MODIFIED LOW VOL//Correct but worse performing wvfinverse. Not sure if it is worse performing://wvf = ((high-lowest[IVperiod](close))/(lowest[IVperiod](close)))*100wvf = ((highest[IVperiod](close)-low)/(lowest[IVperiod](close)))*100//Boundariesupper = highest[HiLoPeriod](wvf)lower = lowest[HiLoPeriod](wvf)//wvflev = 100-((wvf-lower)/(upper-lower)*100) //Doesn't Show Low Vol Topswvflev = ((wvf-lower)/(upper-lower)*100)//PercentilernkCount = 0count = 0FOR i = 1 to HiLoPeriod-1count = count + 1IF (wvflev[i]) > (wvflev) THENrnkCount = rnkCount + 1endifNEXTPercentileRank = 100-(rnkCount/count)*100//Historic Volatility//HVLength = 22//annualVol = 365//periods = 7// 1 = intraday chart 7 = daily chart//Returns = log(close / close[1])//StdDev = std[HVLength](Returns)//HVol = StdDev * sqrt(annualVol) * 100 //sqrt(annualVol / periods//lowVol = lowest[annualvol](HVol)//HVrankUp = HVol - lowVol//maxVol = highest[annualvol](HVol)//HVrankLow = maxVol - lowVol//HVR = (HVrankUp / HVrankLow)*100//=================================================================////=================================================================////Bollinger//=================================================================//BollUp =Average[PeriodBoll](close)+dev*std[PeriodBoll](close)BollDown = Average[PeriodBoll](close)-dev*std[PeriodBoll](close)//=================================================================////Trending and Volatile//=================================================================////1 Trending Up and Volatile = DARK GREEN (0,150,0)//ALMA BULL/BEARBullC0 = Close[0] > VShortMABullC1 = Close[0] > ShortMA//BullC2 = Close[0] > MediumMA//BullC3 = Close[0] > LongMA//VixFix1 = (wvflev > 50)PercRankTV = PercentileRank > 50If BullC0 and BullC1 and PercRankTV then//and BullC2 and BullC3Indicator = close //Indicator =1r=0g=150b=0Endif//=================================================================////2 Trending Down and Volatile = RED (255,0,0)//ALMA BULL/BEARBearC4 = Close[0] < VShortMABearC5 = Close[0] < ShortMA//BearC6 = Close[0] < MediumMA//BearC7 = Close[0] < LongMA//VixFix2 = (wvflev > 50)PercRankTV = PercentileRank > 50If BearC4 and BearC5 and PercRankTV thenIndicator = close //Indicator =1r=255g=0b=0Endif//=================================================================////Trending and Calm//=================================================================////3 Trending Up and Calm = LIGHT GREEN (204,255,153)//ALMA BULL/BEARBullC0 = Close[0] > VShortMABullC1 = Close[0] > ShortMABullC2 = Close[0] > MediumMABullC3 = Close[0] > LongMA//VixFix3 = (wvflev < 50)PercRankTC = PercentileRank < 50If BullC0 and BullC1 and BullC2 and BullC3 and PercRankTC thenIndicator = close //Indicator =1r=204g=255b=153Endif//=================================================================////4 Trending Down and Calm = LIGHT PINK (255,153,255)//ALMA BULL/BEARBearC4 = Close[0] < VShortMABearC5 = Close[0] < ShortMABearC6 = Close[0] < MediumMABearC7 = Close[0] < LongMA//VixFix4 = (wvflev < 50)PercRankTC = PercentileRank < 50If BearC4 and BearC5 and BearC6 and BearC7 and PercRankTC thenIndicator = close //Indicator =1r=255g=153b=255Endif//=================================================================//max1=BollUpmin1=BollDownDRAWCANDLE(max1, min1, max1, min1)coloured(R,G,B,x)RETURN VShortMA coloured (204,0,204,255) style (dottedline,2) as "ALMA 25", ShortMA coloured (255,153,51,255) style (dottedline,2) as "ALMA 50", MediumMA coloured (204,0,51,255) style (dottedline,2) as "ALMA 100", LongMA coloured (153,102,255,255) style (dottedline,2) as "ALMA 200", BollUp style(dottedline) as "BollUp", BollDown style(dottedline) as "BollDown", indicator style(dottedline) as "8x Multicolour Market States"//RETURN HVR coloured(102,179,255) style (line,3) as "Historic Volatility Rank"Update:
just showing the first 4 defined market states,
Correction: Showing: Trending and Volatile, Trending and Calm, Ranging and Volatile and Ranging and Calm.
Changes need on the 8x MultiColour
Change line 164 to r=153 (previously was a wrong colour)
Change line 146 to g=205 (for better definition)05/11/2020 at 5:13 PM #131170This 4x Colour Trend/Range/Volatility/Calm indicator can be used to instantly gauge what kind of market conditions you are in. For example, before the Covid19 market rout in the £/$ you can already see the market was becoming very “skittish” from mid December onwards with lots of red and blue areas which depict higher volatility.
The trending colours are red for “Trending and Volatile” and light green for “Trending and Calm.” (Think of trends in terms of red and green as a mnemonic).
The indicator is non directional but ALMA moving averages and a Zero Lag Bollinger Band has been constructed around price.The ranging market regime is also split into volatile and calm, coloured in blue and aqua blue respectively, (again try thinking of a calm blue sea as a mnemonic for ranging conditions).
Trending or ranging is determined by use of the Damiani Volatmeter to determine the signal to noise ratio, whilst volatility is determined by a percentile rank of the 22 day implied volatility (“Williams Vix Fix”) compared to 365 day highs and lows of implied volatility. Volatile is set at greater than 50% and calm at 50% or less. You can change these if you wish, perhaps only depicting markets that are very volatile and over 75% or even 95%. Good for options traders.
I’ve left the effective ALMA Bull/Bear indicator in case you want to experiment with another way of determine a trend. Ditto with the Vix Fix for volatility.
No indicator is perfect (feel free to play with the settings) but this does go someway to giving you a more statistically based summation of market conditions thanks to Vonasi’s Williams Vix Fix indicator and Bollinger Bands set at 2 standard deviations to capture 95% of the price distribution — if prices were to follow a normal distribution. They don’t as prices suffer from skew/trends caused by the vagaries of human emotions like fear and greed!
“4x Colour Trend/Range/Volatility/Calm”
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372// Bard’s 4x Multicolour Trending/Ranging/Volatile/Calm Damiani//10/05/2019 v3//Template: 2x Colour Trend/Range Damiani//P = 20 //bb20 period --- Add in VARIABLES//Dev = 2.0 //std deviation factor --- Add in VARIABLES//X = 90 //background alpha --- Add in VARIABLES//TRENDS -- RED/GREEN// 1 Trending and Volatile = RED (204,0,0)// 2 Trending and Calm = LIGHT GREEN (255,153,255)//RANGING OUT AT SEA -- BLUE'S// 3 Ranging and Volatile = BLUE (0,128,255)// 4 Ranging and Calm AQUA BLUE (0,0,255)DEFPARAM CalculateOnLastBars = 2000//=================================================================////ALMA//=================================================================////VShortMA = 25//ShortMA = 50//MediumMA = 100//LongMA = 200Period = 25 //start with 50 periodsSeries = customcloseFOR j = 1 TO 4Sigma = 6Offset = 0.85m = ROUND(Offset * (Period - 1))s = Period / SigmaWtdSum = 0CumWt = 0FOR k = 0 TO Period - 1 DOWtd = EXP(-((k - m) * (k - m)) / (2 * s * s))WtdSum = WtdSum + Wtd * Series[Period - 1 - k]CumWt = CumWt + WtdNEXTIF CumWt <= 0 THENAFR = SeriesELSEAFR = WtdSum / CumWtENDIFIF j = 1 THENVShortMA = AFRELSIF j = 2 THENShortMA = AFRELSIF j = 3 THENMediumMA = AFRELSELongMA = AFRENDIFPeriod = Period * 2 //doubles the periodsNEXT//ALMAve25 = WtdSum / CumWt//ALMAve25 = 0.5*AFR//ALMA25 = 0.5*AFR//Bull Market increase in Prices//BullC1 = Close[0] > ShortMA//BullC2 = Close[0] > MediumMA//BullC3 = Close[0] > LongMA//BullC4 = Close[0] >= (Close[200] * 1.2)//Bear Market decrease in Prices//BearC5 = Close[0] < ShortMA//BearC6 = Close[0] < MediumMA//BearC7 = Close[0] < LongMA//BearC8 = Close[0] <= (Close[200] * 1.2)//If BullC1 = 0 and BullC2 = 0 and BullC3 = 0 and BearC5 = -0 and BearC6 = -0 and BearC7 = -0 then//NoBullorBear = 0//Endif//=================================================================//// ZLJE - Zero Lag John Ehlers//=================================================================//// --- parametersMAType = 0Series = CustomClose// Period = 15// ---IF MAType = 65 THENPeriod = MAX(Period, 2)alpha = 2 / (1 + Period)per = ROUND((Period - 1) / 2)IF BarIndex < per THENAFR = SeriesELSEAFR = AFR[1] + alpha * (2 * Series - Series[per] - AFR[1])ENDIFENDIF//=================================================================//// ELASTIC WEIGHTED MOVING AVERAGE BOLLINGER // //Dev = 1.618//=================================================================//BollPERIODS = 20Deviations = 2.57PRICE = LOG(customclose)alpha = 2/(BollPERIODS+1)// EWMA (EMA)if barindex < BollPERIODS thenEWMA = EXPONENTIALAVERAGE[3](PRICE)elseEWMA = alpha * PRICE + (1-alpha)*EWMAendif// ELASTIC WEIGHTED STANDARD DEVIATION (ESD)error = PRICE - EWMAdev = SQUARE(error)if barindex < BollPERIODS+1 thenvar = develsevar = alpha * dev + (1-alpha) * varendifESD = SQRT(var)// BANDSSAverage[20](close)// BANDSUpperBoll = EXP(EWMA + (Deviations*ESD))LowerBoll = EXP(EWMA - (Deviations*ESD))MidBoll = EXP(EWMA)//RETURN MID as "EWMA(EMA)", UB as "+ESD", BB as "-ESD"//=================================================================////"Williams' VixFix IV R+P//=================================================================////Implied Volatility Rank and Percentile Indicator — MARKET TOPS//By Vonasi //Date 20191018//NEED 1000 UNITS FOR AQUA BLUE PEAK OUTS//SettingsHiLoPeriod = 365 //Highest/Lowest PeriodIVperiod = 22 //IVperiod//Inverse Vix Fix - Low IV Proxy//MODIFIED LOW VOL//Inverse Vix Fix - Low IV Proxy//MODIFIED LOW VOL//Correct but worse performing wvfinverse for spotting tops.//wvf = ((high-lowest[IVperiod](close))/(lowest[IVperiod](close)))*100//High Volatility Market Bottoms - Non Inverse Vix Fixwvf = ((highest[IVperiod](close)-low)/(lowest[IVperiod](close)))*100//Boundariesupper = highest[HiLoPeriod](wvf)lower = lowest[HiLoPeriod](wvf)//wvflev = 100-((wvf-lower)/(upper-lower)*100) //Doesn't Show Low Vol Topswvflev = ((wvf-lower)/(upper-lower)*100)//=================================================================////Implied Volatility Rank and Percentile Indicator — MARKET TOPS//=================================================================////By Vonasi //Date 20191018//NEED 1000 UNITS FOR AQUA BLUE PEAK OUTS//SettingsHiLoPeriod = 365 //Highest/Lowest PeriodIVperiod = 22 //IVperiod//Inverse Vix Fix - Low IV Proxy//MODIFIED LOW VOL//Correct but worse performing wvfinverse. Not sure if it is worse performing://wvf = ((high-lowest[IVperiod](close))/(lowest[IVperiod](close)))*100wvf = ((highest[IVperiod](close)-low)/(lowest[IVperiod](close)))*100//Boundariesupper = highest[HiLoPeriod](wvf)lower = lowest[HiLoPeriod](wvf)//wvflev = 100-((wvf-lower)/(upper-lower)*100) //Doesn't Show Low Vol Topswvflev = ((wvf-lower)/(upper-lower)*100)//PercentilernkCount = 0count = 0FOR i = 1 to HiLoPeriod-1count = count + 1IF (wvflev[i]) > (wvflev) THENrnkCount = rnkCount + 1endifNEXTPercentileRank = 100-(rnkCount/count)*100//Historic Volatility//HVLength = 22//annualVol = 365//periods = 7// 1 = intraday chart 7 = daily chart//Returns = log(close / close[1])//StdDev = std[HVLength](Returns)//HVol = StdDev * sqrt(annualVol) * 100 //sqrt(annualVol / periods//lowVol = lowest[annualvol](HVol)//HVrankUp = HVol - lowVol//maxVol = highest[annualvol](HVol)//HVrankLow = maxVol - lowVol//HVR = (HVrankUp / HVrankLow)*100//=================================================================////PRC_Damiani Volatmeter | Indicator//=================================================================////24.04.2017//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge//translated from MT4 indicator code//---Damiani Volatmeter SettingsViscosity=8 //8£/$ //9 //Default=7 //try 5, 2Sedimentation=90 //90£/$ 60 //Default 50 //try 60Thresholdlevel=1.2 //1.2£/$ 0.9 1.2 Default 1.1 -- higher values = more bars defined as ranging and aqualagsupressor=1 //boolean value (default=true)MAtype=2 //MA type variable (2=Weighted average) //Default 2if barindex>Sedimentation thenlagsK=0.5sa = averagetruerange[Viscosity]s1 = indc[1]s3 = indc[3]if lagsupressor thenvol=sa/averagetruerange[Sedimentation]+lagsK*(s1-s3)elsevol=sa/averagetruerange[Sedimentation]endifMA1=average[Viscosity,MAtype](typicalprice)D1=0Sum1=0for x1=0 to Viscosity-1 doD1=square(typicalprice[x1]-MA1)Sum1=Sum1+D1anti=sqrt(Sum1/(x1+1))nextMA2=average[Sedimentation,MAtype](typicalprice)D2=0Sum2=0for x2=0 to Sedimentation-1 doD2=square(typicalprice[x2]-MA2)Sum2=Sum2+D2Sedi=sqrt(Sum2/(x2+1))nextantithres=anti/Sedit = Thresholdlevelt=t-antithresif(vol>t) thenvolt=volelsevolt=volendifindc=volendif//return volt coloured(0,200,0) style(line,2) as "volatility meter", t style(line,2) as "threshold level"//=================================================================////Bollinger - Orig//=================================================================////BollUp =Average[PeriodBoll](close)+dev*std[PeriodBoll](close)//BollDown = Average[PeriodBoll](close)-dev*std[PeriodBoll](close)//=================================================================////Conditions//=================================================================//// Trending and Volatile//=================================================================//// 1 Trending and Volatile = RED (255,0,0)//ALMA BULL/BEAR//BullC0 = Close[0] > VShortMA//BullC1 = Close[0] > ShortMA////BullC2 = Close[0] > MediumMA////BullC3 = Close[0] > LongMA//VixFix1 = (wvflev > 50)PercRankTV = PercentileRank > 50If Volt > t and PercRankTV thenIndicator = close //Indicator =1r=255g=0b=0Endif//=================================================================//// Trending and Calm//=================================================================//// 2 Trending and Calm = LIGHT GREEN (255,153,255)//ALMA BULL/BEAR//BullC0 = Close[0] > VShortMA//BullC1 = Close[0] > ShortMA//BullC2 = Close[0] > MediumMA//BullC3 = Close[0] > LongMA//VixFix3 = (wvflev < 50)PercRankTC = PercentileRank < 50If Volt > t and PercRankTC thenIndicator = close //Indicator =1r=153g=255b=153Endif//=================================================================//// Ranging and Volatile//=================================================================//// 3 Ranging and Volatile = BLUE (0,128,255)PercRankRV = PercentileRank > 50If Volt < t and PercRankRV thenIndicator = close //Indicator =1r=0g=128b=255Endif//=================================================================//// Ranging and Calm//=================================================================//// 4 Ranging and Calm AQUA BLUE (0,0,255)PercRankRC = PercentileRank < 50If Volt < t and PercRankRC thenIndicator = close //Indicator =1r=102g=255b=255Endif//=================================================================//max1=UpperBollmin1=LowerBollDRAWCANDLE(max1, min1, max1, min1)coloured(R,G,B,x)RETURN VShortMA coloured (204,0,204,255) style (dottedline,2) as "ALMA 25", ShortMA coloured (255,153,51,255) style (dottedline,2) as "ALMA 50", MediumMA coloured (204,0,51,255) style (dottedline,2) as "ALMA 100", LongMA coloured (153,102,255,255) style (dottedline,2) as "ALMA 200", UpperBoll style(dottedline) as "BollUp", LowerBoll style(dottedline) as "BollDown", MidBoll style(dottedline) as "MidBoll", indicator style(dottedline) as "8x Multicolour Market States",0//RETURN HVR coloured(102,179,255) style (line,3) as "Historic Volatility Rank" -
AuthorPosts
Find exclusive trading pro-tools on