Scan the bar Lower Low input the date

kc5560

New member
Hello,
Can you help me to make scan to find the third bar Lower low, which is start by the date I chosen?
example
By chosen date: 9/12/22 the day low 55 named Bar Zero, next day day low 56, this bar is not "qalified" because is higher than Bar Zero, then next day day low is 53. this bar is qalified because lower than Bar Zero(55) . And named that Bar 1, Finally I only need to find another bar which is lower than Bar 1 ,named Bar 2 then finished..

Many Thank for help
 
Solution
Hello,
Can you help me to make scan to find the third bar Lower low, which is start by the date I chosen?
example
By chosen date: 9/12/22 the day low 55 named Bar Zero, next day day low 56, this bar is not "qalified" because is higher than Bar Zero, then next day day low is 53. this bar is qalified because lower than Bar Zero(55) . And named that Bar 1, Finally I only need to find another bar which is lower than Bar 1 ,named Bar 2 then finished..

Many Thank for help

I am not sure what you want a scan of Bar2 results to find, so I had 'plot scan' to just find if Bar2 is the last bar on the daily chart ( you can increase the number of bars to lookback by...
Hello,
Can you help me to make scan to find the third bar Lower low, which is start by the date I chosen?
example
By chosen date: 9/12/22 the day low 55 named Bar Zero, next day day low 56, this bar is not "qalified" because is higher than Bar Zero, then next day day low is 53. this bar is qalified because lower than Bar Zero(55) . And named that Bar 1, Finally I only need to find another bar which is lower than Bar 1 ,named Bar 2 then finished..

Many Thank for help

I am not sure what you want a scan of Bar2 results to find, so I had 'plot scan' to just find if Bar2 is the last bar on the daily chart ( you can increase the number of bars to lookback by revising 'plot scan = Bar1==2 within 3 bars;', for example.

I have just shown you how to find the value of the low at Bar2 from a date you input in the commented out (#) code. Just delete the '#' in front of each line if you want to see this result.

Ruby:
def date = 20220912;
def BAR0 = if GetYYYYMMDD() == date then low else BAR0[1];
def BAR1 = if GetYYYYMMDD() > date and low < GetValue(BAR0, 1) then BAR1[1] + 1 else BAR1[1];
#plot BAR2 = if BAR1 == 2 then low else double.nan;
#BAR2.setpaintingStrategy(paintingStrategy.VALUES_BELOW);
#Addlabel(1, "BAR2: " + getvalue(highestall(BAR2),1), color.white);
plot scan = Bar1 == 2;
 
Solution
When The bar2 day high is higher than bar 1 and bar zero i will buy stocks that may be takes a week ,

This might be more helpful based upon you last post. It will find the Lows and Highs using your criteria. The scan is based upon the Highs in this code. If there are not any bars after the initial Bar0High that have met the criteria to Bar1High or Bar2High, they will appear as 'N/A' until met.

Ruby:
input date = 20220912;

def BAR0Low     = if GetYYYYMMDD() == date
                  then low else BAR0Low[1];
def BARLowCount = if GetYYYYMMDD() > date and low < GetValue(BAR0Low, 1)
                  then BARLowCount[1] + 1 else BARLowCount[1];
def Bar1Low     = if BARLowCount == 1 then low else Double.NaN;
def BAR2Low     = if BARLowCount == 2 then low else Double.NaN;

AddLabel(1, "Lows || Bar0: " + BAR0Low +
            " Bar1Low: " + GetValue(HighestAll(Bar1Low), 1) +
            " Bar2Low: " + GetValue(HighestAll(BAR2Low), 1), Color.WHITE);

def BAR0High     = if GetYYYYMMDD() == date
                   then high else BAR0High[1];
def BARHighCount = if GetYYYYMMDD() > date and high > GetValue(BAR0High, 1)
                   then BARHighCount[1] + 1 else BARHighCount[1];
def Bar1High     = if BARHighCount == 1
                   then high else Double.NaN;
def BAR2High     = if BARHighCount == 2
                   then high else Double.NaN;

AddLabel(1, "Highs || Bar0: " + BAR0High +
            " Bar1High: " + GetValue(HighestAll(Bar1High), 1) +
            " Bar2High: " + GetValue(HighestAll(BAR2High), 1), Color.WHITE);

plot scan = BAR2High > Bar1High and BAR2High > BAR0High;
 
I copy the script paste to scan ,it does not work, show "AddLabel is not allowed in this context" May be I did somthing wrong?
You cannot have label code in a scan. The labels were mostly so you code verify that the code works. Either comment them out by putting an '*' before addlabel or delete them in your scan.
 

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