3 consecutive green/red bars with a dot on the first candle

hovno

New member
Hello,

Can someone please help me to build a simple tool that will plot a dot or an arrow every time three consecutive higher green or lower red candles appear? Basically a legstart of the swing. The problem is, I would like to plot an arrow/dot on that first candle (beginning of the legstart), not the last candle nor the all candles...but the first candle..(of course the dot will appear after all candles are completed so after 3 candles).

This is what i came up with so far:


def candle = open < close;
def leg =((candle > candle[1]) and (candle[1] > candle[2]) and (candle[2] > candle[3]));


plot LegStart = if leg then Lowest(leg) else Double.NaN;
LegStart.setpaintingStrategy(paintingStrategy.POINTS);
LegStart.setLineWeight(3);
LegStart .setdefaultColor(Color.WHITE);
 
Solution
Hello,

Can someone please help me to build a simple tool that will plot a dot or an arrow every time three consecutive higher green or lower red candles appear? Basically a legstart of the swing. The problem is, I would like to plot an arrow/dot on that first candle (beginning of the legstart), not the last candle nor the all candles...but the first candle..(of course the dot will appear after all candles are completed so after 3 candles).

This is what i came up with so far:


def candle = open < close;
def leg =((candle > candle[1]) and (candle[1] > candle[2]) and (candle[2] > candle[3]));


plot LegStart = if leg then Lowest(leg) else Double.NaN;
LegStart.setpaintingStrategy(paintingStrategy.POINTS);
LegStart.setLineWeight(3)...
Hello,

Can someone please help me to build a simple tool that will plot a dot or an arrow every time three consecutive higher green or lower red candles appear? Basically a legstart of the swing. The problem is, I would like to plot an arrow/dot on that first candle (beginning of the legstart), not the last candle nor the all candles...but the first candle..(of course the dot will appear after all candles are completed so after 3 candles).

This is what i came up with so far:


def candle = open < close;
def leg =((candle > candle[1]) and (candle[1] > candle[2]) and (candle[2] > candle[3]));


plot LegStart = if leg then Lowest(leg) else Double.NaN;
LegStart.setpaintingStrategy(paintingStrategy.POINTS);
LegStart.setLineWeight(3);
LegStart .setdefaultColor(Color.WHITE);

See if this works as you want

Capture.jpg
Ruby:
def legup    = Sum(open < close, 3) == 3;
def legdn    = Sum(open > close, 3) == 3;


plot LegupStart = if !legup and !legup[-1] and legup[-2] then low else Double.NaN;
LegupStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegupStart.SetLineWeight(5);
LegupStart .SetDefaultColor(Color.WHITE);

plot LegdnStart = if !legdn and !legdn[-1] and legdn[-2] then high else Double.NaN;
LegdnStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegdnStart.SetLineWeight(5);
LegdnStart .SetDefaultColor(Color.YELLOW);
 
Solution

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

Is it possible to change this for 2 consecutive bars instead of 3? I tried editing the code (don't know much) but its not coming out right.

Sure, try this

Capture.jpg
Ruby:
def legup    = Sum(open < close, 2) == 2;
def legdn    = Sum(open > close, 2) == 2;


plot LegupStart = if !legup and legup[-1] then low else Double.NaN;
LegupStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegupStart.SetLineWeight(5);
LegupStart .SetDefaultColor(Color.WHITE);

plot LegdnStart = if !legdn and legdn[-1] then high else Double.NaN;
LegdnStart.SetPaintingStrategy(PaintingStrategy.POINTS);
LegdnStart.SetLineWeight(5);
LegdnStart .SetDefaultColor(Color.YELLOW);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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