short answer , everything
you are trying to define a boolean variable, greenbar, but then trying to define 2 more variables, with the same value, that aren't needed?
1. this is wrong
def GreenBar = (open > close);
should be
def GreenBar = (close > open);
this will be true or false, 1 or 0.
2. def candle1 = If (yes, GreenBar(), Double.NaN);
greenbar() doesn't exist, there is no function with that name.
it is pointless to set the condition of a if-then to yes,
might as well write
def candle1 = greenbar;
maybe you meant this
def candle1 = if greenbar then 1 else double.nan;
3. plot candle1 = if (yes)is true then 1 else 0;
duplicate variable name. already used candle1 in previous code line.
it is pointless to set the condition to yes,
why are you plotting a boolean value? just to show something in the column
correct line
plot candle2 = if candle1 then 1 else 0;
4. AssignBackgroundColor(if candle1 == 1 then Color.GREEN else Color.GRAY);
this works. although the == 1 isn't really nessesary
------------------------
candle1 and candle2 are basically the same as greenbar, so might as well remove them and just use greenbar.
i think it is better to stick with 1 and 0 during signal formulas, and wait to use double.nan in plot formulas.
sometimes those double.nan values can cascade through the formulas and cause unwanted results.
this is how i would write it
Code:
# column study
plot GreenBar = (close > open);
AssignBackgroundColor(if greenbar then Color.GREEN else Color.GRAY);
----------------------------------
if i wanted to look for green and red bars,....
Code:
def GreenBar = (close > open);
def redBar = (close < open);
AssignBackgroundColor(if greenbar then Color.GREEN else if redbar then color.red else Color.GRAY);