Plot line at the low of consecutive green candle

SJP07

Member
I need help fixing my code that currently plots a horizontal line under each green candle. I want it to only show a line at the low of each consecutive green candle.

input length = 1;

def isUpCloseCandle = close > open;

plot UpCloseLine = if isUpCloseCandle
then low
else double.nan;

UpCloseLine.SetDefaultColor(color.Green);
UpCloseLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpCloseLine.SetLineWeight(1);
 
I need help fixing my code that currently plots a horizontal line under each green candle. I want it to only show a line at the low of each consecutive green candle.

input length = 1;

def isUpCloseCandle = close > open;

plot UpCloseLine = if isUpCloseCandle
then low
else double.nan;

UpCloseLine.SetDefaultColor(color.Green);
UpCloseLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpCloseLine.SetLineWeight(1);

This might do what you want to happen.

Screenshot 2023-10-05 092916.png
Code:
input length = 1;

def isUpCloseCandle = close > open;

plot UpCloseLine = if isUpCloseCandle and isupcloseCandle[1]
then low
else double.nan;

UpCloseLine.SetDefaultColor(color.Green);
UpCloseLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
UpCloseLine.SetLineWeight(1);
 
Thanks. This is very close to what I'm looking for, but not quite it.
I've included a screenshot as a
Screenshot 2023-10-05 at 2.15.41 PM.png
reference. I'd like it to show the last five occurrences and for the lines to extend.
 
Thanks. This is very close to what I'm looking for, but not quite it.
I've included a screenshot as a View attachment 19873reference. I'd like it to show the last five occurrences and for the lines to extend.

This looks like it might be what you want.

Screenshot 2023-10-19 153004.png
Code:
def isUpCloseCandle = close > open;
def count     = if !isUpCloseCandle
                then 0 else
                if !isUpCloseCandle[2] and isUpCloseCandle[1] and isUpCloseCandle and low[1] > low
                then 2 else
                if !isUpCloseCandle[1] and isUpCloseCandle and count[1] == 0
                then 1
                else 0;
def lowlength = if count == 2
                then low else
                if count[-1] != 2 and count == 1
                then low
                else lowlength[1];

input test = no;
AddChartBubble(test and between(count,1,2),low, count, Color.YELLOW, no);


def candles  = !IsNaN(close);
def capture  = candles and lowlength != lowlength[1];
def xCount   = CompoundValue(1, if capture then xCount[1] + 1 else xCount[1], 0);
def x        = (HighestAll(xCount) - xCount) + 1;

def upclose1  = if IsNaN(lowlength)
                then upclose1[1] else
                if x == 1
                then lowlength
                else upclose1[1];
plot u1 = upclose1;
u1.SetDefaultColor(Color.GREEN);
u1.SetPaintingStrategy(PaintingStrategy.DASHES);
u1.SetLineWeight(1);

def upclose2  = if IsNaN(lowlength)
                then upclose2[1] else
                if x == 2
                then lowlength
                else upclose2[1];
plot u2 = upclose2;
u2.SetDefaultColor(Color.GREEN);
u2.SetPaintingStrategy(PaintingStrategy.DASHES);
u2.SetLineWeight(1);

def upclose3  = if IsNaN(lowlength)
                then upclose3[1] else
                if x == 3
                then lowlength
                else upclose3[1];
plot u3 = upclose3;
u3.SetDefaultColor(Color.GREEN);
u3.SetPaintingStrategy(PaintingStrategy.DASHES);
u3.SetLineWeight(1);

def upclose4  = if IsNaN(lowlength)
                then upclose4[1] else
                if x == 4
                then lowlength
                else upclose4[1];
plot u4 = upclose4;
u4.SetDefaultColor(Color.GREEN);
u4.SetPaintingStrategy(PaintingStrategy.DASHES);
u4.SetLineWeight(1);

def upclose5  = if IsNaN(lowlength)
                then upclose5[1] else
                if x == 5
                then lowlength
                else upclose5[1];
plot u5 = upclose5;
u5.SetDefaultColor(Color.GREEN);
u5.SetPaintingStrategy(PaintingStrategy.DASHES);
u5.SetLineWeight(1);

defineGlobalColor("L", color.yellow);
input bubbles = yes;
input bubblemover = 3;
def b=bubblemover;
def b1=b+1;
addchartBubble(bubbles and isnan(close[b]) and !isnan(close[b1]), upclose1[b1], "Low 1:  " + asdollars(upclose1[b1]), globalColor("L"));
addchartBubble(bubbles and isnan(close[b]) and !isnan(close[b1]), upclose2[b1], "Low 2:  " + asdollars(upclose2[b1]), globalColor("L"));
addchartBubble(bubbles and isnan(close[b]) and !isnan(close[b1]), upclose3[b1], "Low 3:  " + asdollars(upclose3[b1]), globalColor("L"));
addchartBubble(bubbles and isnan(close[b]) and !isnan(close[b1]), upclose4[b1], "Low 4:  " + asdollars(upclose4[b1]), globalColor("L"));
addchartBubble(bubbles and isnan(close[b]) and !isnan(close[b1]), upclose5[b1], "Low 5:  " + asdollars(upclose5[b1]), globalColor("L"));

#
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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