Skip to main content

Posts

Showing posts from 2017

Using the Donchian Indicator to enhance your Trading

The Donchian channel is available for purchase here.



Richard Davoud Donchian was an Armenian-American commodities and futures trader, and pioneer in the field of managed futures who came up with a simple intuitive indicator called the Donchian channel. It is basically based on the lowest low value or the highest high value in a given period of time:


Calculation

As mentioned, Donchian is based on marking the lowest low line or the highest high line, so visually you see the trend of the product. Whenever the product reached a value which is higher than the last 24 values or lower than the previous ones, a new markup will start until it reverses.
Calculating it with MQL is straightforward, to find out the highest value of the product in a given period, we use the following snippet:
double HighestHigh=iClose(Symbol(),Period(),iHighest(Symbol(),Period(),MODE_CLOSE,TradePeriod,0));

Here, reading from right to left, we first find the shift of the highest value using a call to iHighest, and then, u…

Checking Metatrader connectivity

When running Metatrader locally, the first action the platform does when it starts up is connecting to the near by broker server. You may it clearly by looking at the lower right part of the platform and checking the connectivity status:



In this case, you may see it is green and traffic is floating successfully between the terminal to the server. If from some reason, there is no connectivity, this terminal section would look like:



Manual solution

The manual solution is quite straightforward, mainly close and reopening the terminal. The challenge is knowing the connectivity got lost at the first place. When it happens, there is no way to tell unless you write the code which tells you the connectivity got lost. Once you know it happened, you need to restart the terminal and hope the problem got sorted out. If it continues, you can either scan the available serves or contact your broker.

Automated Connection monitoring

As noted above, it is challenging to know when the connectivity is lost if…

How to safely open an order in MQL4

All the functions discussed here are part of the Common library available for purchase.



In trading, it's critical to confirm certain criteria and conditions before opening an order. These checks may impact on your profitability or notify you in case something failed.

My checks

For me, it's important to verify before opening an order in MQL4 the following conditions:
- Is the spread acceptable? i.e. whether it's below a certain fixed value which I predefined.
- Is the trade context busy? This thread is the one which eventually opens the orders, if busy, it will not be possible to open the order anyway.
- Do we have enough margin to trade? As noted here, margin is critical factor when trading and could make a difference between a successful account to wiped one.
- Check open order returned value. As per MQL4 specifications, open order returns the order id which was opened or -1 in case it failed - https://docs.mql4.com/trading/ordersend. It is a good practice to check the value bef…

Forex correlation calculation with MQL4

All the functions discussed here are part of the Statistics library available for purchase.



While watching Wimbledon finals yesterday in the UK. I was thinking of all the significant economical events we are going through in Europe, the Brexit, elections etc. and how are the different pairs I am trading got affected. The statistical value which show the significance of the dependency between two products is called Correlation.

According to https://en.wikipedia.org/wiki/Correlation_and_dependence, Correlation can be calculated using the following equation:

Correlation(EURUSD,USDJPY)=Covariance(EURUSD,USDJPY) / STD(EURUSD)*STD(USDJPY)

Correlation ranges between -1, that when EURUSD trends upwards, USDJPY expected to trend downwards. 0, meaning there is no dependency between these currencies at all. Or +1, meaning the currencies are expected to trend in the same direction.

Why would you care?

EURUSD and EURCHF have correlation of -1 in most of the times. Imagine you went long on EURUSD believi…

The MQL4 Lot Size Functions I Use In My Algotrading Code

All the functions discussed here are part of the Common library available for purchase.



The goal of this post is to share with you some functions I am using to verify and manage the lot size I used when opening an order. As mentioned in my home page, I am using proprietary algorithm to trade the 25% cash I don't invest in the permanent portfolio. To achieve that, I programmed an Expert Advisor using MQL language which is running 24/5 and trade 5 currency pairs. In here, you can find the relevant darwin which can be traded as a normal financial product thanks to the Darwinex broker.

Managing Lot Size

As noted in another post about leverage, it is important to keep the leverage / lot size under control. Most common junior mistakes are trading massive lot sizes to gain quick wins, but as soon as the market turns against them, their account is completely wiped out without a chance to react (speaking from experience). So, in this post I will share three functions I am using to verify and …

Swiss Permanent Portfolio Performance H1/2017

The first half of the year is over, time to check the Swiss permanent portfolio performance. As per the definition set by Harry Brown, the permanent portfolio should consist of 4 pillars:


Equities
Bondsbonds.
Gold
Cash


Swiss Permanent Portfolio Version

Using the above template as basis and as explained in here, I split my investment within 3 funds:


AUCHAH - The fund aims to primarily reflect gold's performance, after deduction of the running costs. The fund's assets are exclusively invested in physical Gold.
CSBGC0 - The fund invests exclusively in bonds and other fixed or variable-rate debt instruments and rights, denominated in Swiss francs, of the Swiss Confederation, which are included in the Swiss Bond Index Domestic Government 7+.
SPICHA - The fund's investment objective is to replicate the price performance and returns of the Swiss Performance Index SPI(R). The SPI(R) comprises the about 230 largest stocks in the Swiss equity market.
Cash - Using my own proprietary algorithm …

Leverage Explained

It is such a common confusion among FX traders to mix up between the leverage offered to them by their broker with the actual leverage they are using. So, I decided to dedicate a post focusing just on this topic.

Leverage - what is it all about?

As per Wikipedia leverage enables you to buy an expensive product with borrowed funds. A classical use case is the mortgage one pays on his house - assuming a house costs 1,000,000€ and a person has only 200,000€, the rest he will borrow from the bank and use it to buy the house. So actually, using his own funds, he is able to control much more value than he actually has. The risk associated is defaulting on the original mortgage, as a person who can't pay and sustain these leveraged funds will loss it all and the bank will posses his property.

Leverage works both directions, on one side it enables you to control more value and enhance your profits, on the other hand, it also magnifies your losses. That is the basic, the ground which we will …

Guest Post: Hack your retirement nest egg with this one simple trick

All financial planners talk about the importance of setting goals and planning for retirement. They’ll recommend automating your savings plan with a set and forget monthly deduction. And they’ll share how to supercharge your contributions by optimizing taxes and finding your ‘latte factor.’

I’m ok with all of this but it misses a huge point. The reason most people don’t plan properly and don’t save enough is because saving requires sacrifice. Saving requires forgoing something now in favor of having more of it in the future. That’s not a bad deal but it’s not natural behavior to want to go without and most of us hate it.
Want to improve the quality of your retirement? Improve the quality of your life now.
Saving is of course very important. The sooner you start to get compound interest working for you and build a capital base that is generating cash for you, the sooner and richer you can retire. That's a fact.

But there’s a better way to look at it than just carving out savings from w…

Guest Post: Why 46% of financial planners have no idea how much they will need to retire

How do you feel about working hard and going without your whole life only to miss the one thing you can’t buy? Time. My guess is your answer is: ‘not great.’

But lots of people work hard their whole lives, save their whole lives. They live an average life and they live an average retirement. Simply because they never bother to plan.
When it comes to retirement goals you want to focus on the lifestyle, not the number
It’s often said that the state your life is in is a reflection not of your achievements but of the quality of the goals you set for yourself. That’s the truth.

The real difference between you and the most successful person you can think of is that they did what they did and you did what you did.

Success is not inherited: Steve Jobs, Larry Ellison and Jeff Bezos were all adopted. And it’s not favor: Nelson Mandela changed the world from the inside of a prison cell. It’s a question of knowing what you want and focusing on that.

Granted, knowing what you want is a tough question fo…

3 financial planning mistakes that could cost you everything

Let me give you the best financial planning advice you will ever get in just two sentences. Start early. And invest in assets that generate an income.

There are scores of blogs with advice on personal financial planning and retirement planning. You can find excellent tips on strategies for saving more, optimizing asset allocation and rebalancing, and tax optimisation and succession planning. But it’s those two irrefutable laws that an eight year old can understand that could shortcut a whole industry.

Start saving early, ideally with your parents socking away money in a trust, and you’ll have time and compound interest on your side. Invest in income generating assets – blue chip stocks, bonds and real estate – and you’ll retire earlier and richer than you could dream of. These are simple facts.

But what if that’s not the way things have played out for you? For whatever reasons. What if you had a couple of setbacks or haven’t really gotten started yet? It’s still important to look after y…