Volume Profile and dynamic pricePerRow help! - futures io
futures io futures trading



Volume Profile and dynamic pricePerRow help!


Discussion in ThinkOrSwim

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Volume Profile and dynamic pricePerRow help!

(login for full post details)
  #1 (permalink)
Toronto Ontario
 
 
Posts: 5 since Jul 2012
Thanks: 0 given, 1 received

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

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(167 thanks from 31 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(116 thanks from 33 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 17 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
 
 
(login for full post details)
  #2 (permalink)
Legendary Market Wizard
Portland, OR
 
Experience: None
 
Massive l's Avatar
 
Posts: 1,971 since Mar 2011
Thanks: 1,621 given, 3,965 received

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 futures io Trade Journal Reply With Quote
 
(login for full post details)
  #3 (permalink)
Legendary Market Wizard
Portland, OR
 
Experience: None
 
Massive l's Avatar
 
Posts: 1,971 since Mar 2011
Thanks: 1,621 given, 3,965 received


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

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #4 (permalink)
Legendary Market Wizard
Portland, OR
 
Experience: None
 
Massive l's Avatar
 
Posts: 1,971 since Mar 2011
Thanks: 1,621 given, 3,965 received

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 futures io Trade Journal Reply With Quote
 
(login for full post details)
  #5 (permalink)
Toronto Ontario
 
 
Posts: 5 since Jul 2012
Thanks: 0 given, 1 received


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
 
(login for full post details)
  #6 (permalink)
Toronto Ontario
 
 
Posts: 5 since Jul 2012
Thanks: 0 given, 1 received

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
 
(login for full post details)
  #7 (permalink)
San Diego CA
 
 
Posts: 7 since Sep 2018
Thanks: 2 given, 0 received

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


futures io Trading Community Platforms and Indicators ThinkOrSwim > Volume Profile and dynamic pricePerRow help!


Last Updated on September 13, 2018


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1500 prizes from Topstep!

February
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Call Option Buying: The New Pain Trade? w/Carley Garner

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts