Forums › ProRealTime English forum › ProBuilder support › Show 5 minute candlestick in 1 minute chart › Reply To: Show 5 minute candlestick in 1 minute chart
I 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 WickENDIFReturn
Hi 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…