Ruby:#Example_PreviousDaysHL-each_extended_through_expansion #20170911 - BLT #Example Highs/Lows from previous days, extended from each day through the right expansion script philow { input n = 1; def ymd = GetYYYYMMDD(); def ok = !IsNaN(close); def capture = ok and ymd != ymd[1]; def dayCount =...
Swing high swing lowThanks.
Basically looking for an indicator that:
1.) plots the extreme swing highs and lows on the daily chart
2.) then plot lines between the above levels (swing high/low) where price reacted to multiple times (basically support and resistance lines) on the daily chart as well.
Both the above need to be viewable on say the 1,5,15 etc mins chart.
Ruby:#Example_PreviousDaysHL-each_extended_through_expansion #20170911 - BLT #Example Highs/Lows from previous days, extended from each day through the right expansion script philow { input n = 1; def ymd = GetYYYYMMDD(); def ok = !IsNaN(close); def capture = ok and ymd != ymd[1]; def dayCount = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0); def thisDay = (HighestAll(dayCount) - dayCount) ; def hh = CompoundValue(1, if thisDay == n and SecondsFromTime(0930) == 0 then high else if thisDay == n and high > hh[1] then high else hh[1] , high); def hhnan = if IsNaN(close) then hhnan[1] else hh; plot hhplot = if thisDay == n and SecondsFromTime(0930) < 0 then Double.NaN else if thisDay <= n then hhnan else Double.NaN; def ll = CompoundValue(1, if thisDay == n and SecondsFromTime(0930) == 0 then low else if thisDay == n and low < ll[1] then low else ll[1] , low); def llnan = if IsNaN(ll) then llnan[1] else ll; plot llplot = if thisDay == n and SecondsFromTime(0930) < 0 then Double.NaN else if thisDay <= n then (llnan) else Double.NaN; } #Plots of Highs/Lows based upon script...add more days using similar plot statements, increasing the value by 1 plot H1 = philow(1); plot H2 = philow(2); plot H3 = philow(3); plot L1 = philow(1).llplot; plot L2 = philow(2).llplot; plot L3 = philow(3).llplot; defineGlobalColor("H",color.red); defineGlobalColor("L",color.green); H1.setdefaultColor(globalColor("H")); H2.setdefaultColor(globalColor("H")); H3.setdefaultColor(globalColor("H")); L1.setdefaultColor(globalColor("L")); L2.setdefaultColor(globalColor("L")); L3.setdefaultColor(globalColor("L"));
Hey @SleepyZ - Any chance it would be possible to have this code use an aggregate rather than being specific for the last 3 days? In other words, so it could look back for the last 3 hourly candles, or last 3 15min candles?@nitrous @vro3 @Pumper @007sakura
Regrettably, plotting horizontal lines in TOS requires a separate plot for each line. So your request is a very manual process to create.
The following code plots 3 sets of daily high/low lines using a script as a basis. All the lines are extended to the right. You can create more plots using the logic between the 3 sets of plots and associated coloring.
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
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.