I need help. I need 2 things:
On an hourly chart I want label and trend lines that show:
1st 5 minute candle open and close .
What do I need to fix here in the code as I'm obviously not getting the data correctly.I need help. I need 2 things:
On an hourly chart I want label and trend lines that show:
1st 5 minute candle open and close .
What do I need to fix here in the code as I'm obviously not getting the data correctly.
On an hourly chart I want label and trend lines that show:
1st 5 minute candle open and close .
What do I need to fix here in the code as I'm obviously not getting the data correctly.I need help. I need 2 things:
On an hourly chart I want label and trend lines that show:
1st 5 minute candle open and close .
What do I need to fix here in the code as I'm obviously not getting the data correctly.
Code:
# Inputs to toggle features
input showPreMarket = yes;
input showFirst5Min = yes;
# Pre-Market High and Low
def isPreMarket = SecondsFromTime(0400) >= 0 and SecondsTillTime(0930) > 0;
def preMarketHigh = if isPreMarket then high else Double.NaN;
def preMarketLow = if isPreMarket then low else Double.NaN;
plot PreMarketHighLine = if showPreMarket then HighestAll(preMarketHigh) else Double.NaN;
PreMarketHighLine.SetDefaultColor(Color.GREEN);
PreMarketHighLine.SetLineWeight(2);
plot PreMarketLowLine = if showPreMarket then LowestAll(preMarketLow) else Double.NaN;
PreMarketLowLine.SetDefaultColor(Color.RED);
PreMarketLowLine.SetLineWeight(2);
# Labels for Pre-Market High and Low
AddLabel(showPreMarket, "PM High: " + Round(HighestAll(preMarketHigh), 2), Color.GREEN);
AddLabel(showPreMarket, "PM Low: " + Round(LowestAll(preMarketLow), 2), Color.RED);
# First 5-Minute High and Low after Market Open
def isFirst5Min = SecondsFromTime(0930) >= 0 and SecondsTillTime(0935) > 0;
def first5MinHigh = if isFirst5Min then high else Double.NaN;
def first5MinLow = if isFirst5Min then low else Double.NaN;
plot First5MinHighLine = if showFirst5Min then HighestAll(first5MinHigh) else Double.NaN;
First5MinHighLine.SetDefaultColor(Color.BLUE);
First5MinHighLine.SetLineWeight(2);
plot First5MinLowLine = if showFirst5Min then LowestAll(first5MinLow) else Double.NaN;
First5MinLowLine.SetDefaultColor(Color.ORANGE);
First5MinLowLine.SetLineWeight(2);
# Labels for First 5-Minute High and Low
AddLabel(showFirst5Min, "1st 5 Min High: " + Round(HighestAll(first5MinHigh), 2), Color.BLUE);
AddLabel(showFirst5Min, "1st 5 Min Low: " + Round(LowestAll(first5MinLow), 2), Color.ORANGE);
# SPY Close and Direction
def spyClose = close(symbol = "SPY");
def spyChange = spyClose - spyClose[1];
def spyDirectionUp = spyChange > 0; # True if SPY is up
def spyDirectionDown = spyChange < 0; # True if SPY is down
# ATR Calculation
def atrLength = 14;
def atr = Average(TrueRange(high, close, low), atrLength);
# Add Labels for SPY and ATR
AddLabel(yes, "SPY: " + Round(spyClose, 2), if spyDirectionUp then Color.BLUE else if spyDirectionDown then Color.RED else Color.GRAY);
AddLabel(yes, "ATR: " + Round(atr, 2), Color.PINK);