Assign Background questions

jrj4774

Active member
VIP
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
 
Solution
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

No, AssignBackgroundColor() only changes the entire Chart... We cannot selectively change the background of only one lower indicator with this function...
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

No, AssignBackgroundColor() only changes the entire Chart... We cannot selectively change the background of only one lower indicator with this function...
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

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);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
1050 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top