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.

Capture.jpg
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.
7FspHBO.png
[/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.
7FspHBO.png
[/IMG]

Added red lines in case you still needed them.

Capture.jpg
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);
;
 

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
445 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