Hello, can someone help me by sharing the 15 day high low and close ( ignoring public holidays and weekends)
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)
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); #
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?See if this works:
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;
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;
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;
Thanks SleepyZ!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
[SIZE=17px]SleepyZ[/SIZE] -Thank you, sorry for the delayed response. I was looking at getting the biweekly high like below
Jan 1 - Jan 15 - High low for this period
Jan 16- Jan 30- High low for this period
in any month I need the first two weeks high low and second two weeks high low separately.
Thank you!
Code:#HL_1sr_2nd_High_Month declare lower; input show_at_top = yes; input showlines = yes; def h1 = if GetMonth() != GetMonth()[1] then high else if GetDayOfMonth(GetYYYYMMDD()) <= 15 and high > h1[1] then high else if GetDayOfMonth(GetYYYYMMDD()) > 15 then Double.NaN else h1[1]; plot hh1 = if !IsNaN(h1) then h1 else Double.NaN; def l1 = if GetMonth() != GetMonth()[1] then low else if GetDayOfMonth(GetYYYYMMDD()) <= 15 and low < l1[1] then low else if GetDayOfMonth(GetYYYYMMDD()) > 15 then Double.NaN else l1[1]; plot ll1 = if !IsNaN(l1) then l1 else Double.NaN; def location1 = if (IsNaN(h1[-1]) and !IsNaN(h1)) == 1 then IsNaN(h1[-1]) and !IsNaN(h1) else IsNaN(l1[-1]) and !IsNaN(l1) ; AddChartBubble(location1 == 1, if show_at_top then 90 else h1, "L: " + AsText(l1), Color.LIGHT_RED, yes); AddChartBubble(location1 == 1, if show_at_top then 90 else h1, "Mo: " + GetMonth() + "\n1st Half\nH: " + AsText(h1), Color.LIGHT_GREEN, yes); #2nd Half def h2 = if !IsNaN(h1[1]) and IsNaN(h1) then high else if GetDayOfMonth(GetYYYYMMDD()) <= 31 and high > h2[1] then high else if GetMonth() != GetMonth()[1] then Double.NaN else h2[1]; plot hh2 = if !IsNaN(h2) then h2 else Double.NaN; def l2 = if !IsNaN(l1[1]) and IsNaN(l1) then low else if GetDayOfMonth(GetYYYYMMDD()) <= 31 and low < l2[1] then low else if GetMonth() != GetMonth()[1] then Double.NaN else l2[1]; plot ll2 = if !IsNaN(l2) then l2 else Double.NaN; def location2 = if (IsNaN(h2[-1]) and !IsNaN(h2)) == 1 then IsNaN(h2[-1]) and !IsNaN(h2) else IsNaN(l2[-1]) and !IsNaN(l2) ; AddChartBubble(location2 == 1, if show_at_top then 90 else h2, "L: " + AsText(l2), Color.LIGHT_RED, yes); AddChartBubble(location2 == 1, if show_at_top then 90 else h2, "Mo: " + GetMonth() + "\n2nd Half\nH: " + AsText(h2), Color.LIGHT_GREEN, yes); plot linetop = 100; plot linebot = 0; linetop.SetDefaultColor(Color.BLACK); linebot.SetDefaultColor(Color.BLACK); linetop.SetHiding(!show_at_top); linebot.SetHiding(!show_at_top); hh1.SetHiding(!showlines); hh2.SetHiding(!showlines); ll1.SetHiding(!showlines); ll2.SetHiding(!showlines); #
![]()
Code:#HL_1sr_2nd_High_Month #declare lower; input show_at_top = no; input showlines = yes; def h1 = if GetMonth() != GetMonth()[1] then high else if GetDayOfMonth(GetYYYYMMDD()) <= 15 and high > h1[1] then high else if GetDayOfMonth(GetYYYYMMDD()) > 15 then Double.NaN else h1[1]; plot hh1 = if !IsNaN(h1) then h1 else Double.NaN; def l1 = if GetMonth() != GetMonth()[1] then low else if GetDayOfMonth(GetYYYYMMDD()) <= 15 and low < l1[1] then low else if GetDayOfMonth(GetYYYYMMDD()) > 15 then Double.NaN else l1[1]; plot ll1 = if !IsNaN(l1) then l1 else Double.NaN; def location1 = if (IsNaN(h1[-1]) and !IsNaN(h1)) == 1 then IsNaN(h1[-1]) and !IsNaN(h1) else IsNaN(l1[-1]) and !IsNaN(l1) ; AddChartBubble(location1 == 1, if show_at_top then 90 else h1, "L: " + AsText(l1), Color.LIGHT_RED, yes); AddChartBubble(location1 == 1, if show_at_top then 90 else h1, "Mo: " + GetMonth() + "\n1st Half\nH: " + AsText(h1), Color.LIGHT_GREEN, yes); #2nd Half def h2 = if !IsNaN(h1[1]) and IsNaN(h1) then high else if GetDayOfMonth(GetYYYYMMDD()) <= 31 and high > h2[1] then high else if GetMonth() != GetMonth()[1] then Double.NaN else h2[1]; plot hh2 = if !IsNaN(h2) then h2 else Double.NaN; def l2 = if !IsNaN(l1[1]) and IsNaN(l1) then low else if GetDayOfMonth(GetYYYYMMDD()) <= 31 and low < l2[1] then low else if GetMonth() != GetMonth()[1] then Double.NaN else l2[1]; plot ll2 = if !IsNaN(l2) then l2 else Double.NaN; def location2 = if (IsNaN(h2[-1]) and !IsNaN(h2)) == 1 then IsNaN(h2[-1]) and !IsNaN(h2) else IsNaN(l2[-1]) and !IsNaN(l2) ; AddChartBubble(location2 == 1, if show_at_top then 90 else h2, "L: " + AsText(l2), Color.LIGHT_RED, yes); AddChartBubble(location2 == 1, if show_at_top then 90 else h2, "Mo: " + GetMonth() + "\n2nd Half\nH: " + AsText(h2), Color.LIGHT_GREEN, yes); plot linetop = 100; plot linebot = 0; linetop.SetDefaultColor(Color.BLACK); linebot.SetDefaultColor(Color.BLACK); linetop.SetHiding(!show_at_top); linebot.SetHiding(!show_at_top); hh1.SetHiding(!showlines); hh2.SetHiding(!showlines); ll1.SetHiding(!showlines); ll2.SetHiding(!showlines); #
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
E | weekly/monthly high low line | Questions | 7 | |
J | Weekly high……Weekly low dot over high and under low | Questions | 3 | |
R | How to scan for option Monthly expiry only (no weekly) | Questions | 1 | |
I | Weekly break out Fib extension script | Questions | 2 | |
![]() |
Weekly Support/Resistance Lines | Questions | 2 |
Start a new thread and receive assistance from our community.
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.
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.