NexusFi: Find Your Edge


Home Menu

 





Programming "Year" into the Volume Profile


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one Massive l with 6 posts (1 thanks)
    2. looks_two rmejia with 3 posts (3 thanks)
    3. looks_3 ZevoTrader with 1 posts (0 thanks)
    4. looks_4 mmirza with 1 posts (0 thanks)
    1. trending_up 5,514 views
    2. thumb_up 4 thanks given
    3. group 5 followers
    1. forum 11 posts
    2. attach_file 2 attachments




 
Search this Thread

Programming "Year" into the Volume Profile

  #1 (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 want to add the option to have a yearly profile. I don't want to use Month and then 12 as the multiplier.

Here's the code. Any help would be greatly appreciated. Thank you!

input pricePerRowHeightMode = {default TICKSIZE, AUTOMATIC, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {default DAY, MINUTE, HOUR, WEEK, CHART, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input onExpansion = NO;
input profiles = 2;
input showPointOfControl = NO;
input showValueArea = NO;
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;
}

Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
ZombieSqueeze
Platforms and Indicators
 
  #2 (permalink)
 
rmejia's Avatar
 rmejia 
Puerto Rico
 
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: Options
Posts: 379 since Oct 2010
Thanks Given: 3,614
Thanks Received: 441

I think these 3 additions should do the trick:

input timePerProfile = {default DAY, MINUTE, HOUR, WEEK, CHART, MONTH, "OPT EXP", BAR, YEAR};
def year = getYear();
case YEAR:
period = Floor(year - first(year));


and all toguether now:

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

def period;
def yyyymmdd = getYyyyMmDd();
def seconds = secondsFromTime(0);
def month = getYear() * 12 + getMonth();
def year = getYear()
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;
case YEAR:
period = Floor(year - first(year));
}



Reply With Quote
Thanked by:
  #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


rmejia! ya da man. Thank you so much.

Visit my NexusFi Trade Journal Started this thread 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

If you are ever in Oregon, I'll show you some mind blowing shit. Let me know!

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #5 (permalink)
 
rmejia's Avatar
 rmejia 
Puerto Rico
 
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: Options
Posts: 379 since Oct 2010
Thanks Given: 3,614
Thanks Received: 441

lol, Oregon would be one heck of a trip, it's pretty far away from here. I considered moving to Portland after hearing the dream of the 90's was still alive there

Reply With Quote
  #6 (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

It doesn't seem to be working on my end

[img]https://nexusfi.com/v/nkf5uj.png[/img]

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #7 (permalink)
 
rmejia's Avatar
 rmejia 
Puerto Rico
 
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: Options
Posts: 379 since Oct 2010
Thanks Given: 3,614
Thanks Received: 441

I think you are missing the ";" at the end of the first line:

def year = getYear();

Reply With Quote
Thanked by:
  #8 (permalink)
mmirza
chicago, IL
 
Posts: 1 since Sep 2021
Thanks Given: 0
Thanks Received: 0

How I can get the Volume profile behind the chart like in attached in snapshot.
By default I am getting on right side of my prices

@rmejia help please

Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	144
Size:	85.0 KB
ID:	316871  
Reply With Quote
  #9 (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


mmirza View Post
How I can get the Volume profile behind the chart like in attached in snapshot.
By default I am getting on right side of my prices

@rmejia help please

In indicator settings change expansion to No

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #10 (permalink)
ZevoTrader
Pittsburgh PA
 
Posts: 1 since Oct 2021
Thanks Given: 0
Thanks Received: 0


Is it possible to have 4hour added to timePerProfile? I tried but couldn't get to work.

input timePerProfile = {default DAY, MINUTE, HOUR, WEEK, CHART, MONTH, "OPT EXP", BAR, YEAR};

Reply With Quote




Last Updated on November 3, 2021


© 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