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