Pretty sure you only need to change the last line of code. Replace the word “assignPriceColor” with “AssignBackgroundColor”.
For a watchlist, assignPriceColor impacts the color of the text/values. While AssignBackgroundColor impacts the color of the cells.
Update: Here is the full code with the changes applied
input nBB = 2.0;
input Length = 20.0;
input nK = 1.5;
input price = close;
input earlyEntrySmoothing = 7;
input earlyExitSmoothing = 9;
def momentum = TTM_Squeeze(price = price, length = length, nk = nk, nbb = nbb).”Histogram”;
def OA = linearRegressionSlope(price = momentum-momentum[1], length = earlyExitSmoothing);
def BolKelDelta = reference BollingerBands(“num_dev_up” = nBB, “length” = Length ).”upperband” – KeltnerChannels(“factor” = nK, “length” = Length).”Upper_Band”;
def BKDA = ExpAverage(BolKelDelta, earlyEntrySmoothing);
def EarlyEntry = BolKelDelta > BKDA and BolKelDelta <= 0;
plot data = if EarlyEntry then 1 else if momentum >= 0 and momentum > momentum[1] and (OA > 0 or OA <=0 and bolKelDelta <0) then 2 else if Momentum >=0 then 3 else if momentum < momentum[1] and (OA < 0 or OA >=0 and bolKelDelta < 0) then 4 else 5;
data.SetDefaultColor(Color.BLACK);
AssignBackgroundColor(if EarlyEntry then color.green else if momentum >= 0 and momentum > momentum[1] and (OA > 0 or OA <=0 and bolKelDelta <0) then CreateColor(0, 255, 255) else if Momentum >=0 then CreateColor(0, 0, 255) else if momentum < momentum[1] and (OA < 0 or OA >=0 and bolKelDelta < 0) then CreateColor(255, 0, 0) else CreateColor(255, 255, 0));
It also said one plot should be defined
I also want to be clear in what I’m looking for. this is a color column for a watch list first off. I’m hoping you can make the column color the current bar on the chart.
Well if the error says “at least one plot should defined” then simply add one. I added “plot data = 0” and it let me save the code. The colors should match exactly because we are using the same exact statement to color the cells of the watchlist that are used to color the bars on the chart.