Multi-plot Market Lines For ThinkOrSwim

RickK

Active member
This is a script created by someone else that plots previous day highs/lows, current day highs/lows, current day open, yesterday close, etc. .... and includes bubbles for each. Its code displays a line from when it began AND allows for both having bubbles at the origin point AND on the Right Edge.

The (Multi Plot) script:
Code:
# Custom Multi Plot ThinkScript by 7of9 for BRT
# Modifed by RK for colored bubbles and bubbles on Right Edge
# and changed Plot...LinesPastOpen to 8hrs from 0
# edited 3/5/19

# Inputs
input PlotPreMktLinesHrsPastOpen = 4;
input PlotRegMktLinesHrsPastOpen = 0;
input PlotYesterdayMktLinesHrsPastOpen = 0;
input PlotActiveRegMktLinesOnPrevDays = 0;
input DisplayPreMarketPriceBubbles = yes;
input DisplayCurrentDayPriceBubbles = yes;
input DisplayPreviousDayPriceBubbles = yes;
input DisplayPreMarketPriceBubblesRightEdge = no;
input DisplayCurrentDayPriceBubblesRightEdge = no;
input DisplayPreviousDayPriceBubblesRightEdge = no;

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

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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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 (116, 189, 232));
PDH.SetStyle (Curve.SHORT_DASH);

#Previous day low code
def HidePDL = if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN then yes else no;

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 (116, 189, 232));
PDL.SetStyle (Curve.SHORT_DASH);

#Previous day close code
def HidePDC = if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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 PMBubbles = if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN then DisplayPreMarketPriceBubbles else no;
AddChartBubble (PMopenBar and PMBubbles, PMO, ("PMO:") + PMO,
CreateColor (234, 136, 255));
AddChartBubble (highBar and PMBubbles, PMH, ("PMH:") + PMH,
CreateColor (116, 189, 232));
AddChartBubble (lowBar and PMBubbles, PML, ("PML:") + PML,
CreateColor (116, 189, 232), no);

###############
################edited by rk .. ADDING PRICE PM BUBBLES RIGHT EDGE
AddChartBubble(BarNumber() == HighestAll(BarNumber()) and
DisplayPreMarketPriceBubblesRightEdge, PMO, "PMO:" + PMO, CreateColor(234, 136, 255), no);

AddChartBubble(BarNumber() == HighestAll(BarNumber()) and
DisplayPreMarketPriceBubblesRightEdge, PMH, "PMH:" + PMH, CreateColor(116, 189, 232), no);

AddChartBubble(BarNumber() == HighestAll(BarNumber()) and
DisplayPreMarketPriceBubblesRightEdge, PML, "PML:" + PML, CreateColor(116, 189, 232), no);

###############end edit by rk
###############

#Current day bubbles code
def CDBubbles = if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN then DisplayCurrentDayPriceBubbles else no;

def CDFirstBar = SecondsFromTime (0800) >= 0 and SecondsFromTime (0800) < 60;
AddChartBubble (CDFirstBar and CDBubbles, CDO, ("CDO:") + CDO,
CreateColor (255, 255, 255));

AddChartBubble (CDFirstBar and CDBubbles, CDH, ("CDH:") + CDH,
CreateColor (0, 255, 0));

AddChartBubble (CDFirstBar and CDBubbles, CDL, ("CDL:") + CDL,
CreateColor (255, 0, 0), no);

###############
################edited by rk .. ADDING PRICE CD BUBBLES RIGHT EDGE
AddChartBubble(BarNumber() == HighestAll(BarNumber()) and
DisplayCurrentDayPriceBubblesRightEdge, CDO, "CDO:" + CDO, CreateColor(255, 255, 255), no);

AddChartBubble(BarNumber() == HighestAll(BarNumber()) and
DisplayCurrentDayPriceBubblesRightEdge, CDH, "CDH:" + CDH, CreateColor(0, 255, 0), no);

AddChartBubble(BarNumber() == HighestAll(BarNumber()) and
DisplayCurrentDayPriceBubblesRightEdge, CDL, "CDL:" + CDL, CreateColor(255, 0, 0), no);

################end edit by rk
###############

#Previous day bubbles code
def PDBubbles = if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN then DisplayPreviousDayPriceBubbles else no;

def PDFirstBar = SecondsFromTime (0700) >= 0 and SecondsFromTime (0700) < 60;

AddChartBubble (PDFirstBar and PDBubbles, PDH, ("PDH:") + PDH,
CreateColor (116, 189, 232));

AddChartBubble (PDFirstBar and PDBubbles, PDL, ("PDL:") + PDL,
CreateColor (116, 189, 232), no);

AddChartBubble (PDFirstBar and PDBubbles, PDC, ("PDC:") + PDC,
CreateColor (231, 190, 0));

###############
################edited by rk .. ADDING PRICE PD BUBBLES RIGHT EDGE
AddChartBubble(BarNumber() == HighestAll(BarNumber()) and
DisplayCurrentDayPriceBubblesRightEdge, PDH, "PDH:" + PDH, CreateColor(116, 189, 232), no);

AddChartBubble(BarNumber() == HighestAll(BarNumber()) and
DisplayCurrentDayPriceBubblesRightEdge, PDL, "PDL:" + PDL, CreateColor(116, 204, 232), no);

AddChartBubble(BarNumber() == HighestAll(BarNumber()) and
DisplayCurrentDayPriceBubblesRightEdge, PDC, "PDC:" + PDC, CreateColor(231, 190, 0), no);

################end edit by rk
###############
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I have this plot and I wanted to see if you "big brains" out there can improve it.
Ruby:
# Custom Multi Plot ThinkScript by 7of9 for BRT
# Modifed by RK for colored bubbles and bubbles on Right Edge
# and changed Plot...LinesPastOpen to 8hrs from 0
# edited 3/5/19

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

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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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() <= AggregationPeriod.FIFTEEN_MIN then yes else no;
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 PMBubbles = if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN then DisplayPreMarketPriceBubbles else no;

AddChartBubble (PMopenBar and PMBubbles, PMO, ("PMO:") + PMO,
CreateColor (204, 204, 255));

AddChartBubble (highBar and PMBubbles, PMH, ("PMH:") + PMH,
CreateColor (204, 204, 255));

AddChartBubble (lowBar and PMBubbles, PML, ("PML:") + PML,
CreateColor (204, 204, 255), no);

#Current day bubbles code
def CDBubbles = if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN then DisplayCurrentDayPriceBubbles else no;
def CDFirstBar = SecondsFromTime (0800) >= 0 and SecondsFromTime (0800) < 60;

AddChartBubble (CDFirstBar and CDBubbles, CDO, ("CDO:") + CDO,
CreateColor (204, 204, 255));

AddChartBubble (CDFirstBar and CDBubbles, CDH, ("CDH:") + CDH,
CreateColor (204, 204, 255));

AddChartBubble (CDFirstBar and CDBubbles, CDL, ("CDL:") + CDL,
CreateColor (204, 204, 255), no);

#Previous day bubbles code
def PDBubbles = if GetAggregationPeriod() <= AggregationPeriod.FIFTEEN_MIN then DisplayPreviousDayPriceBubbles else no;
def PDFirstBar = SecondsFromTime (0700) >= 0 and SecondsFromTime (0700) < 60;

AddChartBubble (PDFirstBar and PDBubbles, PDH, ("PDH:") + PDH,
CreateColor (204, 204, 255));

AddChartBubble (PDFirstBar and PDBubbles, PDL, ("PDL:") + PDL,
CreateColor (204, 204, 255), no);

AddChartBubble (PDFirstBar and PDBubbles, PDC, ("PDC:") + PDC,
CreateColor (204, 204, 255));
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
380 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top