Manfrom1968
New member
How to plot a horizontal line at the mid point of the high and low of 1st 15 minute candle of the day? What I've tried is not working and any help is appreciated. Thank you.
Code:
# Define the time frame for the first 15-minute candle
input marketOpenTime = 0930;
input firstCandleDuration = 15; ## 15 minutes
def is_first_candle = if SecondsFromTime(marketOpenTime) == 0 then 1 else 0;
def firstCandleHigh = high(period="DAY");
def firstCandleLow = low(period="DAY");
def firstCandleMidpoint = (firstCandleHigh + firstCandleLow) / 2;
def isFirstCandleClose = if is_first_candle and !is_first_candle[1] then close else Double.NaN;
# Plot the line on the chart
plot firstCandleCloseLine = if !IsNaN(isFirstCandleClose) then isFirstCandleClose else Double.NaN;
firstCandleCloseLine.SetDefaultColor(Color.GREEN);
firstCandleCloseLine.SetLineWeight(2);
# Plot the midpoint on the chart
plot firstCandleMidpointLine = if !IsNaN(isFirstCandleClose) then firstCandleMidpoint else Double.NaN;
firstCandleMidpointLine.SetDefaultColor(Color.BLUE);
firstCandleMidpointLine.SetLineWeight(2);