Categories
Crypto Daily Topic Forex Daily Topic Forex Videos

Forex Trading Algorithms Part 7 Elements Of Computer Languages For EA Design!


Trading Algorithms VII – Liberal sequences and exact sequences

Translating ideas into a trading algorithm is not always easy. When examining a particular trade idea, we could find two cases: 

  • the signal can be described precisely in a consecutive sequence of trading facts, or 
  • Several conditions with variable steps among each condition need to be spotted.

The first class is easier to program. To this class belong any kind of crossovers: 

  • price to MA: 

  • MA to MA :

Similar conditions can be created with indicator crossovers and level breakouts.

 

Trading Signals Using Pivots

But what if the idea is more complex?. Let’s consider we want to catch pivot points in the direction of the trend. Let’s say we want to open a buy trade in the second pivot reversal. Let’s follow Pruitt’s example:

Buy on the second pivot pullback if

1.- The second pivot high is higher than the first pivot

2.- The pullback is larger than 2%

3.- The sequence takes less than 30 bars

 

The Flag Model

Since these conditions happen with variable price-action sequences programming, this kind of entry is much more difficult if we employ just If-then-else statements. The employment of flags to signal that a specific condition was met helps in the logic but is not the best solution.


As we see, the flag model is awkward and not too flexible. Also, this method is prone to errors.

 

The Finite State Machine

The second method to this kind of problem is the Finite State Machine (FSM). Basically, we want to detect certain states following others, defining a state when the needed condition is met. An FSM is a machine with finite states. The machine moves from state zero or START through several states until a final one, which defines the ACCEPT state. 

We can imagine a state machine as a combination lock. We need to supply the lock with a combination of numbers until its final digit, which triggers its opening.

The first step is to create the states needed. Next, we create the conditions for the change from one state to other states. Once satisfied with the diagram, we can easily write the pseudo-code, or, even, the actual code directly.

As we can see here, the code is precisely subdivided into states, each state with the precise instructions to move to the next state or back to the start state. We can see also that this algorithm is executed from top to bottom on each new bar. We hope that this example will help you better understand how an entry algorithm can be created.

Stay tuned for more interesting videos on trading algos!

Categories
Forex Videos

Forex Trading Algorithms Part 4 Elements Of Computer Languages For EA Design!

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

 

A computer program is a combination of data structures and a set of instructions or commands in the form of functions that process the data structures to construct a solution or solutions.

 

Control flow tools

To efficiently process information, a high-level programming language owns specific instructions to do mathematical operations, check for conditions, and control data flow.

 

The if Statement:

The if statement is the most basic flow-control instruction. It allows us to check for conditions or the validity of a statement.

for example, 

if x > 0 checks for the variable x being higher than zero. If it is zero or negative, it will deliver a False value. If over zero, it will provide a True condition.

The if statement, combined with the else statement, handles the flow of the information. If/else is mostly similar in all languages. ( Example taken from docs.python.org 

Iterators

Iterators are used to move through the components or a data structure, such as lists or arrays. There are several ways to iterate, some language-specific, but most are present in all languages.

 

 The for statement

The for statement is used to do an orderly iteration on an array or list. In C++, it has the following structure:

for (initialization; condition; increase) . Initialization is the starting point; condition defines the endpoint, and increase sets the step.

CPP example, source cplusplus.com

Python’s for is more versatile and simple. To loop through a list is straightforward (taken from docs.python.org):

But we can use the range() function to do a similar C++ for (taken from docs.python.org):

The While statement

The while statement creates a computer loop that is exited only after a certain condition is met:

For example, the above while loop appends the Fibonacci numbers up to n, storing them in the fibo list. The loop breaks only when a is bigger than n.

 

Function definition

In a computer app, the code repeats itself most of the time, sometimes the values may be different, but the basic computational structure is the same. To organize these computational structures, all computer languages have functions. 

In C++ a funtion is defined with the following structure:

<out type> function name (<type> parameter1, …. <type> parameter n){

body

}

The out type is the output type of the function. It can be an integer, a floating-point, or any other data structure, pointer, or no output at all.

The parameters are inputs to the function but can be used to modify an external structure as well.

In Python, the definition is simpler. 

def function_name ( parameter1…parameter n):

body

If the function returns a value or data structure, it is delivered through a return statement.

The following example shows the fib function, which computes the Fibonacci numbers up to the input parameter. The results of the Fibonacci computations are stored in the fibo list, which, after exiting the while loop, is returned. The variable res is assigned the output of the fib function and printed. Please note that the last two statements are not part of the fib function.

The last introductory article on high-level languages will talk about classes, objects, and object-oriented programming.

Once we have completed this basic wrap-up on programming language features, we’ll start studying trading-focused algorithms in the coming videos.

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
Forex Videos

Forex Trading Algorithms Part 2 Converting Trading Strategy To EA’s! From Ideas To Code!


Trading Algorithms -From Ideas to code

 

As we have already said, computers are dumb. We need to explain to them everything. Moreover, digital computers are binary. They only understand ones and zeroes. Nothing else. 

Compilers and interpreters

To make our lives easier, we have created interpreters and compilers, able to translate our ideas into binary. Basically, both do the same job. Compilers produce a binary file that a computer can later execute, whereas interpreters translate each instruction as it comes in real-time.

From idea to the algorithm

Usually, traders think about when to enter and exit trades. An example brought by George Pruitt in his book The Ultimate Algorithmic Trading System Toolbox is the following. A trader wanted a code to enter the market and told him: 

” Buy when the market closes above the 200-day moving average and then starts to trend downward and the RSI bottoms out below 20 and starts moving up. The sell-short side is just the opposite.” 

No computer would understand that. In this case, the idea was partially defined, though: To buy when the price was above the 200-day SMA, and the RSI crosses down below 20. But what did he mean by “downward trend”? or “starts moving up”?

Pseudo-code

The first step to make a trading algorithm is to create an approximation to the code using plain English, but with more concise wording.

In the example above, Pruitt says that he could translate the above sentence into the following pseudo-code after some calls to his client:

The number inside brackets represents the close x days before the current session; thus, [1] is yesterday’s close.

In the pseudo-code, close below close[1] and close [1] below close [2] and close[2] below close[3] is the definition of a downtrend. But we could define it differently. What’s important is that a computer doesn’t know what a downtrend is, and every concept needed for our purposes should be defined, such as a moving average, RSI, and so forth.

The code

The next thing we need to do is move the pseudo-code to the actual code. There are several languages devised for trading. MT4/5 offers MQL4/5, which are variants of C++, with a complete library for trading. Another popular language is Easylanguage, created by Tradestation, which is also compatible with other platforms, such as Multicharts. Another popular language among quants is Python, a terrific high-level language with extensive libraries to design and test trading systems.

The code snippet above creates a Python function that translates the above code idea. In this case, the myBuy function must be told the actual asset to buy ( which should point to the asset’s historical data), and it checks for a buy condition. If true, it will return a label for the buy and the level to perform the buy, the next open of the asset in this case.

Systematic or discretionary?

The steps from idea to pseudo-code to code is critical. If you do not have a working algorithm, there is no way you could create a systematic trading system. But this is only the beginning. Creating a successful automated trading system is very hard and involves many developing, testing, and optimizing cycles. The market shifts its condition, and not always your system will perform. Then, you have to ask yourself if you’ll endure the drawdown stage until the market comes in sync with the system again.

Some systematic traders think that the best way to attack the market is to have a basket of uncorrelated trading systems, which are in tune with the market’s different stages: low-volatility trend, high-volatility trend, low-volatility sideways, high-volatility sideways, so your risk and reward is an average of all of them.

In the coming videos, we will dissect the steps to create an automated trading system. Stay tuned!

Categories
Forex Videos

Forex Trading Algorithms Part 1-Converting Trading Strategy To EA’s & Running Tests On Profitability

Trading Algorithms –  An Introduction

 

Almost all traders, novices and pros alike, know at least the basics of technical analysis. Still, not many know how to convert a trading idea into a set of rules and then test them for profitability.  This video series aims to be an introduction to algorithms applied to trading. Even if you are not considering creating one EA or trading bot, we think it is very interesting to be proficient in converting your trading idea into formal code and test it. We will use mostly pseudo-code, but also python, a very easy-to-learn but powerful high-level language, and Easylanguage, developed by Tradestation, which is almost as pseudo-code because it was designed to be read as a natural language.

 

What is an algorithm?

An algorithm is a set of rules to perform a task in a finite number of steps. Basically, an algorithm is a recipe.

 

For example, if we were to create an algorithm to make a phone call manually. A possible solution could be this :

1.- Open the phone
2.- select the keyboard
3.- dial each number from left to right
4.- Click the green phone icon
5.- Hear the calling sound

6.- Busy tone?
    A- no ---> wait  60 seconds for the answer.
        Did somebody answer?
                Yes--> Start a conversation
                    I - Conversation ended?
                            Yes --> Hang up.
                No --> Hang up
    B- Yes ---> Wait 120 seconds and go to 4th step

Algorithms  used in Trading

There are many ways to create Trading algorithms, including advanced sentiment analysis, evaluating the words used in trading forums and news releases. Still, we will focus on algorithms for historical price action data series.

 The ability to create, test, and evaluate a trading algorithm is a terrific ability to own. This allows creating market models that map and profit from the market’s inefficiencies. If you happen to find one set of rules that historically made profits, it could likely continue making profits in the future. This is the basic premise of automated algos, expert advisors, and trading bots.

 

Algorithm properties

  • Inputs: zero or more values can be externally supplied. Some algorithms don’t need inputs, although the majority will, and of course, a trading algorithm will need to get timely data from the market to generate outputs.
  • Outputs: at least one result should be delivered. That is logical. The output may not only be a text. It can be a picture, a sound, or a market trading order.
  • Unambiguous: Each instruction must be explicit, with a single meaning.
  • Finite: It ends after a limited number of steps.
  • The algorithm should precisely specify what the computer should do. The computer is not smart. It is dumb. You should tell it precisely the action it has to make.
  • Effective: Every instruction should be basic enough to be made by hand or uses other algorithmic sub-units with the same property. Of course, the action must be feasible, which means the computer can perform that action because the instruction is included in the instruction set of the programming language you’re using.

The key to a good algorithm, as with recipes, is to break the ideas down into simple building blocks.

Flow Diagrams

Algorithms can be more complicated than a simple recipe. Besides, a recipe is interpreted by a (supposedly) intelligent cooker. On the other hand, algorithms are to be interpreted by brainless CPUs. Besides, algorithms usually accept a stream of data inputs, which must be transformed until an output or output is produced.  Flow diagrams are a pictorial representation of the algorithm’s process and data flow.

A Flow diagram is a very handy tool to develop your ideas into coherent algorithms because it helps you spot potential flaws and improvements and should be the first step before proceeding to the actual code.

 

In the next chapters, we will continue developing this basic idea, applied to trading, using trading examples.

 

Further reading:

The Ultimate Algorithm Trading Toolbox, by George Pruitt.

 

Categories
Crypto Guides

Introduction To ‘Cryptohopper’ – A Reliable Crypto Trading Expert Advisor

Introduction

Cryptocurrencies are intensively volatile. The volatility of the currency is a matter of concern, but in the case of trading with cryptocurrency, it’s quite advantageous. In the crypto trade, you can invest when the market value is declining, and you can retrieve your amount when prices are on hike.

However, it requires experience to become an expert in reading and analyzing this market’s up-down trends, so that you can invest at the perfect time to expect maximum returns. To predict this market flow for investors, trading bots are introduced with automated algorithms in the industry. Today in this article, we will be discussing one such trading bot- Cryptohopper.

Understanding Crypto Trading Bot

Crypto bots are cloud-based computer programs to host cryptocurrency trading. It provides idle tools to beginner and advanced traders. At the right time, it can automatically buy and sell cryptocurrencies. Users can simply connect the bot with their cryptocurrency exchange, and then it can smoothly trade on their behalf. For successful trading, it is necessary to rely upon complicated probability estimation for predicting the market trends, and a bot can calculate this much faster than a human brain. 

What is Cryptohopper?

The cryptocurrency industry is offering various services and tools to traders to elevate their success rate. Cryptohopper is one such tool that can simplify the crypto-trading ecosystem. It’s a trading bot that has been customized as per the requirements of users and can also provide market technical detail.

Earlier, a user would have to spend a lot of time in front of the computer screen to trace market flow all day, but now the fully automated bot can monitor the trade 24/7 on behalf of the users. To ensure high output, it can perform backtest for each iteration and can optimize decisions based on the current situation. 

Why do you need a bot like Cryptohopper?

In the cryptocurrency trading world, every second matters a lot. So, to make life easy and to earn more, traders can make use of a crypto trading bot like Cryptohopper to make every second count. Let’s have a look at how Cryptohopper can help in various domains of crypto-trading.

Objective trading 

The trade will be executed entirely based upon the data analysis. You don’t need to panic about the buying or selling process because the trade activities shall be evidenced without any involvement of stress or emotion.

Social trading 

Cryptohopper directly subscribes to market signalers who analyze the trade and suggest how to raise the value of your coin. As a result, you can get appropriate information for trade optimization.

Simultaneous trading 

It operates and manages all your coins simultaneously. It can keep track of all price details and sell your coin exactly at the target profit scale that you have set.

Intuitive tools 

This bot has the potential to keep the users at the top market position. It notifies with alert in advance about the trade opportunity to sell the declining coins and to repurchase the coins at a lower price.

Cloud-based platform 

It remains 24/7 online in the cloud. It means you don’t need to keep your device ‘on’ always to track your coins. You can log in to your bot account anytime, and you will get a notification about the latest market updates. 

Conclusion

The ability of Cryptohopper to provide users with high returns in cryptocurrency trading is something to look at. The traders won’t feel the need to rely on a computer screen as this bot can automatically trace the trends and take the necessary steps that have been fed. It can be easily used without any coding background and can also be connected to any global crypto exchange without incurring any trading fees.

Categories
Forex Services Reviews-2

EA Prototype Reverse Review

The Prototype Reverse Expert Advisor was made available in September 2019 by the creator Svyatoslav Kucher. Kucker has an extensive list of available products ranging from indicators to expert advisors. The EA we will be looking at today has not had any updates made since 2019 and unfortunately, there are no reviews about it at the moment. Read through this review to get a better idea of what this Expert Advisor does and how it can help you increase your profits when trading.

Overview

The Prototype Reverse EA uses order averaging to avoid losses when prices move in the opposite direction from the initial entry. The EA basis its entrance according to what happened in the first order, ie, if the first order is closed at a profit, the next order is opened in the same direction in the hope of achieving the same results and vice versa; if the first order is closed at a loss, the next order is opened in the opposite direction.

There are a number of parameters that can be set by the users including; language, the maximum number of open orders at one given moment, the take profit value in points, the percentage of margin, the width and style of the lines and also the ability to delete the order history from the price chart amongst many others. This EA is extremely customizable and you can find the full list parameters on the website.

Service Cost

The cost of the Prototype Reverse EA is $35 for purchase or $15 monthly. Users can also choose to test out the free demo which is available before investing in this product.

Conclusion

Unfortunately, there are no user reviews or comments regarding this product at the moment, and from 46 people that downloaded the free demo, only 5 of them decided to purchase it. If you think this EA can help make your trading more profitable, we suggest downloading the free version to try it out first hand and determine whether it can be beneficial for you.

This Forex Indicator is currently available in the MQL5 marketplace: https://www.mql5.com/en/market/product/42060