AssignValueColor changes all colors of chart into a single color, and it won't assign value to start counting bars in the title area.

Mr_Wheeler

Active member
What's it suppose to look like.

ssA9LND.png



How it looks now.

psanVz5.png


Code:
declare lower;

#zero line
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(0));

input Klength = 20; 
input price = close;
input ATRmult = 1.5;

def vClose = close;
def nan = Double.NaN;
def bn = BarNumber();



def K = (Highest(high, Klength) + Lowest(low, Klength)) /
2 + ExpAverage(close, Klength);
plot Momo = Inertia(price - K / 2, Klength);
Momo.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Momo.SetLineWeight(3);
Momo.AssignValueColor(if Momo > Momo[1] and Momo > 0
then Color.CYAN
else if Momo > 0 and Momo < Momo[1]
then Color.BLUE
else if Momo < 0 and Momo < Momo[1]
then Color.WHITE
else Color.YELLOW);



#These code lines give & retract value

def barUp = vClose > vClose[1];
def barDown = vClose < vClose[1];
def barUpCount = CompoundValue(1, if barUp then barUpCount[1] + 1 else 0, 0);
def barDownCount = CompoundValue(1, if barDown then barDownCount[1] - 1 else 0, 0);


#asign value to colored bars
Momo.AssignValueColor(Color.CYAN);
Momo.AssignValueColor(Color.blue);


#creates label to tell you to buy or hold
AddLabel(yes, if barUpCount [+2] then "Buy!Buy!Buy!Buy!Buy!Buy!" else if barDownCount [+2] then "TAKE PROFIT NOW!_____TAKE PROFIT NOW!" else "Stand by", if barUpCount [+2] then Color.GREEN else if barDownCount[+2] then Color.WHITE else Color.ORANGE);
 
Still All blue.

Code:
declare lower;

#zero line
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(0));

input Klength = 20;
input price = close;
input ATRmult = 1.5;

def vClose = close;
def nan = Double.NaN;
def bn = BarNumber();



def K = (Highest(high, Klength) + Lowest(low, Klength)) /
2 + ExpAverage(close, Klength);
plot Momo = Inertia(price - K / 2, Klength);
Momo.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Momo.SetLineWeight(3);
Momo.AssignValueColor(if Momo > Momo[1] and Momo > 0
then Color.CYAN
else if Momo > 0 and Momo < Momo[1]
then Color.BLUE
else if Momo < 0 and Momo < Momo[1]
then Color.WHITE
else Color.YELLOW);

#These code lines give & retract value

Momo.AssignValueColor(Color.CYAN);
Momo.AssignValueColor(Color.blue);


def momoUp = vClose > vClose[1];
def momoDown = vClose < vClose[1];

def momoUpCount = CompoundValue(1, if momoUp then momoUpCount[1] + 1 else 0, 0);
def momoDownCount = CompoundValue(1, if momoDown then momoDownCount[1] - 1 else 0, 0);



#creates label to tell you to buy or hold
AddLabel(yes, if momoUpCount [+2] then "Buy!Buy!Buy!Buy!Buy!Buy!" else if momoDownCount [+2] then "TAKE PROFIT NOW!_____TAKE PROFIT NOW!" else "Stand by", if momoUpCount [+2] then Color.GREEN else if momoDownCount[+2] then Color.WHITE else Color.ORANGE);
 

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

Still All blue.

Code:
declare lower;

#zero line
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(GetColor(0));

input Klength = 20;
input price = close;
input ATRmult = 1.5;

def vClose = close;
def nan = Double.NaN;
def bn = BarNumber();



def K = (Highest(high, Klength) + Lowest(low, Klength)) /
2 + ExpAverage(close, Klength);
plot Momo = Inertia(price - K / 2, Klength);
Momo.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Momo.SetLineWeight(3);
Momo.AssignValueColor(if Momo > Momo[1] and Momo > 0
then Color.CYAN
else if Momo > 0 and Momo < Momo[1]
then Color.BLUE
else if Momo < 0 and Momo < Momo[1]
then Color.WHITE
else Color.YELLOW);

#These code lines give & retract value

Momo.AssignValueColor(Color.CYAN);
Momo.AssignValueColor(Color.blue);


def momoUp = vClose > vClose[1];
def momoDown = vClose < vClose[1];

def momoUpCount = CompoundValue(1, if momoUp then momoUpCount[1] + 1 else 0, 0);
def momoDownCount = CompoundValue(1, if momoDown then momoDownCount[1] - 1 else 0, 0);



#creates label to tell you to buy or hold
AddLabel(yes, if momoUpCount [+2] then "Buy!Buy!Buy!Buy!Buy!Buy!" else if momoDownCount [+2] then "TAKE PROFIT NOW!_____TAKE PROFIT NOW!" else "Stand by", if momoUpCount [+2] then Color.GREEN else if momoDownCount[+2] then Color.WHITE else Color.ORANGE);
Delete the following two lines of code in above post. You have 3 momo assignvaluecolor codes. You can only have one.

Ruby:
Momo.AssignValueColor(Color.CYAN);
Momo.AssignValueColor(Color.blue);
 
Is there a what you can add a 2nd functionality to a plot?

I'm not sure if there's code such as "IF" that's required.

This is the code that I have.

Code:
plot MomoDOWN = Inertia(price - B / 2, Blength);

I need add the following.

Code:
 = if mode == mode.histogram and barUpCount > 0 then barUpCount else nan;
 
I don't think so, at least not directly... but you could add a painting strategy constant as an input, check the input throughout the code's logic and make any adjustments at that level, and then set painting strategy to the input's value when you plot. The set painting strategy function also accepts logical expressions, they just can't be dynamic.
 
Last edited:
Is there a what you can add a 2nd functionality to a plot?

I'm not sure if there's code such as "IF" that's required.

This is the code that I have.

Code:
plot MomoDOWN = Inertia(price - B / 2, Blength);

I need add the following.

Code:
 = if mode == mode.histogram and barUpCount > 0 then barUpCount else nan;

i'm not sure about histogram, but i have experimented with lines and dashes for paintingstrategy and curve, after seeing this post

maybe this will help.
i added notes to the end this study i made, describing several similar situations.
https://usethinkscript.com/threads/...remove-it-once-price-hits-it.5257/#post-75706


Code:
# ========================================

# i used curve,  because curve.dash line always looks like a dash line

# this works,  but points are drawn much thicker than if a line.
#  and paint.dash looks solid when zoomed out.  didn't use this

# paint , line , points
#input lines = {default LINE, POINTS};
#def paint = if lines == lines.POINTS then PaintingStrategy.POINTS else  PaintingStrategy.LINE;
# plot x1 =
#x1.SetPaintingStrategy(paint);


# this doesn't work
# chg line if price crosses it
#def paint1hi = if d1hix > 0 then PaintingStrategy.POINTS else  PaintingStrategy.LINE;

#signal.SetPaintingStrategy(if crossingType == CrossingType.above
#    then PaintingStrategy.BOOLEAN_ARROW_UP
#    else PaintingStrategy.BOOLEAN_ARROW_DOWN);

# ========================================

# input crossed_line = {"invisible", "dots", default "dashes", "solid"};
# this works , but the PaintingStrategy.dashes  line looks like a solid line when zoomed out
# --------------------
#input test_price_line1 = no;
#plot line1x = if ( test_price_line1 and (crslin == 2 or crslin == 3 or crslin == 4)) then line1 else na;
#line1x.SetDefaultColor(Color.LIGHT_GREEN);
#line1x.HideBubble();
#line1x.SetPaintingStrategy(if crossed_line == crossed_line."dots" then PaintingStrategy.points
#  else if crossed_line == crossed_line."dashes" then PaintingStrategy.dashes
#  else if crossed_line == crossed_line."solid" then PaintingStrategy.line
#  else PaintingStrategy.squares);
# -------------------

# this works.  curve.dash  looks like a dash always
#plot L1_dash = if crslin == 2 then line1 else na;
#L1_dash.SetStyle(curve.short_dash);
#L1_dash.SetDefaultColor(Color.LIGHT_GREEN);
#L1_dash.HideBubble();
#plot L1_solid = if crslin == 3 then line1 else na;
#L1_solid.SetStyle(curve.firm);
#L1_solid.SetDefaultColor(Color.LIGHT_GREEN);
#L1_solid.HideBubble();


# this doesn't work
#plot line1x = if (crslin == 2 or crslin == 3) then line1 else na;
#line1x.SetDefaultColor(Color.LIGHT_GREEN);
#line1x.HideBubble();
#line1x.SetStyle(if crossed_line == crossed_line."dashes" then curve.short_dash else if crossed_line == crossed_line."solid" then curve.firm else curve.long_dash);

# ------------------------

#z1hi.SetPaintingStrategy(paint1hi);
#z1hi.SetPaintingStrategy(if d1hix > 0 then PaintingStrategy.points else PaintingStrategy.line);

# this has error
#z1hi.SetStyle(if d1hix > 0 then Curve.POINTS else Curve.FIRM);

# [URL]https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/Curve[/URL]
#x.SetStyle(Curve.FIRM);
#x.SetStyle(Curve.LONG_DASH);
#x.SetStyle(Curve.MEDIUM_DASH);
#x.SetStyle(Curve.SHORT_DASH);
#x.SetStyle(Curve.POINTS);

i saw a post of sleepyz that listed something similar, for choosing line type
https://usethinkscript.com/threads/horizontal-lines.3472/page-7#post-72782
post122, page 7
..

side note,
this may be of interest
robert
using a number for a paintingstrategy(#)
https://usethinkscript.com/threads/horizontal-lines.3472/#post-14529
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
255 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