I created this label but I get errors about the colors. It says they aren’t valid.
The label is to display call/put ratio. Dark Green if below the given threshold and light green if moving down away from the threshold for the past x days. Dark red if above the threshold and light red if moving up away from the threshold for the past x days.
Variables are the TOS call put chart such as $PCSP.
PNC ratio threshold.
Days to use for determining direction.
Any help would be appreciated as to why this is throw the error message.
The label is to display call/put ratio. Dark Green if below the given threshold and light green if moving down away from the threshold for the past x days. Dark red if above the threshold and light red if moving up away from the threshold for the past x days.
Variables are the TOS call put chart such as $PCSP.
PNC ratio threshold.
Days to use for determining direction.
Any help would be appreciated as to why this is throw the error message.
Code:
# Customizable Label Text with Trend-Based Color Change
declare lower;
input symbol = "SPX";
input ratioThreshold = 1.0;
input trendLength = 5;
input labelText = "Put/Call Ratio";
input lightGreen = Color.LIGHT_GREEN;
input darkGreen = Color.DARK_GREEN;
input lightRed = Color.LIGHT_RED;
input darkRed = Color.DARK_RED;
def ratio = close(symbol = symbol, "PCRatio");
def increasing = if ratio > GetValue(ratio, 1) then 1 else 0;
def decreasing = if ratio < GetValue(ratio, 1) then 1 else 0;
def lightGreenCondition = ratio < ratioThreshold and Sum(increasing, trendLength) == trendLength;
def darkGreenCondition = ratio < ratioThreshold and Sum(decreasing, trendLength) == trendLength;
def lightRedCondition = ratio >= ratioThreshold and Sum(decreasing, trendLength) == trendLength;
def darkRedCondition = ratio >= ratioThreshold and Sum(increasing, trendLength) == trendLength;
plot RatioLabel = ratio;
RatioLabel.AssignValueColor(
if lightGreenCondition then lightGreen
else if darkGreenCondition then darkGreen
else if lightRedCondition then lightRed
else if darkRedCondition then darkRed
else Color.WHITE
);
AddLabel(yes, labelText, if lightGreenCondition or lightRedCondition then Color.WHITE else Color.GRAY);
Last edited by a moderator: