High Low in Time Range

Harley Trader

New member
Wonder if anyone can provide a small code up date to this opening 10 minute range that I have. The script runs fine and I was able to add a cloud to it as well, but the cloud will only show one color, which in this case is Light.Green. Light.Green is fine for the upper half of the range, but I cannot seem to get the lower half of the range to show Light.Red. Not a coder, so I am only using snippets of things I find that might work. Not even sure it could work, if the opening range was all to the upside, I would think in my mind that the whole range would then be Green? Boggles my mind for sure. The bottom of the range is red, top of range is green. So I thought it could equally match as a lower half red and upper half green. I will paste the code here. Or maybe use a mid point to separate lower red and upper green?

# High Low in Time Range
# Mobius
# Chat Room Request 09.18.2017 - Altered code to plot all days on chart

declare hide_on_daily;

input Begin = 0930; #hint rBegin: Beginning Time of Range.
input End = 0935; #hint OrEnd: Ending Time of Range.
input ShowTodayOnly = yes;


def h = high;
def l = low;
def c = close;
def bar = barNumber();
def Active = if SecondsFromTime(Begin) >= 0 and
SecondsTillTime(End) >= 0
then 1
else 0;
def hh = if Active and !Active[1]
then h
else if Active and h > hh[1]
then h
else hh[1];
def hhBar = if h == hh
then bar
else double.nan;
def ll = if Active and !Active[1]
then l
else if Active and l < ll[1]
then l
else ll[1];
def llBar = if l == ll
then bar
else double.nan;
plot highLine = if bar >= HighestAll(hhBar)
then HighestAll(if isNaN(close[-1])
then hh
else double.nan)
else double.nan;
highLine.SetStyle(Curve.Long_Dash);
highLine.SetLineWeight(2);
highLine.SetDefaultColor(Color.Green);
plot lowLine = if bar >= HighestAll(llBar)
then HighestAll(if isNaN(close[-1])
then ll
else double.nan)
else double.nan;
lowLine.SetStyle(Curve.Long_Dash);
lowLine.SetLineWeight(2);
lowLine.SetDefaultColor(Color.Red);

AddCloud(HighLine, Lowline, Color.Light_GREEN, Color.Light_RED);

# End Code
 
Solution
Wonder if anyone can provide a small code up date to this opening 10 minute range that I have. The script runs fine and I was able to add a cloud to it as well, but the cloud will only show one color, which in this case is Light.Green. Light.Green is fine for the upper half of the range, but I cannot seem to get the lower half of the range to show Light.Red. Not a coder, so I am only using snippets of things I find that might work. Not even sure it could work, if the opening range was all to the upside, I would think in my mind that the whole range would then be Green? Boggles my mind for sure. The bottom of the range is red, top of range is green. So I thought it could equally match as a lower half red and upper half green...
Wonder if anyone can provide a small code up date to this opening 10 minute range that I have. The script runs fine and I was able to add a cloud to it as well, but the cloud will only show one color, which in this case is Light.Green. Light.Green is fine for the upper half of the range, but I cannot seem to get the lower half of the range to show Light.Red. Not a coder, so I am only using snippets of things I find that might work. Not even sure it could work, if the opening range was all to the upside, I would think in my mind that the whole range would then be Green? Boggles my mind for sure. The bottom of the range is red, top of range is green. So I thought it could equally match as a lower half red and upper half green. I will paste the code here. Or maybe use a mid point to separate lower red and upper green?

# High Low in Time Range
# Mobius
# Chat Room Request 09.18.2017 - Altered code to plot all days on chart

declare hide_on_daily;

input Begin = 0930; #hint rBegin: Beginning Time of Range.
input End = 0935; #hint OrEnd: Ending Time of Range.
input ShowTodayOnly = yes;


def h = high;
def l = low;
def c = close;
def bar = barNumber();
def Active = if SecondsFromTime(Begin) >= 0 and
SecondsTillTime(End) >= 0
then 1
else 0;
def hh = if Active and !Active[1]
then h
else if Active and h > hh[1]
then h
else hh[1];
def hhBar = if h == hh
then bar
else double.nan;
def ll = if Active and !Active[1]
then l
else if Active and l < ll[1]
then l
else ll[1];
def llBar = if l == ll
then bar
else double.nan;
plot highLine = if bar >= HighestAll(hhBar)
then HighestAll(if isNaN(close[-1])
then hh
else double.nan)
else double.nan;
highLine.SetStyle(Curve.Long_Dash);
highLine.SetLineWeight(2);
highLine.SetDefaultColor(Color.Green);
plot lowLine = if bar >= HighestAll(llBar)
then HighestAll(if isNaN(close[-1])
then ll
else double.nan)
else double.nan;
lowLine.SetStyle(Curve.Long_Dash);
lowLine.SetLineWeight(2);
lowLine.SetDefaultColor(Color.Red);

AddCloud(HighLine, Lowline, Color.Light_GREEN, Color.Light_RED);

# End Code
Yes:), the midline will work. Replace your addcloud code with the following:
Ruby:
AddCloud((highLine + lowLine) / 2, lowLine, Color.LIGHT_RED, Color.LIGHT_RED);
AddCloud(highLine, (highLine + lowLine) / 2, Color.LIGHT_GREEN, Color.LIGHT_GREEN);
 
Solution

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