Skip to content

Tutorial 218 | Ratio trade at bid/trade at ask and largest trade in bar

T218-2
Tutorial 218 calculates and plots:
 
If the Ratio input is set to TRUE:
  • The ratio of the number of trades made at the bid divided by the number trades made at the  ask
  • The number of trades made at the bid 
  • The number trades made at the  ask

If the Ratio input is set to FALSE:

  • The largest trade, by volume, for the bar
Tutorial 218 uses a time and sales provider to analyze trade information. TradeStation Time and Sales data is not available historically except for a number of previous ticks, which is not used in this program.
 
For real time bars after the first full bar is processed, when a time and sales update-event occurs, one of three actions is taken:
  1. If the update is NOT a trade, and the update is a bid, the bid price is stored in an intrabarpersist variable (LastBidPrice
  2. If the update is NOT a trade, and the update is an ask, the ask price is stored in an intrabarpersist variable (LastAskPrice)
  3. If the update IS a trade, the size of the trade (number of contracts or shares) is compared with a veriable that keeps a record of the biggest trade, so far, that bar. If the size of the trade is bigger than this number then the variable is updated.
  4. If the update is a trade, and its price is less than or equal to the last bid price then TradeBidCount is incremented.
  5. If the update is a trade, and its price is greater or equal to the latest ask price then TradeAskCount is incremented.
N.B. These assumptions have some potential for misclassification, especially when:
  • The spread is very tight (e.g., 1 tick)
  • The market is moving fast (quotes and trades may not align perfectly)
  • There’s price improvement (e.g., a buyer gets filled between the bid and ask)
  • A trade occurs inside the spread (e.g., midpoint fills).

Comments

Various commented out print statements are included below. These were used for debugging purposes and are not required to run the program.
 
N.B. Since this program is using real time data ONLY and NOT storing any of that data, if the program is reapplied or re-verified all the data currently on the chart will be deleted.
 
If the user is interested in how the data could be stored and later re-applied to the chart then he might be interested in program 81 . Program 81 stores and retrieves calculated values to and from a text file on the user’s hard drive using Streamwriter and Streamreader (the name and location of the file being defined by a user input).
T218-@YM-45s
T218-AMZN-2min
T218-@ES-1min

Explanation of tutorial 218

Free download of tutorial 218 indicator for Gold Pass members

Download the tutorial 218 TradeStation EasyLanguage Indicator free for Gold Pass members If you are a Gold Pass member you can download the tutorial code below, please make sure that you are logged in with your Gold Pass user name and password. This content is for members only.

Download the tutorial 218 program

If you wish to save yourself some typing, the tutorial programs are available for immediate download by clicking the ‘add to cart’ button below. You may pay using PayPal or a credit card. The price is $24.95

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.