TB2Participant
New
Not sure if I am posting the following question in the correct area, but here goes.
I have a simple Probuilder Indicator that highlights and paints NR7 bar(s) on Intraday time frames, i.e. 5 minute 10,30, etc. However, my problem comes that by default every opening bar will be NR7 and this causes the bar to print in the NR7 colour chosen say “Pink” but as the bar[0] completes and the range is not going to be a NR7 I am left with a two toned colour bar(s) say pink and green in the event of a higher close to the open . How can I force the indicator to only consider completed bars i.e ignore High – Low [0] bar.
See code below
REM Narrow Range Bar Intraday Time Frame(x)
NR =High-Low
REM NR7
NRB = LOWEST[7](NR)
IF NRB=NR THEN
DRAWCANDLE(open, high, low, close) coloured (255,102,255)
ENDIF
RETURN
Any help would be appreciated.
Welcome to the forums. Please use the ‘Insert PRT Code’ button when putting code in future posts as it makes it so much easier for others to read. I have tidied up your post for you. 🙂
To refer to a closed bar, you should use offset of your variables:
REM Narrow Range Bar Intraday Time Frame(x)
NR =High-Low
REM NR7
NRB = LOWEST[7](NR)
IF NRB[1]=NR[1] THEN
DRAWCANDLE(open, high, low, close) coloured (255,102,255)
ENDIF
RETURN
Not tested, but it should only paint Closed bars that met the NR7 pattern.
Im not sure if i understand it right. But try this one. Im far away from good on this but maybe it wil fix yur problem? 🙂
REM Narrow Range Bar Intraday Time Frame(x)
NR =High-Low
REM NR7
NRB = LOWEST[7](NR)
For i= 8 downto 1 do
IF NRB=NR THEN
DRAWCANDLE(open, high, low, close) coloured (255,102,255)
ENDIF
next
RETURN
Good try @Lind3berg! But you forgot to refer to the right candlestick in your loop 🙂
REM Narrow Range Bar Intraday Time Frame(x)
NR =High-Low
REM NR7
NRB = LOWEST[7](NR)
For i= 8 downto 1 do
IF NRB[i]=NR[i] THEN
DRAWCANDLE(open, high, low, close) coloured (255,102,255)
ENDIF
next
RETURN
But this code should also not work because DRAWCANDLE can’t plot candle in the past, you could have used an arrow for example:
REM Narrow Range Bar Intraday Time Frame(x)
NR =High-Low
REM NR7
NRB = LOWEST[7](NR)
For i= 8 downto 1 do
IF NRB[i]=NR[i] THEN
DRAWARROW(barindex[i],low[i])coloured (255,102,255)
ENDIF
next
RETURN
BTW, none of these codes posted here have been tested by me, so I don’t know if it fulfilled the initial query of the post ❓
Ok! I Think i understand a little bit more now. Thanks for the lesson @Nicolas 🙂
This can do the trick, just paint the standard colours if not NR7:
DEFPARAM CalculateOnLastBars = 500
NR =High-Low
REM NR7
NRB = LOWEST[7](NR)
IF NRB=NR THEN
DRAWCANDLE(open, high, low, close) coloured (255,102,255)
ELSE
if open > close then
DRAWCANDLE(open, high, low, close) coloured (0,0,255) //BLUE
else
DRAWCANDLE(open, high, low, close) coloured (255,0,0) //RED
endif
ENDIF
RETURN
Moreover, why do the math (NR=high-low) when you can let PRT do it with RANGE?
Sorry, just invert colours!
TB2Participant
New
Thanks for your input Nicolas, unfortunately “IF NRB[1]=NR[1] THEN” seems to highlight both NR7 and non NR7 bars. I tried something similar by including NR =High[1]–Low[1] as a sort of look back once Bar [0] started to print before posting my question resulting in the same mixed result. However, using the “DrawArrowDown” command works without any issues. So for the moment I will keep with this option until I can try out robertogozzi suggestion.
Thanks again for reaching out.
Regards
TB2