Hello. I keep getting errors on this code. Please suggest an answer!
The goal for this watchlist column is to change background color when Linear Reg Reversal is equal to 1 AND when CCI (5) Crosses Zero. Agg period is 2 days.
The goal for this watchlist column is to change background color when Linear Reg Reversal is equal to 1 AND when CCI (5) Crosses Zero. Agg period is 2 days.
Code:
def agg = AggregationPeriod.TWO_DAYS;
def lrr = reference LinearRegrReversal()."LRR"(period = agg);
def cci = reference CCI("length" = 5)."CCI"(period = agg);
def zeroLine = reference CCI("length" = 5)."ZeroLine"(period = agg);
plot scan = if lrr == 1 and cci crosses above zeroLine then 1 else if lrr == 1 and cci crosses below zeroLine then -1 else 0;
scan.AssignBackgroundColor(if scan == 1 then Color.WHITE else if scan == -1 then Color.RED else Color.GRAY);