• LIMITED TIME ONLY: Take $40 off VIP with code: BTD40.

How to make a SPX Badge in TOS?

Toddt

New member
I have been using TOS for about three years and wondering if anyone knows how to make a simple badge with SPX price up/down in dollars? I know it may sound weird since I can see it in a watchlist, but thought it would be a nice addition to my chart. I have never coded before so any help is appreciated
Thanks
 

Joshua

Active member
VIP
I guess a label is what you mean by badge? This can go on any chart.

Ruby:
def SpxOpen = Open("SPX",aggregationPeriod.DAY);
def SpxClose = Close("SPX",aggregationPeriod.DAY);
def SpxColor = SpxClose > SpxOpen;
AddLabel(
           Yes,
           SpxClose - SpxOpen,
        if SpxOpen == SpxClose then color.Yellow
   else if SpxColor then color.Light_green
      else color.Light_orange
);

Edit: I still had the conditions backwards from testing to see how the colors appeared when I first posted. It should be working now.
 
Last edited:

Similar threads

Top