You were very close. Great job. When you saw the error, “exactly one plot expected”, did you go through your code and count how many plots where there? I counted four. Only one is allowed for a watchlist but which one do you leave? To keep it simple, none of them.
I took the first two that are named FullK and FullD and changed them from plot to def. This is because we need those values so we can’t simply delete those lines or comment them out. Then I commented out the OverBought and OverSold because you are not using them. This creates a bunch of new errors, because for each plot there are style statements. Those style statements need to be taken out of the code. I used comment marks to turn them off so you can see what changes were required to get your code working.
There was also a problem with the method you used to set the background color. You were trying to set the price color, which is only applicable in a chart. So I commented out your AssignPriceColor statements and replaced it with AssignBackgroundColor. At the very end, we still need to have exactly one plot. So in the last line I create a plot, called value, and assign it’s value to the FullK.
Here is you code with these changes applied. Screenshot included to show what it looks like. Don’t forget to up-vote any answers the best solve your question!
input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 10;
input priceH = high;
input priceL = low;
input priceC = close;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;
def lowest_k = Lowest(priceL, KPeriod);
def c1 = priceC – lowest_k;
def c2 = Highest(priceH, KPeriod) – lowest_k;
def FastK = if c2 != 0 then c1 / c2 * 100 else 0;
def FullK = MovingAverage(averageType, FastK, slowing_period);
def FullD = MovingAverage(averageType, FullK, DPeriod);
#plot OverBought = over_bought;
#plot OverSold = over_sold;
#FullK.SetDefaultColor(GetColor(5));
#FullD.SetDefaultColor(GetColor(0));
#OverBought.SetDefaultColor(GetColor(1));
#OverSold.SetDefaultColor(GetColor(1));
#AssignPriceColor (if Fullk > FullD then color.green else color.red);
AssignBackgroundColor(if Fullk > FullD then color.green else color.red);
plot value = FullK;