Categories
Forex Videos

Forex Trading Algorithms Part 3-Converting Trading Strategy To EA’s & Elements Of Computer Language!


Trading Algorithms – The Elements of a Computer Language – Part I

 

600x600

A computer language is a formal language to convert our ideas into a language understandable by a computer. Along with computing history, languages have evolved from plain ones and zeroes to assembly language and up to the high-level languages we have today.

Assembly language

Assembly language is a direct link to the computer’s CPU. Every assembly instruction of the instruction set is linked to a specific instruction code to the CPU.  

Fig 1. The basic structure of an X86 CPU. Source cs.lmu.edu

The CPU characteristics are reflected in the instruction set. For instance, an X86 CPU has eight floating-point 80-bit registers, sixteen 64-bit registers, and six 16-bit registers. Registers are ultrafast memories for the CPU use. Thus every register has assembly instructions to load, add, subtract, and move values using them. 

Fig 2- Example of assembly language

source codeproject.com

A computer program developed in assembly language is highly efficient, but it is a nightmare for the developer when the project is large. Therefore, high-level languages have been created for the benefit of computer scientists.

The Elements of a high-level language

A modern computer language is a combination of efficient high-level data structures, elegant and easy-to-understand syntax, and an extensive library of functions to allow fast application development.

Numbers

A computer application usually receives inputs in the form of numbers. These come in two styles: integer and floating-point. Usually, they are linked to a name called “variable.” That name is used so that we can use different names for the many sources of information. For instance, a bar of market data is composed of Open, High, Low, and Close. We could assign each category the corresponding name in our program.

Integers correspond to a mathematical integer. An integer does not hold decimals. For instance, an integer division of 3/2 is 1. integers are usually used as counters or pointers to larger objects, such as lists or arrays.

A floating-point number is allowed to have decimals. Thus a 3/2 division is equal to 1.5. All OHLC market data comes in floating-point format.

Strings

A string is a data type to store written information made of characters. Strings are used as labels and to present information in a human-understandable form. Recently, strings are used as input in sentiment-analysis functions. Sentiment analysis 

Boolean

Boolean types represent true/false values. A true or false value is the result of a question or “if” statement. It can also be assigned directly to a variable, such as in

buyCondition = EURUSD.Close[0] > 1.151

In this case, buyCondition is False for EURUSD closes below 1.151, and is True when the close value is higher than 1.151.

Lists 

We usually do not deal with a single number. If we want to compute a 20-period moving average of the USDJPY pair’s Close, we would need its last 20 closes. To store these values, the language uses lists (or arrays in C++). A list is an ordered collection of values or other types of information, such as strings.

Since Lists are ordered, we can refer to a particular element in the list using an index. For instance, if we were to retrieve the candlestick Close two bars ago of the USDJPY, we would ask for USDJPY.Close[2]

Sets

A Set is an unordered collection of elements. Sets do not allow duplication of elements. That means it eliminates duplicate entries. Not all languages have built-in Sets, although it can be made through programming if needed.

Dictionaries

Dictionaries are a useful data type that maps a key to a value. For instance, in Python 

tel = {‘Joe’: 554 098 111, ‘Jane’: 660 413 901} 

is a telephone structure. To retrieve Joe’s phone, we would write:

mytel = tel[‘Joe’]

with mytel holding 554 098 111

As with sets, not all high-level languages have built-in dictionaries, but a savvy programmer is able to create one.

 

In the next video of this series, we will explain the elements for flow control.

 

970x250

By Keiran

Forex trader, media, marketing, entrepreneur and father

Leave a Reply

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