PrevDayClose CrossOver Watchlist Column

A

AJ_29

New member
Hey,

I'm trying to create a custom watchlist column to indicate if the price cross Prev Day Close. Find below my code for review. Somehow it is not working. Any help is appreciated!!!


Code:
def PrevDayClose=close(period = AggregationPeriod.DAY)[-1];

plot signal = if PrevDayClose>close(period =AggregationPeriod.MIN) then 2 else if PrevDayClose<close(period =AggregationPeriod.MIN) then 1 else 0;

signal.AssignValueColor(if signal == 2 then Color.White else if signal == 1 then Color.White else Color.White);

AssignBackgroundCOlor(if signal == 2 then Color.Dark_Green else if signal == 1 then Color.Dark_Red else Color.Dark_Orange);

Thanks,
AJ
 
L

Len20

Member
If you're just looking for the column to show if the price is above or below yesterday's close, I came up with this:
Make sure to set the aggregation setting to Daily
Code:
def tClose = close;
def yClose = close[1];

plot position = if tClose > yClose then 1 else if tClose < yClose then -1 else 0;

addLabel(1, if position == 1 then "Above" else if position == -1 then "Below" else " ");
AssignBackgroundColor(if position == 1 then color.DARK_GREEN else if position == -1 then color.DARK_RED else color.DARK_ORANGE);
position.AssignValueColor(Color.WHITE);
 

Similar threads

Top