NexusFi: Find Your Edge


Home Menu

 





ThinkOrSwim VolumeProfile edit


Discussion in ThinkOrSwim

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




 
Search this Thread

ThinkOrSwim VolumeProfile edit

  #1 (permalink)
 Ninman 
Ft Lauderdale/United States
 
Experience: Intermediate
Platform: Thinkorswim
Trading: Emini ES
Posts: 4 since Jun 2018
Thanks Given: 1
Thanks Received: 0

Can someone help me add the "YEAR" to volume profile? So if I have a multi year chart up, I can see the volume profile for 2016, 2017, 2018. I have the volume profile code... but no luck on trying to do the script to add year. Simply adding YEAR in the input timePerProfile didn't work.

Thank you!!!



input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {CHART, MINUTE, default HOUR, DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1; #### Hint: Set for time
input onExpansion = no;
input profiles = 1000;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 68;
input opacity = 0;
input displace = 12;
input ShowValueLabel = yes;


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 tpo = timeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = compoundValue(1, onExpansion, no);
def pc = if IsNaN(tpo.getPointOfControl()) and con then pc[1] else tpo.getPointOfControl();
def hVA = if IsNaN(tpo.getHighestValueArea()) and con then hVA[1] else tpo.getHighestValueArea();
def lVA = if IsNaN(tpo.getLowestValueArea()) and con then lVA[1] else tpo.getLowestValueArea();

def hProfile = if IsNaN(tpo.getHighest()) and con then hProfile[1] else tpo.getHighest();
def lProfile = if IsNaN(tpo.getLowest()) and con then lProfile[1] else tpo.getLowest();
def plotsDomain = IsNaN(close) == onExpansion;


plot POC = if plotsDomain then pc[displace] else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile[displace] else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile[displace] else Double.NaN;
plot VAH = if plotsDomain then hVA[displace] else Double.NaN;
plot VAL = if plotsDomain then lVA[displace] else Double.NaN;

DefineGlobalColor("Profile", color.blue);
DefineGlobalColor("Value Area", color.gray);
DefineGlobalColor("Point Of Control", color.yellow);

tpo.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(color.yellow);
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAH.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAL.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAH.SetDefaultColor(color.green);
VAL.SetDefaultColor(color.red);
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.hide();
ProfileLow.hide();
VAH.setlineweight(3);
VAL.setlineweight(3);
Poc.setlineweight(3);


def VA = VAH - VAL;

addlabel(ShowValueLabel,
if close <= VAH && close >= VAL && close >= POC
then "Inside VA, > POC: " +" (" +VAH +" / " +VAL +") "
else if close <= VAH && close >= VAL && close < POC
then "Inside VA, < POC: " +" (" +VAH +" / " +VAL +") "
else if close < VAL
then "< VA: " +" (" +VAL +") "
else if close > VAH
then "> VA: " +" (" +VAH +") "
else "",
if close <= VAH && close >= VAL && close >= POC
then color.yellow
else if close <= VAH && close >= VAL && close < POC
then color.dark_orange
else if close < VAL
then color.red
else if close > VAH
then color.green
else color.gray);

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
What broker to use for trading palladium futures
Commodities
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
MC PL editor upgrade
MultiCharts
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #2 (permalink)
 Ninman 
Ft Lauderdale/United States
 
Experience: Intermediate
Platform: Thinkorswim
Trading: Emini ES
Posts: 4 since Jun 2018
Thanks Given: 1
Thanks Received: 0

That was fast. Thank you!! Big help

Started this thread 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



Ninman View Post
That was fast. Thank you!! Big help

I posted the wrong one. Hold on.

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

#ichifutures
input pricePerRowHeightMode = {default TICKSIZE, AUTOMATIC, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {default Year, Threeyear, Week, Day, Month, Quarter, Decade, Minute, Hour, Chart, "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 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 Quarter:
period = Floor(month/3 - First(month/3));
case "OPT EXP":
period = exp_opt - first(exp_opt);
case BAR:
period = barNumber() - 1;
case ThreeYear:
period = Floor(year/3 - First(year/3));
case Decade:
period = Floor(year/10 - First(year/10));
case YEAR:
period = Floor(year - first(year));
}

rec count = if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1];
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);
rec pc = if IsNaN(vol.getPointOfControl()) and con then pc[1] else vol.getPointOfControl();
rec hVA = if IsNaN(vol.getHighestValueArea()) and con then hVA[1] else vol.getHighestValueArea();
rec lVA = if IsNaN(vol.getLowestValueArea()) and con then lVA[1] else vol.getLowestValueArea();
rec hProfile = if IsNaN(vol.getHighest()) and con then hProfile[1] else vol.getHighest();
rec 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
  #5 (permalink)
 Ninman 
Ft Lauderdale/United States
 
Experience: Intermediate
Platform: Thinkorswim
Trading: Emini ES
Posts: 4 since Jun 2018
Thanks Given: 1
Thanks Received: 0

That is exactly what I was looking for. You are the man! Thank you.

Started this thread 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


Ninman View Post
That is exactly what I was looking for. You are the man! Thank you.

no prob. Included bonus decade profile and also a 3 year

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on December 19, 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