Tutorial 133 | Displaying trade at bid and ask data using ActivityBars

Display activity bars when trades at bid or ask exceed a certain value

One of Markplex’s YouTube subscribers requested a tutorial to demonstrate the TradeStation Time&Sales provider. He wanted to understand how one could use the provider to find trades executed at the last ask or at the last bid price whose size (in terms of contracts or shares) was bigger than a user input. The request was to display these trades using an EasyLanguage show-me study, but, perhaps I thought it would be more appropriate to use an ActivityBar study.  EasyLanguage ActivityBar studies can display the approximate price levels on a bar where the trades took place. Read an introduction to ActivityBars below.

An example Time and Sales window

This tutorial uses the TradeStation Time and Sales class to create an object which enables the user to monitor and analyze time and sales information programmatically. Each time a bid or ask is posted, the object fires an update event and the bid or ask price is recorded. When a trade takes place with a price equal to the last bid or ask price and with a number of contracts greater than the MinTradeSize user input, the TradeAtBidCounter or TradeAtAskCounter is incremented, respectively. The Time and Sales object is not available within MultiCharts and so this tutorial program will not work with MultiCharts.

A detailed @ES 30 minute bar. Notice how an extra row of ‘E’ rows are added on the left side of the bar, indicating a greater number of trades at the ask price for this specific ActivityBar range

An ActivityBar study is then used  to add a cell or cells on the chart for the price range covered by the specific ActivityBar being developed for the TradeAtBidCounter and TradeAtAskCounter up to a maximum number of cells (again specified by user input: MaxWeight). The program adds cells for the TradeAtBidCounter on the right of the current Data1 bar and it adds cells for the TradeAtAskCounter on the left of the current Data1 bar.

Introduction to ActivityBars

ActivityBar studies analyse bars based on look-inside-data of smaller ActivityBars. For example, a 30 minute bar might use 5 minute ActivityBars.  ActivityBar studies uses ‘cells’ (little rectangles) to display information about a bar based on the range of prices for each underlying ActivityBar. The number of rows of cells can be controlled according to some other quantity related to the ActivityBar being analysed.

The colors of the cells and the text within them cab be changed for each ActivityBars.

The ApproxNumRows user input determines the approximate number of cell rows placed between the high and low prices of the ActivityBar.

Probably one of the simplest ActivityBar studies is the Price Distribution ActivityBar study which uses cells to show the range of prices for each ActivityBar interval within the price bar. The number of cells distributed on any one row or among several rows reveals in how many of the ActivityData intervals the price occurred.

TradeStation created a very good introduction to the functionality of its ActivityBar studies here: https://www.youtube.com/watch?v=j7kXbPjM7rU

Applied to @ES 30 minutes with 5 minute ActivityBars. Inputs: 10, 3, 25

Another time period on @ES 30 minutes with 5 minute ActivityBars. Inputs:10, 20, 25

Inputs and data settings

The tutorial program has the following inputs:

ApproxNumRows: The approximate number of rows of cells to use in the study.

The study calls the standard AB_RowHeightCalc function which uses a calculation of the average range over 3 bars, divided by the ApproxNumRows input to determine what the row height should be set to. The number of rows on each ActivityBar will be likely to vary. If the above calculation results in a row height value that is smaller than the minimum movement of the symbol, the minimum movement is returned.

MaxWeight: The maximum number of columns to plot based on the number of the  TradeAtBidCounter and TradeAtAskCounter.

MinTradeSize: The minimum trade size to consider when counting trades at the last bid or ask.

As well as the inputs, the data setting tab enables you to set the interval of the Activity Bar. For example, you might use a data1 bar of 30 minutes and an intra-day interval of 5 minutes.

The ActivityBar length is set in the ActivityBar settings’ ‘Data Settings’ tab.

The tutorial demonstrates various techniques including:

  • Creating an object of the Time and Sales Provider class
  • Using a method to determine when the ‘big’ data1 bars end and when the small ActivityBars end
  • Using ActivityBars and understanding differences from the behavior of an indicator or show me study
  • Determining if the chart is set to local or exchange time using the DataStreams Class

Because the Time and Sales provider only provides real time data when the ActivityBar study is first applied to a chart no ‘cells’ will appear. The cells will start to appear as the real time data develops.

Note that if the program is applied part way through the development of a real time bar, the cell colors and cell letters will appear if if it were the start of the bar. The next ActivityBar will be created properly.

Download

The tutorial 133 ActivityBar indicators (_Tutorial133) is available for download for $39.95 by clicking the following link. The program works with TradeStation version 9.5 and newer versions.

Video explanation of Tutorial 133 Part 1

Video explanation of Tutorial 133 Part 2


The variable declaration

Note that some variables are declared as intrabarpersist.

int MinuteInterval( BarInterval of ActivityData ),

TimeAndSalesProvider TSProv( NULL ),

intrabarpersist double LastBid( 0.0 ),
intrabarpersist double LastAsk( 0.0 ),
intrabarpersist double LastTrade( 0.0 ),
intrabarpersist double DataPrice( 0.0 ),

intrabarpersist int TradeAtBidCounter( 0 ),
intrabarpersist int TradeAtAskCounter( 0 ),

intrabarpersist int CC( 0 ),
intrabarpersist int CCLastBigBar( 0 ),

intrabarpersist Int NextCol( 0 ),
intrabarpersist int NextLabelIndex( 0 ),
intrabarpersist string Label( “” ),

int BGColor( RGBToLegacyColor( GetBackGroundColor ) );

Please let me know if you spot any mistakes or errors or have questions.

THESE INDICATORS, SHOW ME STUDIES, STRATEGIES AND OTHER PROGRAMS HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES.

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.

Disclaimer The information, materials, products and services on this Web site are made available subject to the following terms and conditions. Markplex Corporation reserves the right to change these terms and conditions at its sole discretion. This Web site and any downloads, videos, tutorials, programs and information contained herein is presented solely for educational, informational, and/or entertainment use and under no circumstances should be used for actual trading. We at Markplex Corporation are not Broker/Dealers, Financial Advisers or Registered Analysts. No offer or solicitation to buy or sell securities, securities derivatives, futures products or off-exchange foreign currency (forex) transactions of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given or in any manner endorsed by Markplex Corporation. You are fully responsible for any investment or trading decisions you make. Futures and options trading has a large potential risk. You must be aware of the risks and be willing to accept them in order to invest in the futures and options markets. This Web site is neither a solicitation nor an offer to buy and/or sell futures or options. No representation is being made that any account will or is likely to achieve profits or losses similar to those discussed on this Web site. Past performance, whether actual or indicated by historical tests of strategies, is no guarantee of future performance or success. No warranties of profitability are being made or given. There is a possibility that you may sustain a loss equal to or greater than your entire investment regardless of which asset class you trade (equities, options futures or forex); therefore, you should not invest or risk money that you cannot afford to lose. CFTC RULE 4.41 - Hypothetical or simulated performance results have certain inherent limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not actually been executed, the results may have under- or over-compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown. Screen shots on this site are examples and are not meant to imply that any of the programs or tutorials available on this Web site will generate profitable trades. 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, informational, and entertainment use. 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. 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 Web site including the information, tutorials and/or programs included on it is at your own risk. You shall indemnify and hold Markplex Corporation harmless from any and all liability, loss, trading losses, costs, damage, or expense, including attorneys' fees you or third party may suffer (other than damage to your tangible property or injuries to employees occurring during the course of work) as a result of claims, demands, costs, or judgments arising out of third party and any other claims based on Markplex Corporation's performance, including, but not limited to losses resulting from the use of Markplex Corporation developed software, programs, web sites, tutorials, or the TradeStation charting and/or trading platform. Any testimonials on this Web site may not be representative of the experience of other clients and are not indicative of future results or success.
This Web site contains or may contain references and links to other companies and/or their Web sites, none of which is under the control of Markplex Corporation. Markplex Corporation makes no representations, warranties or endorsements whatsoever about any other Web sites to which you may have access through the Markplex Corporation Web site, or any products or services of those other companies, even if the products or services of those other companies or their Web sites are described or offered on the Markplex Corporation Web site or integrated with Markplex Corporation's products or services. TradeStation®, EasyLanguage® and PowerEditor® are registered trademarks of TradeStation Technologies, Inc. Other brand and product names which appear on this site are the trademarks or service marks of their respective owners, including: Microsoft® is a registered trademark in the United States Microsoft®Excel® is a registered trademark of Microsoft® Neither TradeStation Technologies nor any of its affiliates has reviewed, certified, endorsed, approved, disapproved or recommended, and neither does or will review, certify, endorse, approve, disapprove or recommend, any product or service that offers training, education or consulting regarding the use of EasyLanguage.

By continuing to use and navigate our sites, services, applications, tools or messaging, you are agreeing to our Terms and Conditions and the use of cookies, web beacons and similar technologies as described in our Privacy Policy and Privacy Policy on the use of cookies.