Hello,
Currently I add the background color to change when it meets my parameters for enter and exit trades.
However, it lights up the entire charts and the other indictors like a disco party, is there a way to isolate the assigned color background script to just the specific indictor?
thanks,
jrj4774
You could try using clouds. The thread below creates a cloud (actually two clouds) depending on which definition is triggered.
https://usethinkscript.com/threads/sar-macd-for-thinkorswim.15409/#post-147514
I've excepted the section of the code that deals with the cloud.
You could possibly adapt the conditions to meet your needs. Just an FYI, I use this type of clouding but I usually only use one of the clouds and # the other to not show it. Don't know what your conditions are for assigning the background, but it may be an option to consider. It only will show on the panel it resides in.
def na = Double.NaN;
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
def last = isNaN(close);
def macdSel = GraphType==GraphType.MACD;
def HistSel = GraphType==GraphType.HIST;
def sar = ParabolicSAR();
def cross = crosses(close,sar);
def sa = if cross then close else sa[1];
def dir = if sar < close then 1 else -1;
def m = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def s = MovingAverage(averageType, m, MACDLength);
def h = m - s;
def bc = if dir == 1 and close > sa and m>0 then 1 else
if dir == -1 and close < sa and m<0 then -1 else 0;
def hc = if dir == 1 and close > sa and h>0 then 1 else
if dir == -1 and close < sa and h<0 then -1 else 0;
plot SigLine = s;
plot Hist = if HistSel then m else na;
plot macd = if macdSel then m else h;
macd.SetLineWeight(3);
macd.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
macd.AssignValueColor(if macdSel then
if bc>0 then CreateColor(1, 185, 7) else
if bc<0 then CreateColor(224, 4, 4) else Color.YELLOW else
if hc>0 then CreateColor(1, 185, 7) else
if hc<0 then CreateColor(224, 4, 4) else Color.YELLOW);
Hist.SetLineWeight(2);
Hist.SetDefaultColor(Color.WHITE);
SigLine.SetStyle(Curve.POINTS);
SigLine.AssignValueColor(if dir==1 then Color.CYAN else Color.MAGENTA);
plot limitUp = if last then na else TickSize() * sideways;
plot limitDn = if last then na else TickSize() * -sideways;
plot Mid = if last then na else 0; # 'Zero line'
limitUp.SetDefaultColor(Color.GRAY);
limitDn.SetDefaultColor(Color.GRAY);
mid.SetDefaultColor(Color.GRAY);
limitUp.SetPaintingStrategy(PaintingStrategy.DASHES);
limitDn.SetPaintingStrategy(PaintingStrategy.DASHES);
# Background
def buy_ = h>0 and dir==1;
def sell_= h<0 and dir==-1;
AddCloud(if buy_ then pos else na, neg, Color.DARK_GREEN);
AddCloud(if sell_ then pos else na, neg, Color.DARK_REd);