Skip to content

Tutorial 121 | Introduction to the Dictionary class

Store, check and update information in a Dictionary object

The Dictionary Class defines the structure of an object as a collection of key/value pairs that let you save values for use by a single EasyLanguage analysis techniques (indicator, paintbar study, showme study etc) or strategy. The structure is similar to a real dictionary where the word that we are searching the meaning for is the key and the definition of the word is the value.

Using Dictionary objects to store data is relatively straightforward and, arguably, more efficient with computer resources. A potential disadvantages is that, whereas with Arrays you can query what the value was for a particular element of an array a number of bars ago, you cannot do this with a dictionary.

Summary of tutorial 121

In this tutorial we look for high pivots on a chart. Each time a high pivot is confirmed we plot a dot on the pivot and add pivot information to a dictionary. As the key we use the bar number (converted to a string) and for the value we use the price of the pivot. At the close of each bar we check if the high of that bar is greater than any of the pivot values stored in the dictionary. If so, the pivot key/value pair are be deleted from the dictionary. Finally we do another plot of all the pivots that remain in the array at the time that the program was first applied to a chart.

Programming lessons

The tutorial demonstrates how to:

  • Create a dictionary and vector
  • Add a key/value pair to the dictionary
  • Delete a key/value pair from the dictionary
  • Use a for loop to go through the dictionary
  • Copy to keys into a key vector and copy the values into a values vector
  • Count the number of elements in the dictionary
  • Avoid ‘Vector is empty or invalid index’ errors

[download_box]If you wish to save yourself some time typing in the code, the UNPROTECTED TradeStation showme study (_Tutorial121) containing tutorial program (i.e. the TradeStation EasyLanguage is fully functional and you can see the source code) is available for IMMEDIATE download for $19.95- by clicking the ‘add to cart’ button. The program works with TradeStation but not with Multicharts.

The code is available free to Gold Pass members (see below).

After download the programs can be opened, you will be able to see the program code and modify it if you wish.

After purchase you will be redirected to a download page, so don’t close the browser.[/download_box]

 Video explanation of tutorial 121

 Video explanation of tutorial 121 – a typical error

Gold Pass area

This content is for members only.

[download_box]If you wish to save yourself some time typing in the code, the UNPROTECTED TradeStation indicator (_Tutorial121) containing tutorial program (i.e. the TradeStation EasyLanguage is fully functional and you can see the source code) is available for IMMEDIATE download for $19.95- by clicking the ‘add to cart’ button. The program works with TradeStation but not with Multicharts.

The code is available free to Gold Pass members (see above).

After download the programs can be opened, you will be able to see the program code and modify it if you wish.

After purchase you will be redirected to a download page, so don’t close the browser.[/download_box]

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.