NexusFi: Find Your Edge


Home Menu

 





How to reference previous day VPOC, VAH, and VAL?


Discussion in ThinkOrSwim

Updated
    1. trending_up 3,381 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 1 attachments




 
Search this Thread

How to reference previous day VPOC, VAH, and VAL?

  #1 (permalink)
 TheNomadicAspie 
Las Vegas, NV
 
Experience: Beginner
Platform: NinjaTrader 8
Trading: Emini ES
Posts: 9 since May 2020
Thanks Given: 2
Thanks Received: 1

I have an indicator that shows the volume profile for each day, but I would like to access the previous day's VPOC, VAL, and VAH specifically so I can perform calculations to compare them to the current day. Could anyone help me figure out how to do this? Is it possible to specify a time period when using GetHighestValueArea() and GetPointOfControl()? Or would it require something more complicated?

This is the script I use for the daily volume profiles. I tried to see if I could modify the code to store the value of a specific day, but it's beyond my skill level.

input aggregationPeriod = AggregationPeriod.DAY;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = no;


input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {default CHART, MINUTE, HOUR, DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input onExpansion = yes;
input profiles = 1000;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 50;

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

#Added to find previous day point of control
def testpc = vol.getPointOfControl()[1];

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;


#added label to show label
#addLabel(yes, POC[1] );



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();
VAHigh.AssignValueColor(Color.WHITE);
POC.AssignValueColor(Color.WHITE);
POC.SetLineWeight(3);
VALow.AssignValueColor(Color.WHITE);

#addlabel(yes, testpc);

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
About a successful futures trader who didnt know anythin …
Psychology and Money Management
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
 
  #2 (permalink)
 JayC 
San Diego, CA
 
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
Posts: 55 since Mar 2019
Thanks Given: 9
Thanks Received: 43

Look back works ok, but you need to specify enough bars to put you into yesterday to get the "previous" value (POC[400]). One way to capture yesterday is using a time condition (at 1800) for the first bar of the session, then get the value of the previous bar. It works in most cases, but seems buggy at the month boundary for some reason.

 
Code
def previousPOC = if SecondsTillTime(1800) == 0 then POC[1] else previousPOC[1];
def previousVAHigh = if SecondsTillTime(1800) == 0 then VAHigh[1] else previousVAHigh[1];
def previousVALow = if SecondsTillTime(1800) == 0 then VALow[1] else previousVALow[1];

plot prevPOC = previousPOC;
plot prevVAH = previousVAHigh;
plot prevVAL = previousVALow;

prevPOC.AssignValueColor(Color.CYAN);
prevPOC.SetLineWeight(3);
prevVAH.AssignValueColor(Color.CYAN);
prevVAL.AssignValueColor(Color.CYAN);

Addlabel(yes, "pPOC: " + round(previousPOC, 0) + " POC: " + round(POC, 0), Color.CYAN);
Addlabel(yes, "pVAH: " + round(previousVAHigh, 0) + " VAH: " + round(VAHigh, 0), Color.CYAN);
Addlabel(yes, "pVAL: " + round(previousVALow, 0) + " VAL: " + round(VALow, 0), Color.CYAN);
Regards,
JayC

Reply With Quote
  #3 (permalink)
 TheNomadicAspie 
Las Vegas, NV
 
Experience: Beginner
Platform: NinjaTrader 8
Trading: Emini ES
Posts: 9 since May 2020
Thanks Given: 2
Thanks Received: 1


Thank you so much for the help. Unfortunately it doesn't seem to work. As you can see it plots the volume profile for the chart as a whole, not the previous day. =/

https://imgur.com/a/JiywNtn

Started this thread Reply With Quote
  #4 (permalink)
 JayC 
San Diego, CA
 
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
Posts: 55 since Mar 2019
Thanks Given: 9
Thanks Received: 43

Yea, I see in your screenshot the values are not changing at the correct time. Time conditions are very picky and hard to code for all situations. Its not clear what settings you're using to recreate the issue. Here's an example of ES, and the only issue i saw was on the month boundary.

JayC


Reply With Quote




Last Updated on November 11, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts