Volume Profile and POC (Point of Control) Scripts

Jmp2626

New member
2019 Donor
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
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.
 

Similar threads

Top