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

 

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.

 

Categories
Crypto Guides

Smart Contracts – A Brief Introduction

What are Smart Contracts?

Smart contracts are nothing but deals that are digitally stored using digitization to enable digitalization of the business process. The smart contracts can be touted as one of the best applications of blockchain. Blockchain eliminates the middlemen in whichever industry the technology is leveraged, and smart contracts do the same. One doesn’t have to rely on a third-party player to authenticate the deal but pay some money to build the code which is suitable for all the parties involved and deploy the contract in the blockchain to make it active.

How do they work?

Smart contracts in real is a piece of code which can be written in any language that the blockchain platform may support. The code is written in such a way that when predefined parameters are met, the contract execution triggers automatically, and the conditions are met without any human intervention. This makes it very easy to handle and execute smart contracts.

Are they reliable?

Immutability is one of the essential characteristics of blockchain, as we have seen in our previous articles. Since the blockchain works on the concept of distributed ledgers, a copy of the contract will be available with every party involved. Smart contracts deployed in the blockchain network are immutable; once used, they cannot be changed. All the predefined terms should be met as agreed and signed by all the involved parties. Payments, if any concerned, will be done automatically as well without any human involvement. Thus, not delaying the cash, which makes all the parties happy about the work done. Hence the smart contracts are considered very reliable.

The real-life example of Smart Contracts

There are infinite real-life scenarios where smart contracts can be used. We all have booked tickets for our most awaited events, say concerts, movies, sports and so on. We always use a third-party website/app to book the tickets. Here the audience, as well as the event organizers, are trusting this third-party service provider with their money.

Instead of a third-party service provider, if one can deploy smart contracts in these scenarios, it would be easy to manage money. People buy their passes for the event, and this money is stored in the escrow linked to the contract. The money is not credited to the event organizers’ account unless the event is completed. If the event is completed, the funds will be automatically transferred to the organizers of the game. If not, the amount will be refunded to the audience account as per the terms and conditions of the event.

In this case, we do not depend on a third party for the refund of the amount, which may delay in case of any eventualities. We are also not paying any other extra fee to book the ticket as no third party is involved—this the best real-life example where once can use smart contracts.

Conclusion

The new technologies in our lives have come to make our life easy, and smart contracts come under such a category. We not only save money using them but also get rid of concept terminology of terms and conditions which lawyers use to cash the loopholes when something goes wrong. In this case, we use straightforward language to code the words and get them triggered as required, thus making them comfortable and very reliable to use.