Colour coding the bars
Forums › ProRealTime English forum › ProBuilder support › Colour coding the bars
- This topic has 12 replies, 3 voices, and was last updated 2 years ago by robertogozzi.
-
-
09/05/2018 at 11:17 PM #79838
Hello,
Complete noob when it comes to coding (am trying my best to learn!), so any help is greatly appreciated. Is it possible to colour code the bars that close outside the bollinger bands?
Ex. (Note, my candlestick colour scheme is black/white)
Candle(s) close outside the upper bollinger band, it gets painted blue.
Candle(s) close outside the lower bollinger band, it gets painted red.
Thank you.
09/06/2018 at 12:04 AM #79839There you go. I tested it on EurUsd daily and it worked:
Coloring CANDLESTICKS outside BB12345678910111213141516171819202122defparam calculateonlastbars=500// construction of Bollinger BandsBBVal = 20 //20 periodsBBdev = 2.0 //2.0 DeviationBBavg = Average[BBval,0](close) //BB mean (middle line) 0=smaBollUP = BBavg + ((std[BBval](close)) * BBdev) //Bollinger Upper BandBollDN = BBavg - ((std[BBval](close)) * BBdev) //Bollinger Lower Band// initialize colours to nullr=0g=0b=0// set colours when dueif close > BollUP thenb=255elsif close < BollDN THENr=255endif// display candlestick, if above/below BBIF (r + g + b) <> 0 THENDRAWCANDLE(open,high,low,close) COLOURED(r,g,b,255) //BORDERCOLOR(0,255,0,255)ENDIFRETURN09/06/2018 at 12:09 AM #79840Roberto, many many thanks for this!
Question, if I was to replace bollingers and use the Keltner Channels found here (https://www.prorealcode.com/topic/keltner-channel-2/), would it work the samw?
09/06/2018 at 12:17 AM #79841It is, this is the modified code:
1234567891011121314151617181920212223defparam calculateonlastbars=500// construction of Bollinger Bandsa = average[20,0](customclose)b = AverageTrueRange[20](close)co= 1.5//mm = a //middle linehi = a + co*b //Upper Limitlo = a - co*b //Lower Limit// initialize colours to nullr=0g=0b=0// set colours when dueif close > hi thenb=255elsif close < lo THENr=255endif// display candlestick, if above/below Channel's limitsIF (r + g + b) <> 0 THENDRAWCANDLE(open,high,low,close) COLOURED(r,g,b,255) //BORDERCOLOR(0,255,0,255)ENDIFRETURN09/06/2018 at 12:19 AM #79842I added line 5.
09/06/2018 at 2:57 AM #7984303/23/2022 at 9:14 PM #190370Good evening Roberto:
is it possibile to get the same system but with the intraday stocastic indicator ???
specifically smoohed stochastic 5.3.3 80/20
overbought entry red colored bar >80
entry into oversold green colored bar <20
THANK YOU
03/24/2022 at 8:49 AM #190378I think that this indicator that color candlesticks based on the chosen oscillator might be of interest to you: 3D Candlesticks (CCI,RSI,Stochastic,Cycle,DI)
03/28/2022 at 7:15 PM #19067903/29/2022 at 9:21 AM #190703There you go:
1234567891011121314151617181920// StochasticKline = Stochastic[5,3](close)Dline = Average[3](Kline)OB = 80OS = 100 - OB// initialize colours to nullr=0g=0b=0// set colours when dueif Kline > OB thenr=255elsif Kline < OS THENg=255endif// display candlestick, if above/below limitsIF (r + g + b) <> 0 THENDRAWCANDLE(open,high,low,close) COLOURED(r,g,b,255) //BORDERCOLOR(0,255,0,255)ENDIFRETURN03/31/2022 at 4:17 PM #19087103/31/2022 at 5:42 PM #190876Grazie Roberto ..fine settimana lo provo
per l’intanto grazie per la gentilezza
TANKS ROBERTO !
Gia testato ok perfetto … solo un’ultima richiesta se possibile :
è possibile invertire i colori ? il verde in ipercomprato / rosso in ipervenduto ? Grazie
……………Already tested ok perfect … just one last request if possible: is it possible to invert the colors? green overbought / red oversold? Thanks
03/31/2022 at 6:03 PM #190879Swap lines 12 and 14.
-
AuthorPosts
Find exclusive trading pro-tools on