Show 5 minute candlestick in 1 minute chart
Forums › ProRealTime English forum › ProBuilder support › Show 5 minute candlestick in 1 minute chart
- This topic has 28 replies, 9 voices, and was last updated 1 year ago by LucasBest.
-
-
07/13/2022 at 10:47 AM #19721307/13/2022 at 3:26 PM #197232
Thanks for comments guy’s.
Razz if it’s doing what you want, then that’s good. I thought that might be the case, but just couldn’t sit here and no say nothing.
And Rob your right, the code is 30sec specific and would need tweaking if used on another chart time frame as you mention. However it now looks like I did a bad job of explaining that bit because that wasn’t the point I was trying to make.
The problem stems deeper in proBuilder, and how coder’s interpret some of the instruction . To me it seems to be one of those situations where 99.99% of the time it doesn’t cause an issue and if it does, can be so subtle that it goes un-noticed. But it’s always there lurking in the background..
From my observations it appears that using ‘Barindex’ in ‘drawRectangle’ isn’t a 100% fit and especially under low market activity, the objects position can be affected.
There can be a weird relationship between tick’s, candle’s, charts and instructions, i’ll post about it when I get my head around it. Wen’t back through the instruction database and dug up ‘dateToBarindex’ which i’d missed the several thousand times I’ve been through it. This may offer the path to a solution.
1 user thanked author for this post.
07/14/2022 at 11:27 AM #197264I made the code to automatically detect the current (default) TIMEFRAME, which cannot be higher than 15 minutes (unless you change lines 16, 17 and 36 as stated below).
You can set your preferred TF changing lines 16 and 36. Furthermore you have to change line 17 to set the correct number of seconds in the preferred HIGHER timeframe.
On your chart you can use any of the allowed default TFs (be it 1, or 15 or 30 seconds, 1 or 3 or 5 minutes). Beware that with a HIGHER timeframe of 15 minutes you can’t use a 2-minute default TF as 15 is not a multiple of 2. The same for a WEEKLY TF, which is considered being made of 7 days (it doesn’t matter if they trading days or not), so you could only use a 1-day default TF, as 7 is a multiple of 1 only.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758// GetTimeFrame returns://// 1 = 1 second// 10 = 10 seconds (10 * 1 second)// 60 = 1 minute (60 * 1 second)// 300 = 5 minutes (5 * 1 minute)// 3600 = 1 hour (60 * 1 minute)// 14400 = 4 hours (4 * 1 hour)// 86400 = 1 day (24 * 1 hour)// 172800 = 2 days (2 * 1 day)// 604800 = 1 week (7 * 1 day)// 2592000 = 1 month (30 * 1 day)// 31536000 = 1 year (365 * 1 day)// -1 = non time based TF//Timeframe(15 minutes,updateonclose)ONCE TFseconds = 15 * 60 //number of seconds in a 15-minute barONCE t = 50 //Transparency (0-255, 0=invisible, 255=fully visible)ONCE ID = 0ID = ID + 1//C5 = closeO5 = openH5 = highL5 = low//r = 0g = 255b = 0If c5 < o5 thenr = 255g = 0b = 0endif//Timeframe(15 minutes,default)//ONCE ID2 = 0ID2 = ID2 + 1//timeframe(default)ONCE TFdefault = GetTimeFrameIF TFdefault = TFseconds THENTotalBars = 0Bar1 = 0Bar2 = 0ELSETotalBars = TFseconds / TFdefaultBar1 = TotalBars - 1Bar2 = floor(TotalBars / 2)ENDIF//IF ID <> ID[1] THENDrawrectangle(BarIndex - Bar1,O5,BarIndex,C5) Coloured(r,g,b,t)style(line,1) bordercolor(r,g,b,t) //Body /style Line 2 = DickeDrawRectangle(BarIndex - Bar2,max(O5,C5),BarIndex - Bar2,H5) Coloured(r,g,b,t)style(line,1) bordercolor(r,g,b,t) //Upper WickDrawRectangle(BarIndex - Bar2,min(O5,C5),BarIndex - Bar2,L5) Coloured(r,g,b,t)style(line,1) bordercolor(r,g,b,t) //Lower WickENDIFReturn02/25/2023 at 8:27 PM #210502Good evening Robert
I applied his code but the filling does notappear ( the internal bar is transparent ) and neither in the following code ( that of RAZ ) : do I have to add something ?? Thank you
1 user thanked author for this post.
02/26/2023 at 6:35 PM #210553Good evening Robert
I applied his code but the filling does notappear ( the internal bar is transparent ) and neither in the following code ( that of RAZ ) : do I have to add something ?? Thank you
Ok Roberto, I managed it by myself: i have another question, I would like to bring the bar back to 15 minutes ( instead of the 5min one) in the 1 minute graph …..what should I change in the code???
thank you
02/27/2023 at 11:12 AM #210588The code at https://www.prorealcode.com/topic/show-5-minute-candlestick-in-1-minute-chart/page/2/#post-197264. is written for the 15-minute candle in the 1-minute TF.
1 user thanked author for this post.
08/28/2023 at 2:19 PM #219950Is it possible to form custom candle for 4hr timeframe based on time. The PRT 4hr candle is different from MT5 candles as they open 1 hr apart. I understand we cannot change the 4hr candle open time. So is it possible to draw it at 7 am, 11 am, 3 pm, 7 pm and 11 pm, 3 am
thanks in advance
PJ
08/28/2023 at 3:34 PM #219953You can do that on a 1 -hour TF, by first drawing the current 1-hour candle white so that it’s made invisible, then, every 4 hour you need to draw a rectangle (covering 4 hours).
The outcome will not be beautiful, but it’s the only way to accomplish that!
Actually you could leave the original candlesticks, so that they are overlapped (starting at 3am):
12345678910111213141516171819IF OpenHour = 3 THENCount = 0ENDIFCount = Count + 1r = 0 //Redg = 0 //Greenb = 255 //Bluet = 55 //transparencyf = 0 //frame (border) colorIF Count MOD 4 = 0 THENIF close < open[3] THENr = 255b = 0ENDIFDrawRectangle(BarIndex-3,Open[3],BarIndex,close) coloured(r,g,b,t) bordercolor(r,g,b,f) style(line,1)DrawRectangle(BarIndex-2,highest[4](high),BarIndex-1,max(open[3],close)) coloured(r,g,b,t) bordercolor(r,g,b,f) style(line,1)DrawRectangle(BarIndex-2,min(open[3],close),BarIndex-1,lowest[4](low)) coloured(r,g,b,t) bordercolor(r,g,b,f) style(line,1)ENDIFRETURN09/12/2023 at 1:09 PM #22086909/13/2023 at 3:57 PM #220965There you go:
12345678910111213141516171819202122232425IF OpenHour = 3 THENCount = 0ENDIFCount = Count + 1r = 0 //Redg = 0 //Greenb = 255 //Bluet = 55 //transparencyf = 0 //frame (border) colorIF Count MOD 4 = 0 THENIF close < open[3] THENr = 255b = 0ENDIFIF OpenHour = 10 THENr = 119g = 136b = 153t = 255ENDIFDrawRectangle(BarIndex-3,Open[3],BarIndex,close) coloured(r,g,b,t) bordercolor(r,g,b,f) style(line,1)DrawRectangle(BarIndex-2,highest[4](high),BarIndex-1,max(open[3],close)) coloured(r,g,b,t) bordercolor(r,g,b,f) style(line,1)DrawRectangle(BarIndex-2,min(open[3],close),BarIndex-1,lowest[4](low)) coloured(r,g,b,t) bordercolor(r,g,b,f) style(line,1)ENDIFRETURN09/13/2023 at 8:07 PM #220986Hello,
I see that the indicator draws a new candle every 15 minutes. And that’s great. But I have a question.
Would it be possible to add some code to this indicator, so that the new 15-minute candle that is forming at that moment is drawn in real time and not have to wait for the 15 minutes to end?
Thank you so much!
09/14/2023 at 2:37 PM #221027This indicator is made to draw one candle every 4 hours to simulate a 4-hour TF).
10/02/2023 at 10:22 AM #221934I made the code to automatically detect the current (default) TIMEFRAME, which cannot be higher than 15 minutes (unless you change lines 16, 17 and 36 as stated below).
You can set your preferred TF changing lines 16 and 36. Furthermore you have to change line 17 to set the correct number of seconds in the preferred HIGHER timeframe.
On your chart you can use any of the allowed default TFs (be it 1, or 15 or 30 seconds, 1 or 3 or 5 minutes). Beware that with a HIGHER timeframe of 15 minutes you can’t use a 2-minute default TF as 15 is not a multiple of 2. The same for a WEEKLY TF, which is considered being made of 7 days (it doesn’t matter if they trading days or not), so you could only use a 1-day default TF, as 7 is a multiple of 1 only.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758// GetTimeFrame returns://// 1 = 1 second// 10 = 10 seconds (10 * 1 second)// 60 = 1 minute (60 * 1 second)// 300 = 5 minutes (5 * 1 minute)// 3600 = 1 hour (60 * 1 minute)// 14400 = 4 hours (4 * 1 hour)// 86400 = 1 day (24 * 1 hour)// 172800 = 2 days (2 * 1 day)// 604800 = 1 week (7 * 1 day)// 2592000 = 1 month (30 * 1 day)// 31536000 = 1 year (365 * 1 day)// -1 = non time based TF//Timeframe(15 minutes,updateonclose)ONCE TFseconds = 15 * 60 //number of seconds in a 15-minute barONCE t = 50 //Transparency (0-255, 0=invisible, 255=fully visible)ONCE ID = 0ID = ID + 1//C5 = closeO5 = openH5 = highL5 = low//r = 0g = 255b = 0If c5 < o5 thenr = 255g = 0b = 0endif//Timeframe(15 minutes,default)//ONCE ID2 = 0ID2 = ID2 + 1//timeframe(default)ONCE TFdefault = GetTimeFrameIF TFdefault = TFseconds THENTotalBars = 0Bar1 = 0Bar2 = 0ELSETotalBars = TFseconds / TFdefaultBar1 = TotalBars – 1Bar2 = floor(TotalBars / 2)ENDIF//IF ID <> ID[1] THENDrawrectangle(BarIndex – Bar1,O5,BarIndex,C5) Coloured(r,g,b,t)style(line,1) bordercolor(r,g,b,t) //Body /style Line 2 = DickeDrawRectangle(BarIndex – Bar2,max(O5,C5),BarIndex – Bar2,H5) Coloured(r,g,b,t)style(line,1) bordercolor(r,g,b,t) //Upper WickDrawRectangle(BarIndex – Bar2,min(O5,C5),BarIndex – Bar2,L5) Coloured(r,g,b,t)style(line,1) bordercolor(r,g,b,t) //Lower WickENDIFReturnHi robertogozzi,
Very smart to use GetTimeFrame instruction in order to calculate the offset for the begining of the higer timeframe candle, but as you can see in the pictures, there is a problem for last and firt candles of the week if the higher time frame is bigger than 1 hour… If higher time frame is 2 hours or 4 hours for example, last candle of the week and first one will overlap as in reality those candles do not last more than 1 hour. First full candle of 2 hours or 4 hours begin at 01:00…10/02/2023 at 10:28 AM #221937And here below, the solution i found to this issue :
Draw Higher Time frame on current time frame1234567891011121314151617181920212223242526272829303132333435363738Timeframe(120 minutes,updateonclose)ONCE t = 50 //Transparency (0-255, 0=invisible, 255=fully visible)ONCE ID = 0ID = ID + 1//C5 = closeO5 = openH5 = highL5 = low//r = 0g = 255b = 0If c5 < o5 thenr = 255g = 0b = 0endif//Timeframe(120 minutes,default)//ONCE ID2 = 0ID2 = ID2 + 1//timeframe(default)//IF ID <> ID[1] THENBarBegin = BarEnd+1BarEnd = BarindexBarwidth = floor((BarEnd-BarBegin)/2)Drawrectangle(BarBegin,O5,BarEnd,C5)Coloured(r,g,b,t)style(line,2) bordercolor(r,g,b,t) //Body /style Line 2 = DickeDrawRectangle(BarIndex - BarWidth,max(O5,C5),BarIndex - BarWidth,H5)Coloured(r,g,b,t)style(line,3) bordercolor(r,g,b,t) //Upper WickDrawRectangle(BarIndex - BarWidth,min(O5,C5),BarIndex - BarWidth,L5) Coloured(r,g,b,t)style(line,3) bordercolor(r,g,b,t) //Lower WickENDIFReturnOn the picture below : 4 hours candles drawn on 5 minutes time frame. Last 4 hours candle of the week and first one are smaller, which is normal from how prorealtime works…
3 users thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on