Skip to content

Program 87 | Recurring volume profile (with end-of-bar real time update)

P87-1

Program 87 (_Program87-VolProfile) is based on _Program57 v1.7. and Program 86. It has been modified to repeat the volume analysis, every time a user input number of minutes is elapsed like program 86, but now the code updates in real time (at the close of each real time bar). The program has also been simplified and additional comments have been added. A new input has been added to give the user a choice as to whether the histrogram is drawn.
N.B. For real time bars in the current period the first histogram for that period is drawn after the first real-time bar closes. This is explained in the video below.
Also, bear in mind that some of the setting result in the program doing a lot of processing. For example if the _IntervalType input is set to ticks (0) and RepeatTime is set to a high number of minutes, this can cause the program to ‘lock-up’ and require a re-start. 

Compared to program 86, the code in the new program has been slightly simplified with additional commentary added. Unused variables have been removed. Hopefully this will make it easier to understand. In addition, several methods have been written to avoid repeating code.

Program 87 uses the Price Series Provider class to create a volume profile for timed periods that repeat after a user input number of minutes. The first period begins at the date specified in user input: FirstDate and  user input: StartTime. The length of this period is determined by a user input: RepeatTime expressed in minutes. When this time elapses the volume profile is calculated and drawn. Data collection then starts for the next recurring period. This is repeated throughout the day. The profile is color coded between two user specified colors: HistColor1 and HistColor2. The colors are entered as strings (e.g “Cyan”).

Note: Because the drawing tool used in this program can only draw to specific bars, the lengths of the profile are an approximation.

Having calculated the volume profile, Program87 then calculates at which price level most volume occurred during the previous period being analyzed. It plots three horizontal lines at the following levels:

  • The price high of the period being analyzed
  • The price low of the period being analyzed
  • The price at which the highest volume occurred during the PREVIOUS period analyzed

N.B. The above lines are plotted. The histogram is drawn using the Tradestation drawing tools.

Program87 was designed and tested with TradeStation 10. It works on intraday minute bars (e.g. 1 minute, 2 minutes, 5 minutes etc).

Please note that the profiles are drawn from the Starttime bar, however note that the time of the bar actually indicates the end time of the TradeStation bar on a minute chart. The activity that occurred within the StartTime bar IS included in the analysis. For example, on a two minute chart the 1702 bar is the END time of the bar. The bar actually contains activity after 1700 and up to 1702.

The RepeatTime input determines both the time period over which the analysis takes place and when the analysis is repeated. For example, if 2 minute bars were used and the StartTime set to 1000, and RepeatTime set to 60 then the initial period analyzed would be 1000 to 1058. The analysis would then be automatically repeated for 11 to 1158, 1200 to 1258 etc.

For real-time updates, (i.e. a volume profile is being created at the end of the chart for a period that has not yet ended), the histogram is drawn to the latest bar. So, for example, if 5 bars are being analyzed, the maximum length bar in the histogram would be 5 bars. If 6 bars are being analyzed, the maximum length bar in the histogram would be 6 bars.

Calculation of the volume histogram

At the close of each recurring period, the program looks back through the Price Series Provider (PSP) to find the volume (or tick counts depending on settings) at each price level. At the close of each bar _Program87-VolProfile stores volume into a dictionary with a key of the closing price of the bar converted to a string. If a key-value pair already exists in the dictionary for the price, the volume is added to the existing volume for that price. If a key-value pair does not exist then one is created and the volume is stored. Once all the volume data has been collected and stored, for the entire period, the levels are then copied into vectors to be sorted. The price level with the maximum volume is the pivot. The dictionary is cleared before data collection for a new period begins.

Program87 will not work in MultiCharts because it uses the TradeStation collections and other functionality that is not available in the MultiCharts environment.

Program 87 inputs
Program 87 inputs

Key to the user inputs

RepeatTime: Length of each period in minutes
FirstDate: The first date that a volume profile is created for
StartTime: Analysis begins after this bar
TicksOrVol: 0 = use ticks, 1 = use volume
_IntervalType: 0 = ticks, 1 = minutes, 14 = seconds
DrawHist: TRUE = Draw histogram, FALSE = Don’t draw histogram
HistColor1: Color of prices at which the least volume occurred
HistColor2: Color of the line at which the most volume occurred
HistWeight: Integer 0, 1, 2, 3, 4, 5, or 6
HistAlpha: 0 is fully transparent and 255 is fully opaque
TopLine: Color of line at the high of the period
BottomLine: Color of line at the low of the period
VolPivLine: Color of the line at the price at which most volume occurred
P87-Amzn
P87-@ES-5min

Technical lessons

Technically the program makes extensive use of the price series provider, vectors, the dictionary, drawing tools and the color class.
The code then the program 87 is available for  IMMEDIATE download for $74.95  by clicking the following ‘add to cart’ button. 

The tutorial is NOT compatible with MultiCharts.

The program has been thoroughly tested, however, please report any software bugs.

TO THE BEST OF MARKPLEX CORPORATION’S KNOWLEDGE, ALL OF THE INFORMATION ON THIS PAGE IS CORRECT, AND IT IS PROVIDED IN THE HOPE THAT IT WILL BE USEFUL. HOWEVER, MARKPLEX CORPORATION ASSUMES NO LIABILITY FOR ANY DAMAGES, DIRECT OR OTHERWISE, RESULTING FROM THE USE OF THIS INFORMATION AND/OR PROGRAM(S) DESCRIBED, AND NO WARRANTY IS MADE REGARDING ITS ACCURACY OR COMPLETENESS. USE OF THIS INFORMATION AND/OR PROGRAMS DESCRIBED IS AT YOUR OWN RISK.

ANY EASYLANGUAGE OR POWERLANGUAGE TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (AND PARTS THEREOF) AND ASSOCIATED TECHNIQUES REFERRED TO, INCLUDED IN OR ATTACHED TO THIS TUTORIAL OR PROGRAM DESCRIPTION ARE EXAMPLES ONLY, AND HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES. MARKPLEX CORPORATION. DOES NOT RECOMMEND THAT YOU USE ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (OR ANY PARTS THEREOF) OR TECHNIQUES. THE USE OF ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS AND TECHNIQUES DOES NOT GUARANTEE THAT YOU WILL MAKE PROFITS, INCREASE PROFITS, OR MINIMIZE LOSSES.