shakib3585
Active member
Hello All,
Could someone please help me in creating a script to calculate the initial balance, defined as the difference between the highest high and lowest low, based on the first two candles within a 30-minute interval throughout an entire trading session? This trading session should encompass pre-market, regular trading hours, and post-market. I've applied a code using a previous script by @Tiredoflosing (attached below), but I'm unable to track the initial two bars within a 30-minute aggregation based of an entire trading session. Your help is greatly appreciated.
Thanks
Could someone please help me in creating a script to calculate the initial balance, defined as the difference between the highest high and lowest low, based on the first two candles within a 30-minute interval throughout an entire trading session? This trading session should encompass pre-market, regular trading hours, and post-market. I've applied a code using a previous script by @Tiredoflosing (attached below), but I'm unable to track the initial two bars within a 30-minute aggregation based of an entire trading session. Your help is greatly appreciated.
Thanks
Code:
input opentime = 0930;
input ORend = 1030;
input opacity = 1;
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.GREEN);
ORAL.SetDefaultColor(Color.RED);
ORH.SetStyle(Curve.SHORT_DASH);
ORL.SetStyle(Curve.SHORT_DASH);
ORH.SetDefaultColor(Color.GREEN);
ORL.SetDefaultColor(Color.RED);