NexusFi: Find Your Edge


Home Menu

 





Volume Profile and dynamic pricePerRow help!


Discussion in ThinkOrSwim

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




 
Search this Thread

Volume Profile and dynamic pricePerRow help!

  #1 (permalink)
cookie75
Toronto Ontario
 
Posts: 5 since Jul 2012
Thanks Given: 0
Thanks Received: 1

Okay i'm the first to say that i'm not the best programmer in the world so i need a little help changing the TOS Volume Profile a bit. What I would like to do is allow for the price per row height to equal the average true range of the stock for the last X periods. This is what i've tried but I keep getting the error that 'Only constants expected here'. Any help would be appreciated. Here is the code i would like to adjust and my adjustments highlighted in red.

input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input atr_length = 20;
def AvgTR = Average(TrueRange(high, close, low), length = atr_length);
def customRowHeight = getvalue(AvgTR, 1,1);

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

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
ZombieSqueeze
Platforms and Indicators
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
 
Massive l's Avatar
 Massive l 
OR/USA
Legendary /NQ Trader
 
Experience: None
Posts: 2,129 since Mar 2011
Thanks Given: 1,859
Thanks Received: 5,106

working on it...same problem as you right now

 
Code
input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM, ATR};
input customRowHeight = 1.0;
def customATR = AvgTrueRange(high, close, low, 20);
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;
case ATR:
    height = customATR;
}

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

Visit my NexusFi Trade Journal Reply With Quote
  #3 (permalink)
 
Massive l's Avatar
 Massive l 
OR/USA
Legendary /NQ Trader
 
Experience: None
Posts: 2,129 since Mar 2011
Thanks Given: 1,859
Thanks Received: 5,106


I think it's wanting an input for height.
It doesn't want us to define something

Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 
Massive l's Avatar
 Massive l 
OR/USA
Legendary /NQ Trader
 
Experience: None
Posts: 2,129 since Mar 2011
Thanks Given: 1,859
Thanks Received: 5,106

What other studies reference ATR? Then we can build off of that.

I tired this as well...still not liking it

case ATR:
height = AverageTrueRange();

Visit my NexusFi Trade Journal Reply With Quote
  #5 (permalink)
cookie75
Toronto Ontario
 
Posts: 5 since Jul 2012
Thanks Given: 0
Thanks Received: 1


Massive l View Post
What other studies reference ATR? Then we can build off of that.

I tired this as well...still not liking it

case ATR:
height = AverageTrueRange();

thanks for looking into it. What i tried to do was use the ATR with an offset by 1 period so that it doesn't use the current bar since it will always be changing the height.

I was trying to look at TOS's Monkey Bars but couldn't figure it out.

Reply With Quote
  #6 (permalink)
cookie75
Toronto Ontario
 
Posts: 5 since Jul 2012
Thanks Given: 0
Thanks Received: 1

I think i found the issue (just don't know how to fix it). Below is the VolumeProfile syntax. The default value for pricePerRow is a constant. I think I would have to def my own volumeprofile and change the prircePerRow data type or something like that. Any ideas?


VolumeProfile(String symbol, double pricePerRow, IDataHolder startNewProfile, int onExpansion, int numberOfProfiles, double value area percent);

Default values:

symbol: getSymbol()
pricePerRow: PricePerRow.AUTOMATIC
onExpansion: Yes
numberOfProfiles: "all"
value area percent: 70.0

Reply With Quote
  #7 (permalink)
scotch
San Diego CA
 
Posts: 7 since Sep 2018
Thanks Given: 2
Thanks Received: 0

Did anyone figure out a workaround for this issue? I'm also up against the "Only constants expected here" error and looking for a solution.

Reply With Quote




Last Updated on September 13, 2018


© 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