Volume Profile Indicator & POCs For ThinkOrSwim

I want to be able to highlight x amount of candles on my intraday chart and see the volume profile for the highlighted portion only. How can I do this?
 

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

I want to be able to highlight x amount of candles on my intraday chart and see the volume profile for the highlighted portion only. How can I do this?
Any suggestions of a good free charting platform that will allow me to do this?

tradingview.com will allow you, they have what's called "visible range" of the volume profile however you have to be at least a pro member which is $14.95 USD a month and keep in mind you need to pay for data as well on top of that if you want the data to be accurate.
 
Hi @Shinthus, here is another cog indicator https://usethinkscript.com/threads/center-of-gravity-cog-indicator-for-thinkorswim.138/ I think this might be the cog indicator you're looking for if you were in bluesgirl's chatroom. (I'm in the same room :) That's similar to what she uses. From what I understand with the cog indicator is you want to play the edges and also look at the curves of the waves. So if the waves are starting to curl up price may have found a bottom and start to move up. Maybe similar to boillinger bands.

As for volume profile here is a picture of the study I use on TOS. It looks at the volume profile for every individual day, so the levels are pretty much the same across all time frames. I can post the settings I have if you're interested :)

52B6GLo.png


I like to mark off the Value area Highs/Lows (the yellow lines) and the point of control (red line). I use these lines as support/resistance and targets for the next day.
On the other hand, I also need something where I can see 1 volume profile for last 20 days. I select 20 days in ToS and it shows me 20 different ones. I would like it to be one big volume profile. It seems to work fine for 1 year chart.
 
I'm definitely warming up to the "Last 10 POC" indicator by Mobius but I'm hoping to get some (possibly highly) technical guidance.

On his indicator, the POC's seem to extend indefinitely to the left.

The two things I'm seeking are:
1. how can I get, let's say, the POC from 5 days ago to begin at the end of the RTH session 5 days ago (but not go on further to the left).?
2. and, if that's possible, how can I get the bubble to display also at the origin point of the POC extension? (It already displays on the Right Edge.)

For anyone who wants to take a stab at this, I've included 2 sets of code below. First is Mobius's original script. Next 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. Maybe it could help to figure out how to do #1 and #2 above.

Sincere thanks to anyone who considers looking into this!!

cLKeaoU.png


The Mobius POC script:
Code:
declare Hide_On_Daily;

input RthBegin  = 0930; #hint RthBegin: Regular Trading Hours Begin.
input RthEnd    = 1600; #hint RthEnd: Regular Trading Hours End.
input AtrLength = 4;    #hint AtrLength: Length for Average True Range Calculation.
input RoundingFunction = .5; #hint RoundingFunction: Round to nearest ?
input MaxRisk = 2.00; #hint MaxRisk: Maximum Risk around pivots.

def o = open;
def h = high;
def l = low;
def c = close;
def ATR = HighestAll(if isNaN(c[-1])
    then if Average(TrueRange(h, c, l), AtrLength) < MaxRisk
         then Average(TrueRange(h, c, l), AtrLength)
         else MaxRisk
         else double.nan);
def locate = isNaN(close[13]) and !isNaN(close[14]);
def RTH = SecondsFromTime(RthBegin) > 0 and
          SecondsTillTime(RthEnd) >= 0;
def cond = RTH != RTH[1];
profile vol = VolumeProfile("startNewProfile" = cond,
                            "onExpansion" = no,
                            "numberOfProfiles" = 20,
                            "pricePerRow" = PricePerRow.TICKSIZE,
                            "value area percent" = 68.4);
def poc = if RTH
    then Round(vol.GetPointOfControl() / RoundingFunction, 0) * RoundingFunction
    else Double.NaN;
def Poc1 = if !RTH and RTH[1]
    then poc[1]
    else Poc1[1];
def Poc2 = if !RTH and RTH[1]
    then Poc1[1]
    else Poc2[1];
def Poc3 = if !RTH and RTH[1]
    then Poc2[1]
    else Poc3[1];
def Poc4 = if !RTH and RTH[1]
    then Poc3[1]
    else Poc4[1];
def Poc5 = if !RTH and RTH[1]
    then Poc4[1]
    else Poc5[1];
def Poc6 = if !RTH and RTH[1]
    then Poc5[1]
    else Poc6[1];
def Poc7 = if !RTH and RTH[1]
    then Poc6[1]
    else Poc7[1];
def Poc8 = if !RTH and RTH[1]
    then Poc7[1]
    else Poc8[1];
def Poc9 = if !RTH and RTH[1]
    then Poc8[1]
    else Poc9[1];
def Poc10 = if !RTH and RTH[1]
    then Poc9[1]
    else Poc10[1];
plot pc =  HighestAll(if isNaN(c[-1])
     then poc
     else double.nan);
     pc.SetStyle(Curve.Firm);
     pc.SetLineWeight(2);
addCloud(pc-ATR, pc+ATR, createColor(100,100,100), createColor(100,100,100));
addChartBubble(locate, pc, "POC", createColor(100,100,100), yes);
plot pc1 = HighestAll(if isNaN(c[-1])
     then Poc1
     else double.nan);
     pc1.SetStyle(Curve.Long_Dash);
addCloud(pc1-ATR, pc1+ATR, color.gray, color.gray);
addChartBubble(locate, pc1, "POC 1", createColor(100,100,100), yes);
plot pc2 = HighestAll(if isNaN(c[-1])
     then poc2
     else double.nan);
     pc2.SetStyle(Curve.Long_Dash);
addCloud(pc2-ATR, pc2+ATR, color.gray, color.gray);
addChartBubble(locate, pc2, "POC 2", createColor(100,100,100), yes);
plot pc3 = HighestAll(if isNaN(c[-1])
     then poc3
     else double.nan);
     pc3.SetStyle(Curve.Long_Dash);
addCloud(pc3-ATR, pc3+ATR, color.gray, color.gray);
addChartBubble(locate, pc3, "POC 3", createColor(100,100,100), yes);
plot pc4 = HighestAll(if isNaN(c[-1])
     then poc4
     else double.nan);
     pc4.SetStyle(Curve.Long_Dash);
addCloud(pc4-ATR, pc4+ATR, color.gray, color.gray);
addChartBubble(locate, pc4, "POC 4", createColor(100,100,100), yes);
plot pc5 = HighestAll(if isNaN(c[-1])
     then poc5
     else double.nan);
     pc5.SetStyle(Curve.Long_Dash);
addCloud(pc5-ATR, pc5+ATR, color.gray, color.gray);
addChartBubble(locate, pc5, "POC 5", createColor(100,100,100), yes);
plot pc6 = HighestAll(if isNaN(c[-1])
     then poc6
     else double.nan);
     pc6.SetStyle(Curve.Long_Dash);
addCloud(pc6-ATR, pc6+ATR, color.gray, color.gray);
addChartBubble(locate, pc6, "POC 6", createColor(100,100,100), yes);
plot pc7 = HighestAll(if isNaN(c[-1])
     then poc7
     else double.nan);
     pc7.SetStyle(Curve.Long_Dash);
addCloud(pc7-ATR, pc7+ATR, color.gray, color.gray);
addChartBubble(locate, pc7, "POC 7", createColor(100,100,100), yes);
plot pc8 = HighestAll(if isNaN(c[-1])
     then poc8
     else double.nan);
     pc8.SetStyle(Curve.Long_Dash);
addCloud(pc8-ATR, pc8+ATR, color.gray, color.gray);
addChartBubble(locate, pc8, "POC 8", createColor(100,100,100), yes);
plot pc9 = HighestAll(if isNaN(c[-1])
     then poc9
     else double.nan);
     pc9.SetStyle(Curve.Long_Dash);
addCloud(pc9-ATR, pc9+ATR, color.gray, color.gray);
addChartBubble(locate, pc9, "POC 9", createColor(100,100,100), yes);
plot pc10 = HighestAll(if isNaN(c[-1])
     then poc10
     else double.nan);
     pc10.SetStyle(Curve.Long_Dash);
addCloud(pc10-ATR, pc10+ATR, color.gray, color.gray);
addChartBubble(locate, pc10, "POC 10", createColor(100,100,100), yes);
pc.AssignValueColor(if (pc == pc1) or (pc == pc2) or (pc == pc3) or (pc == pc4) or (pc == pc5) or (pc == pc6) or (pc == pc7) or (pc == pc8) or (pc == pc9) or (pc == pc10) then color.dark_green else color.orange);
pc1.AssignValueColor(if (pc1 == pc) or (pc1 == pc2) or (pc1 == pc3) or (pc1 == pc4) or (pc1 == pc5) or (pc1 == pc6) or (pc1 == pc7) or (pc1 == pc8) or (pc1 == pc9) or (pc1 == pc10) then color.dark_green else color.orange);
pc2.AssignValueColor(if (pc2 == pc) or (pc2 == pc1) or (pc2 == pc3) or (pc2 == pc4) or (pc2 == pc5) or (pc2 == pc6) or (pc2 == pc7) or (pc2 == pc8) or (pc2 == pc9) or (pc2 == pc10) then color.dark_green else color.orange);
pc3.AssignValueColor(if (pc3 == pc) or (pc3 == pc1) or (pc3 == pc2) or (pc3 == pc4) or (pc3 == pc5) or (pc3 == pc6) or (pc3 == pc7) or (pc3 == pc8) or (pc3 == pc9) or (pc3 == pc10) then color.dark_green else color.orange);
pc4.AssignValueColor(if (pc4 == pc) or (pc4 == pc1) or (pc4 == pc2) or (pc4 == pc3) or (pc4 == pc5) or (pc4 == pc6) or (pc4 == pc7) or (pc4 == pc8) or (pc4 == pc9) or (pc4 == pc10) then color.dark_green else color.orange);
pc5.AssignValueColor(if (pc5 == pc) or (pc5 == pc1) or (pc5 == pc2) or (pc5 == pc3) or (pc5 == pc4) or (pc5 == pc6) or (pc5 == pc7) or (pc5 == pc8) or (pc5 == pc9) or (pc5 == pc10) then color.dark_green else color.orange);
pc6.AssignValueColor(if (pc6 == pc) or (pc6 == pc1) or (pc6 == pc2) or (pc6 == pc3) or (pc6 == pc4) or (pc6 == pc5) or (pc6 == pc7) or (pc6 == pc8) or (pc6 == pc9) or (pc6 == pc10) then color.dark_green else color.orange);
pc7.AssignValueColor(if (pc7 == pc) or (pc7 == pc1) or (pc7 == pc2) or (pc7 == pc3) or (pc7 == pc4) or (pc7 == pc5) or (pc7 == pc6) or (pc7 == pc8) or (pc7 == pc9) or (pc7 == pc10) then color.dark_green else color.orange);
pc8.AssignValueColor(if (pc8 == pc) or (pc8 == pc1) or (pc8 == pc2) or (pc8 == pc3) or (pc8 == pc4) or (pc8 == pc5) or (pc8 == pc6) or (pc8 == pc7) or (pc8 == pc9) or (pc8 == pc10) then color.dark_green else color.orange);
pc9.AssignValueColor(if (pc9 == pc) or (pc9 == pc1) or (pc9 == pc2) or (pc9 == pc3) or (pc9 == pc4) or (pc9 == pc5) or (pc9 == pc6) or (pc9 == pc7) or (pc9 == pc8) or (pc9 == pc10) then color.dark_green else color.orange);
pc10.AssignValueColor(if (pc10 == pc) or (pc10 == pc1) or (pc10 == pc2) or (pc10 == pc3) or (pc10 == pc4) or (pc10 == pc5) or (pc10 == pc6) or (pc10 == pc7) or (pc10 == pc8) or (pc10 == pc9) then color.dark_green else color.orange);

The other (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
###############
 
I'm definitely warming up to the "Last 10 POC" indicator by Mobius but I'm hoping to get some (possibly highly) technical guidance.

On his indicator, the POC's seem to extend indefinitely to the left.

The two things I'm seeking are:
1. how can I get, let's say, the POC from 5 days ago to begin at the end of the RTH session 5 days ago (but not go on further to the left).?
2. and, if that's possible, how can I get the bubble to display also at the origin point of the POC extension? (It already displays on the Right Edge.)

For anyone who wants to take a stab at this, I've included 2 sets of code below. First is Mobius's original script. Next 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. Maybe it could help to figure out how to do #1 and #2 above.

Sincere thanks to anyone who considers looking into this!!


See if this is what you wanted:

Code:
# Points Of Control Support / Resistance Areas
# Mobius
# V01.03.08.2016
# Locates last 10 Points of Control based on RTH only

#
# Modified version 1 by Sleepz - Usethinkscript request: The two things I'm seeking are:
# 1. how can I get, let's say, the POC from 5 days ago to begin at the end of the RTH session 5 days ago (but not go on further to the left).?
# 2. and, if that's possible, how can I get the bubble to display also at the origin point of the POC extension? (It already displays on the Right Edge.)
# Added an option to extend the POC's based upon the POC for each day during RTH based upon ticksize(), rounded to 2 digits rather than Mobius's smoothed approach
# Added a #VolumeProfile_RTH_ext script that I did quite awhile ago to help test the modified script. One can display it or not at the 'input showVOLProfile_RTH_ext'. It also can be removed after testing if not wanted.

declare hide_on_daily;

input UseRoundingFunction = yes; #hint UseRoundingFunction: Select YES (Mobius default)to use POC based upon Mobius' RoundingFunction input and RoundingDigit; NO to use POC for each day during RTH based upon ticksize(), rounded to 2 digits
input RoundingFunction = 0.5; #hint RoundingFunction: Round to nearest ?
input RoundingDigit    = 0;
input RthBegin  = 0930; #hint RthBegin: Regular Trading Hours Begin.
input RthEnd    = 1600; #hint RthEnd: Regular Trading Hours End.
input AtrLength = 4;    #hint AtrLength: Length for Average True Range Calculation.
input MaxRisk = 2.00; #hint MaxRisk: Maximum Risk around pivots.
def o = open;
def h = high;
def l = low;
def c = close;
def RTH = SecondsFromTime(RthBegin) > 0 and SecondsTillTime(RthEnd) >= 0;
def cond = RTH != RTH[1];
def last = if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else last[1];

def capture  = CompoundValue(1, if BarNumber() > HighestAll(last) then 0 else if SecondsFromTime(1600) == 0 then capture[1] + 1 else capture[1], 0);
def dayCount = CompoundValue(1, if capture != capture[1] then dayCount[1] + 1 else dayCount[1], 0);
def thisDay  = (HighestAll(dayCount) - dayCount) ;


def ATR = HighestAll(if IsNaN(c[-1])
          then if Average(TrueRange(h, c, l), AtrLength) < MaxRisk
          then Average(TrueRange(h, c, l), AtrLength)
          else MaxRisk
          else Double.NaN);


profile vol = VolumeProfile("startNewProfile" = cond,
                            "onExpansion" = no,
                            "numberOfProfiles" = 20,
                            "pricePerRow" = PricePerRow.TICKSIZE,
                            "value area percent" = 68.4);

def poc = if RTH or thisDay == 1
    then if UseRoundingFunction == yes then Round(vol.GetPointOfControl() / RoundingFunction, RoundingDigit) * RoundingFunction else Round(vol.GetPointOfControl(), 2)
    else Double.NaN;
def Poc1 = if UseRoundingFunction == yes and !RTH and RTH[1]
    then poc[1] else if UseRoundingFunction == no and thisDay == 2 and RTH then poc
    else Poc1[1];
def Poc2 = if UseRoundingFunction == yes and !RTH and RTH[1]
    then Poc1[1] else if UseRoundingFunction == no and thisDay == 3 and RTH then poc
    else Poc2[1];
def Poc3 = if UseRoundingFunction == yes and !RTH and RTH[1]
    then Poc2[1]  else if UseRoundingFunction == no and thisDay == 4 and RTH then poc
    else Poc3[1];
def Poc4 = if UseRoundingFunction == yes and !RTH and RTH[1]
    then Poc3[1]  else if UseRoundingFunction == no and thisDay == 5 and RTH then poc
    else Poc4[1];
def Poc5 = if UseRoundingFunction == yes and !RTH and RTH[1]
    then Poc4[1]  else if  UseRoundingFunction == no and thisDay == 6 and RTH then poc
    else Poc5[1];


plot pc =  if thisDay > 1 then Double.NaN else HighestAll(if IsNaN(c[-1])
           then poc
           else Double.NaN);
pc.SetStyle(Curve.FIRM);
pc.SetLineWeight(2);
AddCloud(pc - ATR, pc + ATR, CreateColor(100, 100, 100), CreateColor(100, 100, 100));
AddChartBubble(BarNumber() == HighestAll(BarNumber()), pc, "POC", CreateColor(100, 100, 100), yes);
plot pc1 = if thisDay > 1 then Double.NaN else HighestAll(if IsNaN(c[-1])
     then Poc1
     else Double.NaN);
pc1.SetStyle(Curve.LONG_DASH);
AddCloud(pc1 - ATR, pc1 + ATR, Color.GRAY, Color.GRAY);
AddChartBubble(thisDay == 1 and thisDay[1] == 2, pc1, "POC 1", CreateColor(100, 100, 100), yes);
plot pc2 = if thisDay > 2 then Double.NaN else HighestAll(if IsNaN(c[-1])
     then Poc2
     else Double.NaN);
pc2.SetStyle(Curve.LONG_DASH);
AddCloud(pc2 - ATR, pc2 + ATR, Color.GRAY, Color.GRAY);
AddChartBubble(thisDay == 2 and thisDay[1] == 3, pc2, "POC 2", CreateColor(100, 100, 100), yes);
plot pc3 = if thisDay > 3 then Double.NaN else HighestAll(if IsNaN(c[-1])
     then Poc3
     else Double.NaN);
pc3.SetStyle(Curve.LONG_DASH);
AddCloud(pc3 - ATR, pc3 + ATR, Color.GRAY, Color.GRAY);
AddChartBubble(thisDay == 3 and thisDay[1] == 4, pc3, "POC 3", CreateColor(100, 100, 100), yes);
plot pc4 = if thisDay > 4 then Double.NaN else HighestAll(if IsNaN(c[-1])
     then Poc4
     else Double.NaN);
pc4.SetStyle(Curve.LONG_DASH);
AddCloud(pc4 - ATR, pc4 + ATR, Color.GRAY, Color.GRAY);
AddChartBubble(thisDay == 4 and thisDay[1] == 5, pc4, "POC 4", CreateColor(100, 100, 100), yes);
plot pc5 = if thisDay > 5 then Double.NaN else HighestAll(if IsNaN(c[-1])
     then Poc5
     else Double.NaN);
pc5.SetStyle(Curve.LONG_DASH);
AddCloud(pc5 - ATR, pc4 + ATR, Color.GRAY, Color.GRAY);
AddChartBubble(thisDay == 5 and thisDay[1] == 6, pc5, "POC 5", CreateColor(100, 100, 100), yes);

pc.AssignValueColor(if (pc == pc1) or (pc == pc2) or (pc == pc3) or (pc == pc4) or (pc == pc5)    then Color.DARK_GREEN else Color.ORANGE);
pc1.AssignValueColor(if (pc1 == pc) or (pc1 == pc2) or (pc1 == pc3) or (pc1 == pc4) or (pc1 == pc5) then Color.DARK_GREEN else Color.ORANGE);
pc2.AssignValueColor(if (pc2 == pc) or (pc2 == pc1) or (pc2 == pc3) or (pc2 == pc4) or (pc2 == pc5) then Color.DARK_GREEN else Color.ORANGE);
pc3.AssignValueColor(if (pc3 == pc) or (pc3 == pc1) or (pc3 == pc2) or (pc3 == pc4) or (pc3 == pc5) then Color.DARK_GREEN else Color.ORANGE);
pc4.AssignValueColor(if (pc4 == pc) or (pc4 == pc1) or (pc4 == pc2) or (pc4 == pc3) or (pc4 == pc5) then Color.DARK_GREEN else Color.ORANGE);
pc5.AssignValueColor(if (pc5 == pc) or (pc5 == pc1) or (pc5 == pc2) or (pc5 == pc3) or (pc5 == pc4) then Color.DARK_GREEN else Color.ORANGE);


#VolumeProfile_RTH_ext
input showVOLProfile_RTH_ext = no;

profile vola = VolumeProfile("startNewProfile" = cond and SecondsTillTime(RthEnd) >= 0, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = PricePerRow.TICKSIZE);

def pca      = if IsNaN(vola.GetPointOfControl())   then pca[1] else vola.GetPointOfControl();
def hVA      = if IsNaN(vola.GetHighestValueArea()) then hVA[1] else vola.GetHighestValueArea();
def lVA      = if IsNaN(vola.GetLowestValueArea())  then lVA[1] else vola.GetLowestValueArea();

def poc_ = if !RTH or IsNaN(close) then poc_[1] else pca;
def ub  = if !RTH or IsNaN(close) then ub[1]  else hVA;
def lb  = if !RTH or IsNaN(close) then lb[1]  else lVA;

plot VPOC = if showVOLProfile_RTH_ext == no then Double.NaN else poc_;
plot VAH  = if showVOLProfile_RTH_ext == no then Double.NaN else ub;
plot VAL  = if showVOLProfile_RTH_ext == no then Double.NaN else lb;

VPOC.SetDefaultColor(Color.MAGENTA);
VAH.SetDefaultColor(Color.WHITE);
VAL.SetDefaultColor(Color.WHITE);
VPOC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

def showpointofcontrol = if showVOLProfile_RTH_ext == no then no else yes;
def showvaluearea      = if showVOLProfile_RTH_ext == no then no else yes;
def opacity            = if showVOLProfile_RTH_ext == no then 0 else 50;

vola.Show(Color.CYAN, if showpointofcontrol then Color.CYAN else Color.CURRENT, if showvaluearea then Color.YELLOW else Color.CURRENT, opacity);

profile volb = VolumeProfile("startNewProfile" = cond, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = PricePerRow.TICKSIZE);


def hProfile = if IsNaN(volb.GetHighest()) then hProfile[1] else volb.GetHighest();
def lProfile = if IsNaN(volb.GetLowest())  then lProfile[1] else volb.GetLowest();
def uprof    = if !RTH or IsNaN(close) then uprof[1] else hProfile;
def lprof    = if !RTH or IsNaN(close) then lprof[1] else lProfile;

plot ProfileHigh =  if showVOLProfile_RTH_ext == no then Double.NaN else uprof;
plot ProfileLow  =  if showVOLProfile_RTH_ext == no then Double.NaN else lprof;

ProfileHigh.SetDefaultColor(Color.GREEN);
ProfileLow.SetDefaultColor(Color.RED);
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
Last edited:
Anyway I can plot yesterday Volume Profile on today's trading day?
See if this helps
Code:
#VolumeProfile_PreviousDay_displayed_NextDay
#20190426 Sleepyz
#20210712 Sleepyz - revised to add option for pricePerRowHeightMode rather than just automatic

input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
case CUSTOM:
    height = customRowHeight;
}
input timePerProfile = {CHART, MINUTE, HOUR, default DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input profiles = 1000;
input valueAreaPercent = 70;

def period;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def dom = GetDayOfMonth(yyyymmdd);
def dow = GetDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
switch (timePerProfile) {
case CHART:
    period = 0;
case MINUTE:
    period = Floor(seconds / 60 + day_number * 24 * 60);
case HOUR:
    period = Floor(seconds / 3600 + day_number * 24);
case DAY:
    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
    period = Floor(day_number / 7);
case MONTH:
    period = Floor(month - First(month));
case "OPT EXP":
    period = exp_opt - First(exp_opt);
case BAR:
    period = BarNumber() - 1;
}

def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1], 0);
def cond = count < count[1] + period - period[1];
profile vol = VolumeProfile("startNewProfile" = cond, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent, onExpansion = no);

#Prior Day High/Low ValueAreas
def HVA = if IsNaN(vol.GetHighestValueArea()) then HVA[1] else vol.GetHighestValueArea();
def pHVA = CompoundValue(1, if cond then HVA[1] else pHVA[1], Double.NaN);
def LVA = if IsNaN(vol.GetLowestValueArea()) then LVA[1] else vol.GetLowestValueArea();
def pLVA = CompoundValue(1, if cond then LVA[1] else pLVA[1], Double.NaN);

plot PrevHVA = pHVA;
plot PrevLVA = pLVA;
PrevHVA.SetDefaultColor(Color.YELLOW);
PrevLVA.SetDefaultColor(Color.YELLOW);
PrevHVA.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevLVA.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

#Prior Day POC Calculated
def POC = if IsNaN(vol.GetPointOfControl()) and cond then POC[1] else vol.GetPointOfControl();
def pPOC = CompoundValue (1, if cond then POC[1] else pPOC[1], Double.NaN);

plot PrevPOC = pPOC;
PrevPOC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevPOC.SetDefaultColor(Color.MAGENTA);
 
Last edited:
See if this helps
Code:
#VolumeProfile_PreviousDay_displayed_NextDau
#20190426 Sleepyz

def height = PricePerRow.AUTOMATIC;
input timePerProfile = {CHART, MINUTE, HOUR, default DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input profiles = 1000;
input valueAreaPercent = 70;

def period;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def dom = GetDayOfMonth(yyyymmdd);
def dow = GetDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
switch (timePerProfile) {
case CHART:
    period = 0;
case MINUTE:
    period = Floor(seconds / 60 + day_number * 24 * 60);
case HOUR:
    period = Floor(seconds / 3600 + day_number * 24);
case DAY:
    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
    period = Floor(day_number / 7);
case MONTH:
    period = Floor(month - First(month));
case "OPT EXP":
    period = exp_opt - First(exp_opt);
case BAR:
    period = BarNumber() - 1;
}

def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1], 0);
def cond = count < count[1] + period - period[1];
profile vol = VolumeProfile("startNewProfile" = cond, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent, onExpansion = no);

#Prior Day High/Low ValueAreas
def HVA = if IsNaN(vol.GetHighestValueArea()) then HVA[1] else vol.GetHighestValueArea();
def pHVA = CompoundValue(1, if cond then HVA[1] else pHVA[1], Double.NaN);
def LVA = if IsNaN(vol.GetLowestValueArea()) then LVA[1] else vol.GetLowestValueArea();
def pLVA = CompoundValue(1, if cond then LVA[1] else pLVA[1], Double.NaN);

plot PrevHVA = pHVA;
plot PrevLVA = pLVA;
PrevHVA.SetDefaultColor(Color.YELLOW);
PrevLVA.SetDefaultColor(Color.YELLOW);
PrevHVA.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevLVA.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

#Prior Day POC Calculated
def POC = if IsNaN(vol.GetPointOfControl()) and cond then POC[1] else vol.GetPointOfControl();
def pPOC = CompoundValue (1, if cond then POC[1] else pPOC[1], Double.NaN);

plot PrevPOC = pPOC;
PrevPOC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PrevPOC.SetDefaultColor(Color.MAGENTA);
Nope. That just displays 3 lines on each day. One being VPOC, and not sure what other 2 are.. but definitely doesn't look like a volume profile plot
 
Nope. That just displays 3 lines on each day. One being VPOC, and not sure what other 2 are.. but definitely doesn't look like a volume profile plot
The 'other 2' lines are Value Area High and Value Area Low. Those along with the VPOC you correctly identified are the prior day's levels displayed on the next day's chart.
 
The 'other 2' lines are Value Area High and Value Area Low. Those along with the VPOC you correctly identified are the prior day's levels displayed on the next day's chart.
I'm looking for a volume PROFILE of the previous day to be plotted on the current day's chart. Don't really care for the VAH/VAL/VPOC.
 
Hey all,
I've been messing with the "RTHvsOvernight Profile by JoeBone87 (as below). Ive been trying to get the POC to plot a continuous vertical line for the selected range similar to the Mobius "Points Of Control Support / Resistance Areas" (Last 10 POC) but i can't firure out how to reference the existing POC without making it plot a 2nd profile. TOS profiles ****.
I have a 2nd, lesser dilemma. I'd like to do the same thing with the VAL/VAH lines until they are invalidated in the same way one would traditionally handle a VPOC.
Anyway. Thanks in advance.




Code:
#VolumeProfile_RTHvOvernight
#JoeBone87 in TSL May 2019 (No Guarantee it will plot but math should be good)

input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE, CUSTOM};
input customRowHeight = 0.25;
input onExpansion = no;
input profiles = 100;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 30;

input rthbegin  = 0930;
input rthend    = 1700;
def count = secondsfromTime(rthbegin) >= 0 and secondstillTime(rthend) > 0;
def cond = count != count[1];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
height = PricePerRow.AUTOMATIC;
case TICKSIZE:
height = PricePerRow.TICKSIZE;
case CUSTOM:
height = customRowHeight;
}

profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = CompoundValue(1, onExpansion, no);
def pc = if IsNaN(vol.GetPointOfControl()) and con then pc[1] else vol.GetPointOfControl();
def hVA = if IsNaN(vol.GetHighestValueArea()) and con then hVA[1] else vol.GetHighestValueArea();
def lVA = if IsNaN(vol.GetLowestValueArea()) and con then lVA[1] else vol.GetLowestValueArea();

def hProfile = if IsNaN(vol.GetHighest()) and con then hProfile[1] else vol.GetHighest();
def lProfile = if IsNaN(vol.GetLowest()) and con then lProfile[1] else vol.GetLowest();
def plotsDomain = IsNaN(close) == onExpansion;

plot POC = if plotsDomain then pc else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile else Double.NaN;
plot VAHigh = if plotsDomain then hVA else Double.NaN;
plot VALow = if plotsDomain then lVA else Double.NaN;

DefineGlobalColor("Profile", GetColor(1));
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", GetColor(8));

vol.Show(GlobalColor("Profile"), if showPointOfControl then GlobalColor("Point Of Control") else Color.CURRENT, if showValueArea then GlobalColor("Value Area") else Color.CURRENT, opacity);
POC.SetDefaultColor(GlobalColor("Point Of Control"));
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetDefaultColor(GlobalColor("Value Area"));
VALow.SetDefaultColor(GlobalColor("Value Area"));
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.Hide();
ProfileLow.Hide();

input bubbles = yes;
input n  = 2;
def   n1 = n + 1;
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), VAHigh[n1], "V-VAH", color = Color.YELLOW, yes);
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), VALow[n1], "V-VAL", Color.YELLOW, no);
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), POC[n1], "V-POC", Color.RED, no);
 
You people really want this? Just a moving average that can be duplicated by using the already existing SMA or EMA in ToS. Here is the POC avg compared to 100 length SMA and EMA.

MAc10QM.png


I doubt it is worth the trouble. If you have a POC that is plotted each day just add something like this :

Code:
input length =20;
plot smapoc =  simpleMovingAvg (poc, length);

Adjust length to fit what you want.
Hello @horserider - when I load the study to TOS -it gives me the following errors:

Expected double at 2:16
No such variable: poc at 2:33
Expected double at 2:16
No such variable: poc at 2:33

Can you please work on it when you have a chance
 
Hello @horserider - when I load the study to TOS -it gives me the following errors:

Expected double at 2:16
No such variable: poc at 2:33
Expected double at 2:16
No such variable: poc at 2:33

Can you please work on it when you have a chance

That is only an add-on, not the entire script... Use one of the scripts at the beginning of the topic...
 
@Ninja Bull Is it possible you did not follow @horserider's instructions? She said:
XqS3pTh.png

Did you start w/ your POC study and ADD the snippet of code to it. Perhaps you didn't add it to the end of the study?
It is not possible to offer additional help w/o seeing the whole script that you created and include screenshots of the errors (how to upload an image)
 
Last edited:
I am interested to learn how the change in Point of Control of volume profile affects the price change. Is there a way we can plot the Point of Control history as a graph in thinkorswim?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
273 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