ThinkScripter Volume Profile

Posted by on Sep 5, 2009 in Indicator, Volume | 16 comments

UPDATE MARCH 2010: The various profile studies (Volume/TPO) have been implemented natively by TOS and replace my thinkScript versions. I will leave these studies in the PRO bundle for those interested in looking at the code but I recommend using the new TOS versions henceforth. – Eric

ThinkScripter Volume Profile

It can’t be done. That’s what I told myself along with tens of readers who requested some variation of volume by price, market profile, or volume profile. ThinkScript lacks the basic tools necessary to easily accomplish such a study: iterative looping and indexed array variables (Guido: hint, hint…). Limitations be damned, I decided to give this beast at least the college effort. The volume of trades is depicted in the chart horizontally at price intervals. This “Volume by Price” can be used to understand which prices cause the largest activity and volume. This is useful in defining where the majority of historical trading volume happened and help find significant support and resistance lines. (Edit: FuturesTrader71 has an excellent video “Context and Trade Entries” discussing profiles and their use. See it here).

A few notes on setting this beast up. It plots in the bars to the right of the current price bar. As such, you need to set your style settings accordingly. The default bar length is 45 periods. So, you need to set your bars right at 50 since there is a 5 bar buffer between the volume profile and the current bar. Should you decide to use more bars for a larger histogram, you’ll need to set the barLength parameter to 5 less than the amount of right bars you choose. You will note that the highest volume bar is painted yellow and there is a dashed magenta VWAP line as well. All the bars are plotted relative to the highest volume bar and scaled accordingly. The profile is based on all the data plotted on the current chart so you can tailor it to meet your needs from a tick chart up to monthly. I tried numerous methods for sorting the volume into the various levels and settled for an equipartition model whereby any bar’s volume is divided equally between the high and the low of the bar. This is not exact but sans time and sales data in thinkScript, this seems to produce the best results. I am working on a variation that uses the market profile method of creating the histogram based on time-price-opportunities (TPOs).

This has been published to the PRO area of the forum in the current bundle.

16 Comments

  1. Yes… new donation on the way shortly!…. This is amazing.

  2. Eric – Great stuff!!! Cant wait to try it.
    What timeframes does it work on? What about tick charts?

    • It works on any timeframe any symbol…Yeah baby!

  3. Holy ____ Eric! You never cease to amaze me. I became a gold member back when it was $20 and your portfolio has grown tenfold. It was certainly some of the best money I ever spent and an additional tip to the beer jar is certainly overdue as TS’er said. Thank you for some truly amazing work. The muti-stops, and auto fibonacci are part of my daily trading arsenal and worth far more than you charge. You are a great asset to the Think or Swim community.
    Brian

    • Thanks for the kind words.

      • Wow…after using this for the last few weeks I am wondering how I ever traded without one of these. Looking at the profile I can now pick much more scientific targets for my trades and as a result, my win/loss ratio has improved. The VWAP lines are KILLER!!! I’m amazed at their usefulness. Thanks again TS.

  4. ThinkScripter,

    I am very impressed with your TOS scripting ability! I’ve been looking for a way to monitor volume profiles through TOS but never found it so I moved elsewhere. Is there a way to purchase single scripts, or is it only a package deal for all? Reason I ask is because I really would love to try this volume profile script, but don’t currently need any others.

    Again, great job on all of these scripts!

    Ross

  5. Eric… great work… I just knew you couldn’t resist the challenge.

    I’m excited to see the “TPO” version once its ready.

    Question for you regarding the PLOT tabs within the Study… I’m trying to make heads or tails of the various tabs, and colorization.

    I see that there 2 sets (B1 to B50), and (B1a to B35a), along with histVWap, and vwap.

    Am I correct in assuming that one “set” is for prior-range, and the other set is for “developing” area?

    I’m would also like to adjust the colors to my preferences, but I’m not sure if/how I should go about this… since it seems that eact “tab” has a different color assigned to it.

    Also, Can you help explain the logic behind the ‘tab groups’ and ‘colors’?

    • PS.. not the programming logic.. but the ‘coneptual logic’ of the colors and tabs…

    • The sets have nothing to do with prior vs. developing – Just made my job of typing a bit easier as I extended the study.

      Coloring the bars differently at this point will be very hard. I will try to code something into an update that lets you change the colorization en masse. Ignore the tab colors/groups as they are random.

      -Eric

  6. Eric,

    Great indicator –
    Here’s a couple of enhancement ideas :

    1. Grey color the bars where 70% of the trading volume has taken place. Market profile considers this the “value” area. It’s an important area.
    2. Add the ability to add a cloud for each prior day’s value area.
    3. Red Color the Price level that has had the most “touches” during the day.

    I haven’t joined yet, but I’d be happy to list your blog on mine and do a unique story promoting what you do and your site…..Let me know if you’d be interested.

    Thanks,

    Dave

  7. great work…

    how is the time-price-opportunities (TPOs) histogram progressing?

    • Hey, i’m really interested in this one.. I have a nice custom script i made up, i could send you a screenshot. Perhaps we could barter scripts if you like mine?

      Amir

  8. Hi Eric,

    For some reason even with my 13 years of software development experience, I just can’t figure this scripting language out. All I want to do is get the highest high for a variable number of days. The number of days is determined by the function: daysFromDate
    So I tried to do the following:

    def tradeLength = daysFromDate(BeginDate);
    def HighestHigh = Highest(high, tradeLength);

    for some stupid reason, the Highest funciton won’t take a variable as it’s length parameter.

    Can you please help?

    • Steve,
      Those functions require constants for the inputs. You can either hard code in a number or use in the input function to supply a variable. If you want your script to dynamically find the highest high, you can’t use these functions and will have to write your own algorithm.
      Eric

  9. Eric, TOS has a “raw” volume profile, as it doesnt calculate the Point of Control, Value Area High and value area low. Can you please develop that?, that would be great, as thats whats really useful, not the simple volume distribution graphics

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>