DMacTrades
New member
Hi MourningWood. I used a script provided by @BenTen on page 1 of this thread to add a column to my scanner results that is red when at 52 wk low, green at 52 week high and yellow for in-between (BenTen's script uses gray instead of yellow). I have pasted the script below, but if you click back 1 page you will see the original post. Again, credit to @BenTenHey, how did you get the color codes on the right hand side like that?
Code:
# HINT: right-click on any watchlist column-->>Customize
# click and drag one of the custom choices to add it to your watchlist column choices
# click on ThinkScript tab and replace the code with this code
# BE SURE to give your new column a name and keep the name short enough it will appear on your watchlist at top of the column (ie new 52wk high)
# REMINDER - you can sort your watchlist by this column by clicking on the column header
#def allows you to teach ThinkScript new "words" that you can reference later in your code
def newHigh = high is equal to highest(HIGH (period = AggregationPeriod.DAY), 252);
def newLow = low is equal to lowest(LOW (period = AggregationPeriod.DAY), 252);
#AddLabel allows you to set conditions such as what words or values will appear when your condition is met. Yes at the beginning means do show the label ... >=1 or ==1 means when the condition is True then _ and <=0 or ==) would mean then the condition is False then ___
AddLabel(yes, if newHigh >= 1 then "new 52wk high TODAY" else if newLow >= 1 then "new 52wk low TODAY" else " ");
#on a watchlist column AssignBackgroundColor will change the column color when conditions are met. But AssignBackgroundColor when used in a chart Study or Strategy will change entire chart background
AssignBackgroundColor (if newHigh >= 1 then color.GREEN else if NewLow >= 1 then color.RED else color.YELLOW);
# end custom column code ------------------