Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The code is not running properly. The AddLabel are showing to be invalid. I need it fixed. Its written in ThinkScript # Inputs input PlotPreMktLinesHrsPastOpen

The code is not running properly. The \"AddLabel\" are showing to be invalid. I need it fixed. Its written in ThinkScript

# 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 =>=>

def PMhrs = RegularTradingStart (GetYYYYMMDD()) > GetTime();

def RMhrs = RegularTradingStart (GetYYYYMMDD())

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);

def bar = BarNumber();

def highBar = if PMhrs and high == PMHigh then bar else Double.NaN;

def lowBar = if PMhrs and low == PMLow then bar else Double.NaN;

# Current price line tracker code

plot PriceLine = HighestAll (if IsNaN(close[-1]) and !IsNaN(close) then close else Double.NaN);

PriceLine.SetDefaultColor (Color.GRAY); PriceLine.SetStyle (Curve.SHORT_DASH);

# Pre market open code

def HidePMO = if GetAggregationPeriod() =>

def day = GetDay();

def PMopenBar = day != day[1];

def PMOpen = if PMopenBar then open else PMOpen[1];

plot PMO = if HidePMO and MktPlot and PMplots then PMOpen else Double.NaN;

PMO.SetDefaultColor (CreateColor (234, 136, 255));

# Pre market high code

def HidePMH = if GetAggregationPeriod() =>

def PMHighBar = if bar == HighestAll(highBar) then PMHigh else PMHighBar[1];

plot PMH = if HidePMH and PMplots and PMHighBar > 0 then PMHighBar else Double.NaN;

PMH.SetDefaultColor (CreateColor (116, 189, 232));

# Pre market low code

def HidePML = if GetAggregationPeriod() =>

def PMLowBar = if bar == HighestAll(lowBar) then PMLow else PMLowBar[1];

plot PML = if HidePML and PMplots and PMLowBar > 0 then PMLowBar else Double.NaN;

PML.SetDefaultColor (CreateColor (116, 189, 232));

# Current day open code

def HideCDO = if GetAggregationPeriod() =>

def CDOpen = if !day then Double.NaN else open (period = \"day\");

plot CDO = if HideCDO and MktPlot and RMplots then CDOpen else Double.NaN;

CDO.SetDefaultColor (Color.WHITE); CDO.SetStyle (Curve.SHORT_DASH);

#Current day high code

def HideCDH = if GetAggregationPeriod() =>

def CDHigh = if !day then Double.NaN else high (period = \"day\");

plot CDH = if HideCDH and MktPlot and RMplots then CDHigh else Double.NaN;

CDH.SetDefaultColor (Color.GREEN); CDH.SetStyle (Curve.SHORT_DASH);

#Current day low code

def HideCDL = if GetAggregationPeriod() =>

def CDLow = if !day then Double.NaN else low (period = \"day\");

plot CDL = if HideCDL and MktPlot and RMplots then CDLow else Double.NaN;

CDL.SetDefaultColor (Color.RED); CDL.SetStyle (Curve.SHORT_DASH);

#Previous day high code

def HidePDH = if GetAggregationPeriod() =>

def PDHigh = if !day then Double.NaN else high (period = \"day\")[1];

plot PDH = if HidePDH and MktPlot and YMplots then PDHigh else Double.NaN;

PDH.SetDefaultColor (CreateColor (153, 255, 153)); PDH.SetStyle (Curve.SHORT_DASH);

#Previous day low code

def HidePDL = if GetAggregationPeriod() =>

def PDLow = if !day then Double.NaN else low (period = \"day\")[1];

plot PDL = if HidePDL and MktPlot and YMplots then PDLow else Double.NaN;

PDL.SetDefaultColor (CreateColor (255, 126, 156)); PDL.SetStyle (Curve.SHORT_DASH);

#Previous day close code

def HidePDC = if GetAggregationPeriod() =>

def PDClose = if !day then Double.NaN else close (period = \"day\")[1];

plot PDC = if HidePDC and MktPlot and YMplots then PDClose else Double.NaN;

PDC.SetDefaultColor (CreateColor (231, 190, 0)); PDC.SetStyle (Curve.SHORT_DASH);

#Pre market bubbles code

def PMLabels = if GetAggregationPeriod() =>

AddLabel(yes, PMopenBar and PMLabels, (\"PMO:\") + PMO, (Color.LIGHT_GRAY));

AddLabel(yes, highBar and PMLabels, (\"PMH:\") + PMH, (Color.LIGHT_GRAY));

AddLabel (yes, lowBar and PMLabels, (\"PML:\") + PML, (Color.LIGHT_GRAY));

#Current day bubbles code

def CDLabels = if GetAggregationPeriod() =>

def CDFirstBar = SecondsFromTime (0800) >= 0 and SecondsFromTime (0800)

AddLabel (yes, CDFirstBar and CDLabels, (\"CDO:\") + CDO, (Color.LIGHT_GRAY));

AddLabel (yes, CDFirstBar and CDLabels, (\"CDH:\") + CDH, (Color.LIGHT_GRAY));

AddLabel (yes, CDFirstBar and CDLabels, (\"CDL:\") + CDL, (Color.LIGHT_GRAY));

#Previous day bubbles code

def PDLabels = if GetAggregationPeriod() =>

def PDFirstBar = SecondsFromTime (0700) >= 0 and SecondsFromTime (0700)

AddLabel (yes, PDFirstBar and PDLabels,(\"PDH:\") + PDH, (Color.LIGHT_GRAY));

AddLabel (yes, PDFirstBar and PDLabels, (\"PDL:\") + PDL, (Color.LIGHT_GRAY));

AddLabel (yes, PDFirstBar and PDLabels, (\"PDC:\") + PDC, (Color.LIGHT_GRAY))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

How do the events of normal aging affect life satisfaction?

Answered: 1 week ago