Hi all,
In Trading View, I had coloured my bars depending on the close of the bar. In Pinescipt V5, the code looked like this:
indicator(“Bar Color”, overlay=true)
//Bull bar 1/4
data1 = close > ((high – low) * 0.75) + low
barcolor(close > ((high – low) * 0.75) + low ? #27af40 : na)
//Bull bar 1/3
data2 = close > ((high – low) * 0.666) + low and close < ((high – low) * 0.75) + low
barcolor(close > ((high – low) * 0.666) + low and close < ((high – low) * 0.75) + low? #24532d : na)
//Neutral Bull bar
data3 = close < (((high – low) * 0.666) + low) and close > (high – ((high – low) * 0.666)) and close > open
barcolor(close < (((high – low) * 0.666) + low) and close > (high – ((high – low) * 0.666)) and close > open? #a5dfb2 : na)
If anyone here can help me convert this code to ProBuilder I would be very grateful.
Philip
Here is the translated code that color the candlestick accordingly to the conditions. If conditions are not met, then the bar color is the default one of the platform.
//Bull bar 1/4
data1 = close > ((high - low) * 0.75) + low
//Bull bar 1/3
data2 = close > ((high - low) * 0.666) + low and close < ((high - low) * 0.75) + low
//Neutral Bull bar
data3 = close < (((high - low) * 0.666) + low) and close > (high - ((high - low) * 0.666)) and close > open
if data1 then
r=39
g=175
b=64
elsif data2 then
r=36
g=83
b=45
elsif data3 then
r=165
g=223
b=178
endif
if data1+data2+data3>0 then
drawcandle(open,high,low,close) coloured(r,g,b)
endif
return
Thank you for the quick response! It works perfectly.