What is Mql4 programming language

The MetaQuotes Language 4 (MQL4) is an object-oriented high-level programming language intended for writing automated trading strategies, custom technical indicators for the analysis of various financial markets. It allows not only to write a variety of expert systems, designed to operate in real time, but also create their own graphical tools to help you make trade decisions.

MQL4 is based on the concept of the popular programming language C++. The language has enumerations, structures, classes and event handling. By increasing the number of embedded main types, the interaction of executable programs in MQL4 with other applications through dll is now as easy as possible. MQL4 syntax is similar to the syntax of C++, and this makes it easy to translate into it programs from modern programming languages.

Capabilities

MQL4/MQL5 aims to directly address traders’ needs and requirements. It was developed for writing trading programs and is used only for that purpose. Functions for performing trade operations OrderSend(), OrderClose(), OrderCloseBy(), OrderModify(), OrderDelete() have been initially incorporated in the language and are used for changing the state of a trading account.

There are four program types that can be written in MQL4/MQL5.

  • Expert Advisors. Automatic systems trading by specified parameters and following a coded algorithm. Occurrence of a previously specified event like receiving a new tick, an alert about a new trading operation or even pressing a button or clicking a mouse, triggers the Expert Advisor to perform a programmed action.
  • Custom Indicators. Written by users, they are used along the ready-made indicators integrated in the terminals. Their function is purely analytical. Indicators do not perform trading nor carry out operations that slow down the interface stream such as sending emails or performing a random delay. The main task of indicators is to monitor a situation, reflect and interpret it and then submit to a trader for analysis.
  • Scripts. A script is a program intended for a single execution of an action. The start event is the only event type processed by the script.
  • Custom Function Libraries. In addition, there is an opportunity to create include files (#include). Include files allow you to include most frequently used functions and classes without directly pasting their source code into its program. Using functions and classes simplifies creating, debugging and compiling because when using dynamic libraries, functions load only when they are called directly.

What is price action trading?

Price action trading is based on trading decisions on the price movements of a currency pair. Indicators or other methods of analysis are usually not used, or given very little weight in the trading decision process.

A price action trader believes that the only true source of information is the price itself. If a  currency is going up, that tells the price action trader that people are buying. The trader will then assess, based on how aggressive (volatile) the buying is, whether it is likely to continue. Price action traders are hardly ever  concerned with  “why” something is happen.

Using historical charts and real-time price information (such as bids, offers, volume, velocity and magnitude) the price action trader looks for a favorable entry point.

A favorable entry point is one that allows risk to be controlled, but that also offers a potential profit.

There are many price action strategies. A very common price action strategy is called a breakout. When the price of a currency pair has been moving with a certain tendency, when it breaks that tendency it alerts traders to a new possible trading opportunity.

A breakout doesn’t mean the price will continue in the anticipated direction, often it doesn’t. This is called a false breakout, and also presents a trading opportunity in the opposite direction of the breakout.

Once you know a price action strategy there is little research time required. You find an asset with the specific price conditions you need, or you wait for those conditions to develop. Another benefit is that you often get more favorable entries and exits compared to many indicator based methods. The reason is that indicators are based on price, but lag behind it. By simply focusing on price you get the information in real-time, instead of waiting for a lagging indicator to give you information.

For more information about price action trading, please contact us.

What is Curve fitting ?

One of the advantages of expert advisors is the ability to evaluate their historical performance by “back testing” the strategies based on historical price data. Computers and back adjusted data make it possible to see what a system “would have performed” going back years in history.

The problem, of course, is that the system has been designed on this very same data. Because systems are designed on past data, they are often the victims of what we call “curve fitting”, making the ability to back test results one of the biggest disadvantages of trading systems also. Because the future may look nothing like the past in a particular market – the “fitting” of parameters onto the past “curve” of data may cause big problems on the future data curve, causing the system to be out of phase and potentially causing investors losses.

The easiest way to understand “curve fitting” is through a simple example. Imagine a system that buys or sells eur.usd on a breakout above or below the market high or low for the past X number of days. When testing the system on the past data, the testing may show $1,000 in profits when using a 10 day high/low, $2,000 in profits when using a 20 day high/low, and $5,000 when using a 30 day high/low.

If you were the developer, which value would you use in designing the system, 10, 20, or 30? Most people would use the 30 value, as it gives the highest profit. Now a developer will look at more than just profit, and test for lowest drawdown or most winning months, for example; but whatever your goal for the system, it is human nature to design a system whose parameters produce results as close as possible to those desired. The problem is, just because one parameter worked on the past data does not mean it will work on the future, unknown data. So how would a developer attempt to avoid such a problem?

Another example of curve fitting is adjusting parameters after the fact. Imagine a trading model which is doing well, but suffers a rather big loss on three out of four Wednesday afternoons since live trading began.  A trader might look at those results and come up with a brilliant plan, code the system not to take any trades on Wednesdays after 1:30pm.  Running the code backwards after putting in the new logic would result in those Wednesday losing trades going away, and voila – you have curve fitting.

Some  developers use many tricks such as testing on out of sample data, not optimizing parameters for the best back tested results (instead using logic based parameters – and making sure there are as few parameters as possible in the system (more parameters equals more degrees of freedom = more things to go wrong).

In case you are interested to use an automated trading system, convince yourself that you are not dealing with a tricked curve-fitted Expert Advisor, since it makes the back test useless.

For more information, send us and email

Forex robot back tests, should you trust them?

Forex robot back tests, should you trust them?

 

Back testing an automated forex strategy involves simulating the performance of a trading strategy based on historical data. Goal is to estimate if a strategy would have been effective during the tested period. Many forex robot sellers are not shy with throwing the most amazing back test reports at you in order to convince about the profitability of their strategy.


Is it that easy?

Be careful with back testing results

Back testing is not an exact science and we try to explain why a back test is nothing more than an indication if a strategy might have worked in the selected period. There are many variables that can affect your performance but today we want to show you how market conditions can change the results of a back test.

 

For example, we back tested a strategy in 2013 and 2014 as shown below


Drawdown is 54%, profit factor 2.67

 

But, in 2014 it shows much better results in terms of drawdown

 

Drawdown is 23%, profit factor 2.53

So why do these results differ that much?

 

Simply because market conditions are changing so when using the same settings as in 2013 the outcome can be totally different. Therefore using a forex robot is not just a matter of plug and play, but a constant monitoring of the market to see if market conditions are changing and adjust settings in case it does. For example, if the volatility increases in the upcoming period (like a Brexit event), it means that prices will move more and therefore you need to change the price triggers accordingly. This takes time and requires knowledge. For this reason an EA is absolutely no guarantee that you will make great performances regardless what any back test shows. We believe that over 90% of Algorithmic traders are not monitoring the changes of market conditions and after the first losses appear they simply return to their manual trading where the usual human errors occur.

 

So do back test mean nothing at all?

 

No, a back test will show over a long period of time if the trading rules are solid. For example, if the percentage of winners is 56% over a period of 5 years, it means that the entry rule is good since the chance it will go back to 20% is very unlikely. The Drawdown is the most important indicator to check. So if you start using a strategy with a historical highest draw down of 20%, take into account that the drawdown you are facing could be 40% or more. The best way how to prevent yourself from having unpleasant surprises is to run an EA on a live account using defensive settings and to start with a low amount.

In case you have any questions about automated trading feel free to contact us.