rlohmeyer
Active member
The following code is actually 2 separate indicators, which combined can give me the High and Low for the period between 1600 EST and 930 EST. However, it is not not an elegant solution since I generally have to uncheck the plot for one of the highs or lows to actually get the actual high or low for the period. I am not great with time functions. In any of you great coders could help it would be much appreciated. I have worked on ways to combine these 2 in some way but failed. @Mobious code is included and then additional code I scrounged. @SleepyZ @samer800 if you have time. I gave it about 18 hours and then gave up with my non-elegant solution below.
Code:
#Places vertical lines at start and end times and draws High and Low Lines
input onb = 1600;
input one = 930;
def SOD = secondsFromTime(1600) > 0;
def EOD = secondsFromTime(930) > 0;
def ST = SecondsFromTime(onb) ==0;
def ET = SecondsFromTime(one) ==0;
def OVN = Gettime() > sod;
AddVerticalLine(ST,"Market Open",Color.RED,Curve.points);
AddVerticalLine(ET," Market Closed",Color.RED,Curve.points);
input Date = 20130801;#hint Date: Set the date you want see.<b>\n(Enter in YYYYMMDD)</b>
def timeTest = getYyyyMmDd() == date;
def H = if timetest and sod then high else double.nan;
def L = if timetest and sod then low else double.nan;
plot HLine = highestall(h);
Hline.SetPaintingStrategy(PaintingStrategy.triangles);
Hline.setlineweight(3);
Hline.SetDefaultColor(Color.dark_green);
Hline.HideBubble();
Hline.HideTitle();
plot LLine = lowestall(l);
Lline.SetPaintingStrategy(PaintingStrategy.triangles);
Lline.setlineWeight(3);
Lline.SetDefaultColor(Color.dark_red);
Lline.HideBubble();
Lline.HideTitle();
#Mobius code...using a different method draws High and Low Lines for Globex but doesn't include after hours till midnight EST
def ph = high[1];
def pl = low[1];
def bar = BarNumber();
def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());
def ONhigh = if GlobeX and !Globex[1] then high else if Globex and
high > ONhigh[1]then high else ONhigh[1];
def ONhighBar = if GlobeX and h == ONhigh then Bar else double.nan;
def ONlow = if GlobeX and !GlobeX[1]then low else if GlobeX and
low < ONlow[1] then low else ONlow[1];
def ONlowBar = if GlobeX and low == ONlow then Bar else double.nan;
def OverNightHigh = if BarNumber() == HighestAll(ONhighBar) then ONhigh
else OverNightHigh[1];
def OverNightLow = if BarNumber() == HighestAll(ONlowBar)then ONlow
else OverNightLow[1];
def ONH_ = if OverNightHigh > 0 then OverNightHigh else Double.NaN;
def ONL_ = if OverNightLow > 0 then OverNightLow else Double.NaN;
plot ONH = if Hline > ONH_ then Hline else ONH_;
ONH.SetPaintingStrategy(PaintingStrategy.triangles);
ONH.setlineweight(3);
ONH.SetDefaultColor(Color.dark_green);
ONH.HideBubble();
ONH.HideTitle();
plot ONL = if Lline < ONL_ then Lline else ONL_;
ONL.SetPaintingStrategy(PaintingStrategy.triangles);
ONL.setlineWeight(3);
ONL.SetDefaultColor(Color.dark_red);ONL.HideBubble();
ONL.HideTitle();