consecutive bars: one high, a lower high, higher low

WayneS

New member
Would like to know how to begin coding to lookback over a period 10days, 50days and find a High followed by a lower high, how can this be done, help

I am new to ThinkScript, can someone give me some starter code on how I might lookback over a period of days, say 15, 50, 30, and find a 3 bar pattern , first a high bar, and next after it a second bar with a lower high following right after it a third bar where the high is higher than the second but lower than the first. if someone would please show me how this might be done. Thank You.
 
Last edited by a moderator:
Would like to know how to begin coding to lookback over a period 10days, 50days and find a High followed by a lower high, how can this be done, help

I am new to ThinkScript, can someone give me some starter code on how I might lookback over a period of days, say 15, 50, 30, and find a 3 bar pattern , first a high bar, and next after it a second bar with a lower high following right after it a third bar where the high is higher than the second but lower than the first. if someone would please show me how this might be done. Thank You.

Set the lookback to the number of bars to find the pattern. You can choose to view the pattern by coloring the price bars or bubbles.

Screenshot 2023-06-29 114641.png
Code:
#_3Bar_Pattern_Lookback

input lookback   = 50;
input pricecolor = yes;
input bubble     = yes;

def lastbar  = highestall(if !isnan(close) and isnan(close[-1]) then barnumber() else double.nan);

def pattern = if barnumber()>=lastbar-lookback then if high>high[1] and high<high[2] and high[1]<high[2] then 1 else 0 else double.nan;

assignpriceColor(if !pricecolor then color.current else if pattern or pattern[-1] or pattern[-2] then color.yellow else color.current);

addchartBubble(bubble and pattern or pattern[-1] or pattern[-2], high * 1.005, "P", color.yellow, yes);

#
 
How would I start code to select three consecutive bars, one high, a lower high, higher low

Can someone please explain how I would write the code to look within a specific time frame for a 3 bar pattern, being a high, then a lower high, followed by a higher low. If someone would please show me some examples of code I can then start to go into the right direction, I'm new to thinkscript. Thank you
 
Last edited by a moderator:
How would I start code to select three consecutive bars, one high, a lower high, higher low

Can someone please explain how I would write the code to look within a specific time frame for a 3 bar pattern, being a high, then a lower high, followed by a higher low. If someone would please show me some examples of code I can then start to go into the right direction, I'm new to thinkscript. Thank you

Here is the code I previously did for you with the new pattern above.

Screenshot 2023-07-02 120524.png
Code:
#_3Bar_Pattern_Lookback_HH_LH_HL

input lookback   = 50;
input pricecolor = yes;
input bubble     = yes;

def lastbar  = HighestAll(if !IsNaN(close) and IsNaN(close[-1]) then BarNumber() else Double.NaN);

def pattern = if BarNumber() >= lastbar - lookback then if high[2] > high[3] and high[1] < high[2] and low > low[1] then 1 else 0 else Double.NaN;

AssignPriceColor(if !pricecolor then Color.CURRENT else if pattern or pattern[-1] or pattern[-2] then Color.YELLOW else Color.CURRENT);

AddChartBubble(bubble and pattern or pattern[-1] or pattern[-2], high * 1.005, "P", Color.YELLOW, yes);

#
 

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