Plot specific time opening print


Category:
0
0

I have a code that shows specific time frames (default 1:30 and 2:00) and I’d like to add a 1:30 opening candle print line and a 2:00 opening candle print line. If the 1:30 can be red and the 2:00 can be yellow to match the cloud. Can this be added to the current code?

2nd question (not as important) Currently the clouds part shows the high and low of the 1:30-2:00 range. Is it possible to add whatever the 1:30-2:00 print high is to add 1 point (in S&P futures)(2890 is the high, draw a line at 2891) and draw a line? If not, not worried about that part.

Thanks

Code:

#Mid-day futures scalp indicator

#Time Input
input opentime = 1330;
input ORend = 1400;
def na = Double.NaN;

#Check if the opening range time is now
def ORActive = if GetLastDay() == GetDay() and SecondsFromTime(opentime) >= 0 and SecondsFromTime(ORend) < 0 then 1 else 0;

#Track the OR high and low
def ORHigh = if ORActive then high else na;
def ORLow = if ORActive then low else na;

#Plot the OR high and low
plot ORAH = if GetLastDay() != GetDay() or !ORActive then na else HighestAll(ORHigh);
plot ORAL = if GetLastDay() != GetDay() or !ORActive then na else LowestAll(ORLow);
plot ORH = if GetLastDay() != GetDay() or SecondsFromTime(ORend) < 0 then na else HighestAll(ORHigh);
plot ORL = if GetLastDay() != GetDay() or SecondsFromTime(ORend) < 0 then na else LowestAll(ORLow);

#Formatting
ORAH.SetStyle(Curve.SHORT_DASH);
ORAL.SetStyle(Curve.SHORT_DASH);
ORAH.SetDefaultColor(Color.blue);
ORAL.SetDefaultColor(Color.RED);
ORH.SetStyle(Curve.SHORT_DASH);
ORL.SetStyle(Curve.SHORT_DASH);
ORH.SetDefaultColor(Color.blue);
ORL.SetDefaultColor(Color.RED);

#Add Cloud creates the shading
AddCloud(ORH, ORL);
AddCloud(ORAL, ORAH);

#Alerts:
def alerttrigger = if (high >= ORH and low <= ORH) or (high >= ORL and low <= ORL) then 1 else 0; #replace the 1 with your definition

#BLOCK CODE BELOW
input alerttext = “OR Breakout!”;
input UseAlerts = {false, default true};
input AlertType = {default “BAR”, “ONCE”, “TICK”};
def at = AlertType;
input AlertSound = {“Bell”, “Chimes”, default “Ding”, “NoSound”, “Ring”};
Alert(alerttrigger and UseAlerts, alerttext, if at == 1 then Alert.ONCE else if at == 2 then Alert.TICK else Alert.BAR, AlertSound);

Marked as spam
Posted by (Questions: 21, Answers: 47)
Asked on May 14, 2019 11:21 am
320 views
0
Private answer

Here you go:

def openingOne = if GetLastDay() != GetDay() or SecondsFromTime(opentime) <> 0 then na else open;
def openingTwo = if GetLastDay() != GetDay() or SecondsFromTime(ORend) <> 0 then na else open;
rec trackOpeningOne = if !IsNaN(openingOne) then openingOne else trackOpeningOne[1];
rec trackOpeningTwo = if !IsNaN(openingTwo) then openingTwo else trackOpeningTwo[1];
plot firstOpen = if trackOpeningOne <> 0 then trackOpeningOne else Double. NaN;
firstOpen.SetDefaultColor(Color.RED);
plot secondOpen = if trackOpeningTwo <> 0 then trackOpeningTwo else Double.NaN;
secondOpen.SetDefaultColor(Color.YELLOW);

Marked as spam
Posted by (Questions: 37, Answers: 4086)
Answered on May 20, 2019 5:38 pm