I know it's a long shot to ask here, but I am looking for a way to determine if the first 1 minute candle is red, meaning that the bar closes below the open.
To do this I simply need the open value and close value of the first one minute bar, but I haven't found a way to get the close.
Getting the open is fairly straight forward:
def openValue = open(period = AggregationPeriod.DAY);
Getting the Range of the first bar is fairly straightforward as well since we define a range (1 min) and return the high/low of that range.
If anybody can help, I would really appreciate it.
Thanks!
Ok, someone helped me figure it out.
def x = barNumber(); //bar
def RTH = getTime() >= RegularTradingStart(getYYYYMMDD()) and
getTime() <= RegularTradingEnd(getYYYYMMDD());
def TodaysOpen = if RTH and !RTH[1]
then open
else TodaysOpen[1];
def OpenX = if RTH and !RTH[1]
then x
else double.nan;
def YesterdaysClose = if !RTH and RTH[1]
then close[1]
else YesterdaysClose[1];
def CloseX = if !RTH and RTH[1]
then x
else double.nan;
def HighToday = if RTH and !RTH[1]
then high
else if RTH and high > HighToday[1]
then high
else HighToday[1];
def HighX = if high == HighToday
then x
else double.nan;
def LowToday = if RTH and !RTH[1]
then low
else if RTH and low < LowToday[1]
then low
else LowToday[1];
def LowX = if low == LowToday
then x
else double.nan;
plot OpenToday = if barNumber() >= HighestAll(OpenX)
then HighestAll(if isNaN(close[-1])
then TodaysOpen
else double.nan)
else double.nan;
OpenToday.SetStyle(Curve.Long_Dash);
def firstbarclose = if RTH and !RTH[1]
then close
else firstbarclose[1];
plot CloseBar = if barNumber() >= HighestAll(OpenX)
then HighestAll(if isNaN(close[-1])
then firstbarclose
else double.nan)
else double.nan;
closebar.SetStyle(Curve.Long_Dash);