Change background color exactly one plot expected


Category:
0
0

Pete

TOS gets really confusing, every time I try to assign a background color to a column, it returns: EXACTLY ONE PLOT EXPECTED.  I have attached to code I am using, i have tried everything….except what works of course.  Can you help with plot needed?

Attachments:
Marked as spam
Posted by (Questions: 10, Answers: 11)
Asked on November 22, 2019 11:49 am
748 views
0
Private answer

I moved your post out of the "Frequently Asked Questions" topic and into the "Watch Lists" topic. I also updated the title of your question to include the error message. Which will help the rest of our viewers who search the forum for a solution to this error message.

So only one plot is permitted in a custom watchlist column. Your code contains four plot statements. We need modify your code to get it down to a single plot. The statement used to change the background color makes use of the ADX plot. So we'll keep that and remove the rest. (by 'remove' what I actually mean is we convert these from plot to def and remove the style statements for each of the plots).

Here is the modified code for use in a watchlist column:

input length = 14;
input averageType = AverageType.WILDERS;
def hiDiff = high - high[1];
def loDiff = low[1] - low;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
def diPlus = 100 * MovingAverage(averageType, plusDM, length) / ATR;
def diMinus = 100 * MovingAverage(averageType, minusDM, length) / ATR;
def dx = if (diPlus + diMinus > 0) then 100 * AbsValue(diPlus - diMinus) / (diPlus + diMinus) else 0;
plot adx = MovingAverage(averageType, dx, length);
AssignBackgroundColor (if adx < 20 then Color.YELLOW else if adx > 20 and diPlus > diMinus then Color.GREEN else Color.RED);

We have actually published a much more comprehensive solution to the ADX/DMI watchlist column. You can get the details here:

https://www.hahn-tech.com/thinkorswim-adx-dmi-watchlist/

 

Marked as spam
Posted by (Questions: 37, Answers: 4091)
Answered on November 22, 2019 12:48 pm