• LIMITED TIME OFFER: use coupon code PRIMEDAY at checkout to save $50 off VIP membership (down to $149 / year). Valid through Tuesday 6/22.

Volume Profile and POC (Point of Control) Scripts

Jmp2626

New member
2019 Donor
VIP
Also would like to post historical POC (Point of Control) to follow average POC.

Code:
# plots POC, VAH and VAL for profiles starting at RTH Open and ending 1,2,3 etc bars later
# Not a realistic solution to the problem
# Nube

def bn = BarNumber();
def na = Double.NaN;

script TestPro {
input Start = 1;
input nBars = 3;
def bn    = BarNumber();
def na    = Double.NaN;
def EndBar        = if   bn == start + nBars
                    then bn else endBar[1];
def NewProfile    = bn == start or
                    bn crosses above endBar;

profile testProfile = VolumeProfile("startNewProfile" = NewProfile
, "onExpansion" = no, "numberOfProfiles" = 1000, "pricePerRow" = TickSize(), "value area percent" = 68);

plot hva = if   bn == EndBar
           then testProfile.GetHighestValueArea()
           else na;
plot lva = if   bn == EndBar
           then testProfile.GetLowestValueArea()
           else na;
plot poc = if   bn == EndBar
           then testProfile.GetPointOfControl()
           else na;
}
def RTHOpen = GetDay() == GetLastDay() &&
              GetTime() crosses above
              RegularTradingStart(GetYYYYMMDD());
def RTHBar = CompoundValue(1,
             if   RTHOpen
             then bn
             else RTHBar[1],0);


def hva =
if  bn == RTHBar + 1 then TestPro(RTHBar,1).hva else
if  bn == RTHBar + 2 then TestPro(RTHBar,2).hva else
if  bn == RTHBar + 3 then TestPro(RTHBar,3).hva else
if  bn == RTHBar + 4 then TestPro(RTHBar,4).hva else
if  bn == RTHBar + 5 then TestPro(RTHBar,5).hva else
if  bn == RTHBar + 6 then TestPro(RTHBar,6).hva else
if  bn == RTHBar + 7 then TestPro(RTHBar,7).hva else
if  bn == RTHBar + 8 then TestPro(RTHBar,8).hva else
if  bn == RTHBar + 9 then TestPro(RTHBar,9).hva else
if  bn == RTHBar + 10 then TestPro(RTHBar,10).hva else
if  bn == RTHBar + 11 then TestPro(RTHBar,11).hva else
if  bn == RTHBar + 12 then TestPro(RTHBar,12).hva else
if  bn == RTHBar + 13 then TestPro(RTHBar,13).hva else
if  bn == RTHBar + 14 then TestPro(RTHBar,14).hva else
na;

def lva =
if  bn == RTHBar + 1 then TestPro(RTHBar,1).lva else
if  bn == RTHBar + 2 then TestPro(RTHBar,2).lva else
if  bn == RTHBar + 3 then TestPro(RTHBar,3).lva else
if  bn == RTHBar + 4 then TestPro(RTHBar,4).lva else
if  bn == RTHBar + 5 then TestPro(RTHBar,5).lva else
if  bn == RTHBar + 6 then TestPro(RTHBar,6).lva else
if  bn == RTHBar + 7 then TestPro(RTHBar,7).lva else
if  bn == RTHBar + 8 then TestPro(RTHBar,8).lva else
if  bn == RTHBar + 9 then TestPro(RTHBar,9).lva else
if  bn == RTHBar + 10 then TestPro(RTHBar,10).lva else
if  bn == RTHBar + 11 then TestPro(RTHBar,11).lva else
if  bn == RTHBar + 12 then TestPro(RTHBar,12).lva else
if  bn == RTHBar + 13 then TestPro(RTHBar,13).lva else
if  bn == RTHBar + 14 then TestPro(RTHBar,14).lva else
na;

def poc =
if  bn == RTHBar + 1 then TestPro(RTHBar,1).poc else
if  bn == RTHBar + 2 then TestPro(RTHBar,2).poc else
if  bn == RTHBar + 3 then TestPro(RTHBar,3).poc else
if  bn == RTHBar + 4 then TestPro(RTHBar,4).poc else
if  bn == RTHBar + 5 then TestPro(RTHBar,5).poc else
if  bn == RTHBar + 6 then TestPro(RTHBar,6).poc else
if  bn == RTHBar + 7 then TestPro(RTHBar,7).poc else
if  bn == RTHBar + 8 then TestPro(RTHBar,8).poc else
if  bn == RTHBar + 9 then TestPro(RTHBar,9).poc else
if  bn == RTHBar + 10 then TestPro(RTHBar,10).poc else
if  bn == RTHBar + 11 then TestPro(RTHBar,11).poc else
if  bn == RTHBar + 12 then TestPro(RTHBar,12).poc else
if  bn == RTHBar + 13 then TestPro(RTHBar,13).poc else
if  bn == RTHBar + 14 then TestPro(RTHBar,14).poc else
na;

plot
LoVA = if   bn > HighestAll(RTHBar)
       then lva else na;
plot
HiVA = if   bn > HighestAll(RTHBar)
       then hva else na;
plot
PointOfControl = if   bn > HighestAll(RTHBar)
                 then poc else na;

LoVA.SetDefaultColor(Color.Violet);
LoVA.SetStyle(Curve.Long_Dash);
LoVA.EnableApproximation();
HiVA.SetStyle(Curve.Long_Dash);
HiVA.SetDefaultColor(Color.Violet);
HiVA.EnableApproximation();
PointOfControl.SetDefaultColor(Color.Yellow);
PointOfControl.EnableApproximation();
 

Jmp2626

New member
2019 Donor
VIP
Plots the average POC for all Chart Data. Can be used as boundaries for likely price range intraday.

Code:
# Average Point OF Control (POC) with Standard Deviation Bands
# Mobius
# V01.09.2018
# Plots the average point of control value and standard deviation for high and low price as bands around the average POC.

input SD_Multiplier = 2;

def h = high;
def l = low;
def x = BarNumber();
def RTHBar1 = if getTime() crosses above RegularTradingStart(getYYYYMMDD())
              then x
              else Double.NaN;
def cond = x == (RTHBar1);
profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no, "numberOfProfiles" = 100, "pricePerRow" = PricePerRow.TICKSIZE, "value area percent" = 68);
def pc = if IsNaN(vol.GetPointOfControl())
         then pc[1]
         else vol.GetPointOfControl();
def sumPc = if !isNaN(RTHbar1)
            then sumPC[1] + pc[1]
            else sumPc[1];
def sumD = if !isNaN(RTHbar1)
           then sumD[1] + 1
           else sumD[1];
def SDH = if isNaN(StDevAll(h))
          then SDH[1]
          else StDevAll(h);
def SDL = if isNaN(StDevAll(l))
          then SDL[1]
          else StDevAll(l);
plot Avgpc = (sumPc + pc) / (sumD + 1);
     Avgpc.SetDefaultColor(Color.Cyan);
plot upper = Avgpc + (SD_Multiplier*SDH);
     upper.SetDefaultColor(Color.Gray);
plot lower = Avgpc - (SD_Multiplier*SDL);
     lower.SetDefaultColor(Color.Gray);
# End Code
 

horserider

Well-known member
VIP
KZRagUg.png


Something like that ? @Jmp2626
 

horserider

Well-known member
VIP
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.
 

MarbleSat

New member
Hi everyone.

I'm wanting to place two bands (one slightly above, one slightly below) around the weekly volume point of control for a backtest.

Is this possible? thank you.

p.s I'm new, love the forum.
 

CaptainVine

New member
VIP
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 suck.
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
 

rad14733

Well-known member
VIP
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...
 

MerryDay

Well-known member
VIP
@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:

sri2020

New member
VIP
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?
 

DanielEsse

New member
[REQ] CLOUD PROJECT

I will try to explain my request as best as possible.

elements necessary for compilation:

1) session: eth or rth
2) high
3) low
4) mid point
5) poc

condition 1 = if poc> midpoint then (LOW + POC = calculates the distance between the minimum daily session and the poc), projects the LOW + POC distance FROM POC, drawing it on the graph with a line (with the possibility of adding a dynamic cloud ) ..

condition 2 = if poc <midpoint then (HIGH + POC = calculates the distance between the MAXIMUM of the daily session and the POC), projects the HIGHPOC distance FROM POC, drawing it on the graph with a line (with the possibility of adding a dynamic cloud).

I remain at your disposal for any clarification.




Thanks in advance .
 

Similar threads

Top