Bi-Weekly high low

Srini85

New member
Hello, can someone help me by sharing the 15 day high low and close ( ignoring public holidays and weekends)
 
Solution
Hello, can someone help me by sharing the 15 day high low and close ( ignoring public holidays and weekends)

See if this works:

Screenshot 2023-12-19 092801.png
Code:
input length   = 15;
input vertical = yes;
input label    = yes;

def basis = GetYYYYMMDD() != GetYYYYMMDD()[1];
def count = if !IsNaN(close) and basis then count[1] + 1 else count[1];
def day   = HighestAll(count) - count + 1;

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

AddVerticalLine(if !vertical then Double.NaN else day[1] == length + 1 and day == length, "", Color.WHITE);

def h   = if bn == 1
          then Double.NaN
          else if day[1] == length + 1 and day == length
          then high
          else if day <=...
Hello, can someone help me by sharing the 15 day high low and close ( ignoring public holidays and weekends)

See if this works:

Screenshot 2023-12-19 092801.png
Code:
input length   = 15;
input vertical = yes;
input label    = yes;

def basis = GetYYYYMMDD() != GetYYYYMMDD()[1];
def count = if !IsNaN(close) and basis then count[1] + 1 else count[1];
def day   = HighestAll(count) - count + 1;

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

AddVerticalLine(if !vertical then Double.NaN else day[1] == length + 1 and day == length, "", Color.WHITE);

def h   = if bn == 1
          then Double.NaN
          else if day[1] == length + 1 and day == length
          then high
          else if day <= length and high > h[1]
          then high else h[1];
plot hh = if day > length
          then Double.NaN   
          else HighestAll(h);

def l   = if bn == 1
          then Double.NaN
          else if day[1] == length + 1 and day == length
          then low
          else if day <= length and low < l[1]
          then low else l[1];
plot ll = if day > length
          then Double.NaN   
          else LowestAll(l);

plot cc = if day > length then Double.NaN
          else HighestAll(if bn == HighestAll(lastbn)
                          then close else Double.NaN);
cc.SetDefaultColor(Color.WHITE);

AddLabel(label, "H: " + AsText(hh) + " | L: " + AsText(ll) + " | C: " + AsText(cc), Color.YELLOW);

#
 
Solution

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

Hi SleepyZ, can you please show the code for scanning the biweekly high and low?
I did as follow, but it did not produce spike at the high and low:
plot x= if ll is true then 1 else 0;
plot xx= if hh is true then1 else 0;

That code was made to display to the requestor where the hh/ll were and that the days were trading days. It used code that works on a chart but does not work in the scanner.

This should do work to find if the current day is the hh or ll in the last 14 days. Comment out the plot that you are not scanning when scanning for the other. Set scan to DAY.

Scan code
Screenshot 2024-01-02 091944.png
Code:
def lastbar = HighestAll( if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN);

def h = if IsNaN(close) then h[1] else if BarNumber() == lastbar - 14 then high else if BarNumber() > lastbar - 14 then Max(high, h[1]) else h[1];
#plot hh_scan = high == h;

def l = compoundValue(1, if IsNaN(close) then l[1] else if BarNumber() == lastbar - 14 then low else if BarNumber() > lastbar - 14 then Min(low, l[1]) else l[1], low);
plot ll_scan = low == l;

Chart code to verify scan
Screenshot 2024-01-02 092146.png
Code:
def lastbar = HighestAll( if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN);

def h = if IsNaN(close) then h[1] else if BarNumber() == lastbar - 14 + 1 then high else if BarNumber() > lastbar - 14 then Max(high, h[1]) else h[1];
plot hh = h;

def l = compoundValue(1, if IsNaN(close) then l[1] else if BarNumber() == lastbar - 14 + 1 then low else if BarNumber() > lastbar - 14 then Min(low, l[1]) else l[1], low);
plot ll = l;
 
That code was made to display to the requestor where the hh/ll were and that the days were trading days. It used code that works on a chart but does not work in the scanner.

This should do work to find if the current day is the hh or ll in the last 14 days. Comment out the plot that you are not scanning when scanning for the other. Set scan to DAY.

Scan code


Chart code to verify scan
Thanks SleepyZ!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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