Help with plot on study

PT_Scalper

Member
VIP
Hi all,

I modified a few studies to create this;

def EMA21 = ExpAverage(close, 21);
def EMA50 = ExpAverage(close, 50);
def EMA200 = ExpAverage(close, 200);

def Up2150200 = EMA21 > EMA50 and EMA21 > EMA200 and EMA50 > EMA200;
def Up5021200 = EMA21 < EMA50 and EMA21 > EMA200 and EMA50 > EMA200;
def Up5020021 = EMA21 < EMA50 and EMA21 < EMA200 and EMA50 > EMA200;
def Up2120050 = EMA21 > EMA50 and EMA21 > EMA200 and EMA50 < EMA200;
def Up2002150 = EMA21 > EMA50 and EMA21 < EMA200 and EMA50 < EMA200;
def Up2005021 = EMA21 < EMA50 and EMA21 < EMA200 and EMA50 < EMA200;

I'm really struggling trying to figure out how to add an arrow or vertical line for each of the conditions with the matching colors.

Can anyone help? I prefer the vertical line as it's much easier to see on the chart.

Thanks,

Last edited by a moderator:
Solution
you have the logic conditions, just need to add one to a plot.
you can use boolean painting strategies or non.

boolean , plot a 1 or 0, a true or false. object will be placed just above or below a candle.
Ruby:
``````plot z = Up2150200;
z.SetPaintingStrategy(PaintingStrategy.boolean_ARROW_up);
z.SetLineWeight(4);
z.setdefaultcolor(color.green);``````

plot a price value, to place an object anywhere on chart
Ruby:
``````plot w = if Up2150200 then low else double.nan;
w.SetPaintingStrategy(PaintingStrategy.ARROW_up);
w.SetLineWeight(4);
w.setdefaultcolor(color.green);``````

https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/PaintingStrategy
you have the logic conditions, just need to add one to a plot.
you can use boolean painting strategies or non.

boolean , plot a 1 or 0, a true or false. object will be placed just above or below a candle.
Ruby:
``````plot z = Up2150200;
z.SetPaintingStrategy(PaintingStrategy.boolean_ARROW_up);
z.SetLineWeight(4);
z.setdefaultcolor(color.green);``````

plot a price value, to place an object anywhere on chart
Ruby:
``````plot w = if Up2150200 then low else double.nan;
w.SetPaintingStrategy(PaintingStrategy.ARROW_up);
w.SetLineWeight(4);
w.setdefaultcolor(color.green);``````

https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/PaintingStrategy

Not the exact question you're looking for?

87k+ Posts
170 Online

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?