Skip to main content


Showing posts from 2019

Common MQL4 Functions Library

Description Top-quality MetaTrader 4 library with different functions to support you with improving your returns. All functions were tested thoroughly and optimized for minimal speed and latency.

Calculate orders profit based on type:
double LongOrdersProfit(string argSymbol) export double ShortOrdersProfit(string argSymbol) export
Close orders based on a specific condition:
bool CloseOrder(int argOrder) export
bool CloseOrder(int argOrder,double argLotSize) export bool CloseLongOrders(string argSymbol) export bool CloseShortOrders(string argSymbol) export bool ClosePendingOrder(int argOrder) export bool CloseAllPendingOrders() export bool CloseAllProfitingOrders(string argSymbol) export bool CloseAllLosingOrders() export bool CloseAllOrders(int argMagicNumber) export bool CloseAllOrders(string argSymbol) export bool CloseAllOrders() export
Verify the lot size is valid for this symbol:
double VerifyLotSize(string argSymbol,double argLotSize) export

Calculate lot size based on risk paramete…

Mutual Exclusion (Mutex) Implementation in MQL4

Introduction In computer science, mutual exclusion is a property of concurrency control, which is instituted for the purpose of preventing race conditions; it is the requirement that one thread of execution never enters its critical section at the same time that another concurrent thread of execution enters its own critical section.

In Algotrading, you may encounter this situation while:
Running several expert advisers using a shared object which may worked on only once and not in parallel.Trading only in certain conditions, for example allowing only one expert adviser to open a position while the other ones are blocked. In my case, I am running several expert advisers on the same account trading different currencies. But, I wanted to have only one product open at a given moment while the others are blocked. So, if for example both EURUSD & EURJPY have the right conditions to open an order, only one order will be open. I wanted to avoid to be double exposed to products which are c…

MetaTrader 4 Indicator to show Currency trend in Different Timeframes

Usage When trading, you probably have several windows open next to each other, different products, different time frames. Or, you have the same product but in different timeframes to see how it performs.
I wrote this indicator so I can see for a given product, how it behaves in the different timeframes available by MetaTradre 4. It has three different lines to express the following information: The trend for a given timeframe, blue arrow means bullish, red arrow means bearish.The pips change for a given timeframe, blue text means bullish, red text means bearish.The standard deviation for a given timeframe, red text means that the timeframe movement is higher thatn the volatility, otherwise black. Once attached, a panel will be drawn in the lower left corner as in the following screenshot for EURUSD:

You may see, that the daily trend for example is bullish. And that the hourly movement in pips is higher than the volatility, thus the STD value for hourly timeframe is painted in red.

To …

Looking back at 2018 and forward to 2019


Every year brings with it 365 opportunities to make a difference, so did 2018 and so will 2019. The last was very exciting and challenging. Since going live with my algorithmic strategies to the public, it a was a roller coaster. As soon as you expose your ideas and start getting an inflow of investors it's a whole new and different experience.

The challenge we face as FX traders, specifically as retail ones is that we don't have enough equity to make a living out of the trading, which drives us to take more risky positions with insane leverage hoping this will make us overnight rich. Of course, in reality the market has its own rules and most of the traders gets punished for acting foolish, seeing their account gets blown. This is one of the reasons that 80% of retails traders lose money on average, a figure which can be seen on many FX brokers sites:


Lessons Learned

In 2018 I learned the hard way how risk management is critical. I got burnt with GBPUSD crash in …