• LIMITED TIME OFFER: use coupon code PRIMEDAY (case sensitive) at checkout to save $50 off VIP membership (down to $149 / year). Valid through Tuesday 6/22. Biggest discount this year!

Display red or green label based on the current price

Stockleed

New member
I currently have a code that shows the current price and it displays on the chart. Is there a way to add a code to it so that every time the price changes the background changes that color?

For example

If the price drops the background would turn to RED
  • If the price goes up the background color would change to Green?
  • And if the price was neutral it would be gray.

Current Code
Code:
input limit = 0.09;
def price = close(priceType = PriceType.LAST);
AddLabel(yes, Concat("PRICE: ", price), Color.LIGHT_GREEN);

Any help would be greatly appreciated
 

rad14733

Well-known member
VIP
Ruby:
input limit = 0.09;
def price = close(priceType = PriceType.LAST);
AddLabel(yes, Concat("PRICE: ", price), if price > price[1] then Color.LIGHT_GREEN else if price < price[1] then Color.RED else Color.CURRENT);

Your limit variable is never used... :oops:
 
Hey would you be willing to share your code with us? I would like to try it out as sometimes I trade multiple tickers and that can keep me up to date on my other positions....... possibly.
 

Similar threads

Top