Hi guys. I'm working on a code/column that looks at change from Pre-Market Open to Pre-Market Close or Regular Trading Hours Open.
I hacked this together using 2 scripts but getting garbage. And it's too dang heavy. Any suggestions to define PMO and PMC easier?
I hacked this together using 2 scripts but getting garbage. And it's too dang heavy. Any suggestions to define PMO and PMC easier?
Code:
# Inputs
input PlotPreMktLinesHrsPastOpen = 0;
input PlotRegMktLinesHrsPastOpen = 0;
input PlotYesterdayMktLinesHrsPastOpen = 0;
input PlotActiveRegMktLinesOnPrevDays = 0;
input DisplayPreMarketPriceBubbles = yes;
input DisplayCurrentDayPriceBubbles = yes;
input DisplayPreviousDayPriceBubbles = yes;
# Pre market / Regular market definitions
def ExtPMOut = PlotPreMktLinesHrsPastOpen * 3610000;
def ExtRMOut = PlotRegMktLinesHrsPastOpen * 3610000;
def ExtYMOut = PlotYesterdayMktLinesHrsPastOpen * 3610000;
def MktPlot = GetLastDay() - PlotActiveRegMktLinesOnPrevDays <= GetDay() and GetLastYear() - 0 <= GetYear();
def PMhrs = RegularTradingStart (GetYYYYMMDD()) > GetTime();
def RMhrs = RegularTradingStart (GetYYYYMMDD()) < GetTime();
def PMplots = RegularTradingStart (GetYYYYMMDD()) > GetTime() - ExtPMOut;
def RMplots = RegularTradingStart (GetYYYYMMDD()) > GetTime() - ExtRMOut;
def YMplots = RegularTradingStart (GetYYYYMMDD()) > GetTime() - ExtYMOut;
def PMStart = RMhrs[1] and PMhrs;
def RMStart = PMhrs[1] and RMhrs;
def PMHigh = CompoundValue(1, if PMStart then high else if PMhrs then Max(high, PMHigh[1]) else PMHigh[1], 0);
def PMLow = CompoundValue (1, if PMStart then low else if PMhrs then Min(low, PMLow[1]) else PMLow[1], 0);
# Pre market open code
def HidePMO = if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
def day = GetDay();
def PMopenBar = day != day[1];
def PMOpen = if PMopenBar then open else PMOpen[1];
def PMO = if HidePMO and MktPlot and PMplots then PMOpen else Double.NaN;
# Current day open code
def HideCDO = if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
def CDOpen = if !day then Double.NaN else open (period = "day");
def CDO = if HideCDO and MktPlot and RMplots then CDOpen else Double.NaN;
plot PMC = (PMOpen - CDOpen);
PMC.assignvalueColor(if PMC >0 then color.green else color.red);