Red to Green Previous Day Price Close

Cowabunga

New member
Hey all,

I'm trying to design an indicator to plot a line for the previous day closing price and the line to display the different color lines depending on the market conditions. I am interested in using this to play Red to Green or Green to Red trades. I searched and didn't find anything so I gave it a try and see if I could come up with something myself. Here's the code that I have so far:

input Close_Color = {default single};

plot Data = close;
plot priceLine = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then close else Double.NaN);


def RedDay = Data < priceLine;
def GreenDay = Data > priceLine;

plot DailyClose = close(period = ”DAY”)[1];
DailyClose.SetDefaultColor(Color.BLACK);
DailyClose.DefineColor("Above Close", Color.DARK_GREEN);
DailyClose.DefineColor("Below Close", Color.DARK_RED);
DailyClose.HideBubble();
DailyClose.HideTitle();


DailyClose.AssignValueColor(if Close_Color == Color_Color.fluid and RedDay then DailyClose.Color("Above Close")
else if Close_Color == Color_Color.fluid and GreenDay then DailyClose.Color("Below Close")
else Color.BLACK);

However, I keep getting and error message ("NO such constant: Color_color.fluid at 19.52). I tried a different iterations of this code and it displayed the previous day close but the colors were off. Any help would be great and much appreciate.
 

halcyonguy

Active member
VIP
the input was missing a choice called fluid

# add fluid as a choice
input Close_Color = {default single , fluid};


variable name was spelled wrong. didn't match the name used in input
# change variable name from Color_Color. to close_Color.

DailyClose.AssignValueColor(if Close_Color == close_Color.fluid and RedDay then DailyClose.Color("Above Close")
else if Close_Color == close_Color.fluid and GreenDay then DailyClose.Color("Below Close")
else Color.BLACK);

i didn't test to see if the desired colored lines are plotted

Ruby:
# prevdayclosew_01

#input Close_Color = {default  single };
#  add  fluid as a choice
input Close_Color = {default  single , fluid};


plot Data = close;
plot priceLine = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then close else Double.NaN);


def RedDay = Data < priceLine;
def GreenDay = Data > priceLine;

plot DailyClose = close(period = ”DAY”)[1];
DailyClose.SetDefaultColor(Color.BLACK);
DailyClose.DefineColor("Above Close", Color.DARK_GREEN);
DailyClose.DefineColor("Below Close", Color.DARK_RED);
DailyClose.HideBubble();
DailyClose.HideTitle();

#
#DailyClose.AssignValueColor(if Close_Color == Color_Color.fluid and RedDay then DailyClose.Color("Above Close")
#else if Close_Color == Color_Color.fluid and GreenDay then DailyClose.Color("Below Close")
#else Color.BLACK);

#  change var name from Color_Color.   to close_Color.
DailyClose.AssignValueColor(if Close_Color == close_Color.fluid and RedDay then DailyClose.Color("Above Close")
  else if Close_Color == close_Color.fluid and GreenDay then DailyClose.Color("Below Close")
  else Color.BLACK);

#
 
Last edited:

Cowabunga

New member
Hey halcyonguy,

Thanks for the reply and correcting the little errors that I have in my script. The code works but the colors display is slightly off. Price is over previous day close but the line displayed is majority red with green spots throughout.
 

Similar threads

Top