# Plot line at higher high after price spike

#### decoder

##### New member
can you guys help me create a study that plots line at high of the candle when it spikes over 30% and range its double than yesterday's ? but if the next candle makes a higher high then plot the line at the new high whether or not it spikes 30% and so on until stop making new highs. Thanks for your time.

can you guys help me create a study that plots line at high of the candle when it spikes over 30% and range its double than yesterday's ? but if the next candle makes a higher high then plot the line at the new high whether or not it spikes 30% and so on until stop making new highs. Thanks for your time.

The spikes are denoted by a white dot at the high. If the subsequent bars are higher highs then a cyan colored line will plot at these highs.

Ruby:
``````#can you guys help me create a study that plots line at high of the candle when it spikes over 30% and range its double than yesterday's ? but if the next candle makes a higher high then plot the line at the new high whether or not it spikes 30% and so on until stop making new highs. Thanks for your time.

def range =
(high(period = AggregationPeriod.DAY) - low(period = AggregationPeriod.DAY)) >
(high(period = AggregationPeriod.DAY)[1] - low(period = AggregationPeriod.DAY)[1]) * 2 ;

def spike       = range and (high - low) > (high[1] - low[1]) * 1.30;
plot spikebegin = if spike
then high
else
double.nan;
spikebegin.setpaintingStrategy(PaintingStrategy.POINTS);
spikebegin.setlineWeight(5);
spikebegin.setdefaultColor(color.white);

def spikehighs     = if isnan(close)
then spikehighs[1]
else if spike[1] and high> high[1]
then high
else if high > spikehighs[1]
then high
else if spike
then double.nan
else spikehighs[1];

plot spikenewhighs = if spike then double.nan else spikehighs;
spikenewhighs.setpaintingStrategy(PaintingStrategy.LINE);
spikenewhighs.setdefaultColor(color.cyan);
spikenewhighs.setlineweight(4);
;``````

Great work! just one thing, I did not express my self correctly the first time I want to plot also the line at the high when there is not consecutive highs, thank you so much for your precious time.
[/IMG]

Great work! just one thing, I did not express my self correctly the first time I want to plot also the line at the high when there is not consecutive highs, thank you so much for your precious time.
[/IMG]

Added red lines in case you still needed them.

Ruby:
``````#can you guys help me create a study that plots line at high of the candle when it spikes over 30% and range its double than yesterday's ? but if the next candle makes a higher high then plot the line at the new high whether or not it spikes 30% and so on until stop making new highs. Thanks for your time.

def range =
(high(period = AggregationPeriod.DAY) - low(period = AggregationPeriod.DAY)) >
(high(period = AggregationPeriod.DAY)[1] - low(period = AggregationPeriod.DAY)[1]) * 2 ;

def spike       = range and (high - low) > (high[1] - low[1]) * 1.30;

plot spikebegin  = if spike
then high
else
double.nan;
spikebegin.setpaintingStrategy(PaintingStrategy.POINTS);
spikebegin.setlineWeight(5);
spikebegin.setdefaultColor(color.white);

def spikehighs     = if isnan(close)
then spikehighs[1]
else if spike[1] and high> high[1]
then high
else if high > spikehighs[1]
then high
else if spike
then double.nan
else spikehighs[1];

plot spikenewhighs = if spike then double.nan else spikehighs;
spikenewhighs.setpaintingStrategy(PaintingStrategy.LINE);
spikenewhighs.setdefaultColor(color.cyan);
spikenewhighs.setlineweight(4);

def spikebarehi    = if isnan(close)
then spikebarehi[1]
else if spike
then high
else if high > spikebarehi[1]
then double.nan
else
spikebarehi[1];

plot barespikehi   = spikebarehi;
barespikehi.setpaintingStrategy(paintingStrategy.HORIZONTAL);
barespikehi.setdefaultColor(color.red);
;``````

thanks SleepyZ works amazing you're the man!!

Added red lines in case you still needed them.
Is the code available, or did I miss it? Thank you

87k+ Posts
261 Online

## The Market Trading Game Changer

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?