Algorithmic and Mechanical Forex Strategies | OneStepRemoved

  • Articles
  • Sophisticated Web Sites
  • Automated Trading
  • Testimonials
  • Contact

Selling EAs in the MQL5 Market

April 19, 2013 by Shaun Overton Leave a Comment

MetaQuotes decided to follow the Apple iTunes model for the forex market through its MQL5 market. The company, which is the developer and owner of MetaTrader, has taken the numerous ideas of independent web sites and attempted to put them all under its umbrella.

A lot of traders have been screaming about this, especially in the past few weeks. MT4i is a popular web site that built unauthorized plugins that modified the behavior of MT4. The plugins were wildly popular. Unfortunately, they also violated the software usage agreement that forbids modifying the software.

If you want to work with MetaTrader in a commercial environment, then you are forced to play by the rules that they set. With that in mind, I wanted to write some of the pros and cons of why you might consider using the MQL5 Market.

MQL5 market web site

A screenshot of the MQL5 market web site.

Advantages to using the MQL5 Market

I read Nassim Taleb’s Antifragile a few weeks ago. A predominant theme that he loves to hit on is finding opportunities that have little downside and infinite payoffs. Selling an expert Advisors very much fits into this category.

The cost to develop one ranges from $360-540 for a normal EA. The payoff for most of my customers is the excitement of finding out the performance of their idea. After spending the development costs, the downside is 100% capped.

The thing I like about MQL5 market is that you can take advantage of a free option: a business in a box. The trader only needs to supply an EA and to trade it. MetaQuotes literally does everything for you. They market products, track the performance, do the customer service, collect the money and write the check. Not bad.

What I also like is that MetaQuotes handles the encryption and licensing of the product. Hundreds of customers casually inquired about the possibility of selling their expert advisor over the past 5 ½ years. Very few of them decide to go forward.

The reason is that it takes tons of times (i.e., it’s expensive) to develop the security protocols and encryption to control access to the file. Integrating with a payment processor like PayPal makes it even more expensive.

Most people ask about selling EAs on a whim. It’s not worth spending several thousand dollars on.

MetaQuotes’ system eliminates the hurdle. Potentially selling your expert advisor is as simple as registering the product on their site and filling out a form.

Are your odds of success very good? No.

But you’ll at least have the opportunity to succeed and don’t have to do anything beyond filling out forms for 5 minutes. The better question is, “why not to do it?”

VAT

EU based traders might seriously consider using MetaQuotes simply because of the absurd VAT rates in most of Europe. MetaQuotes charges a 20% commission for selling trading products.

VAT in most of the EU countries that I know of are already higher than 20%. Starting in 2015, EU businesses will be required to collect and track VAT payments for each country where the end customer resides.

Tracking all of those details is insanely complex and time consuming. It’s cheaper to pay MetaQuotes the 20% commission. Doing so also avoids the hassle of reporting and collecting different VAT across the whole EU.

Cons

The disadvantages only affect people with experience running online businesses. I own a successful online business. The challenge of marketing a product online doesn’t intimidate me the way it does to someone who has never done online marketing.

My sales come from the relationships with people. I build those connections online through the web site and the company Facebook and Twitter accounts. When a customer makes a purchasing decision, it’s because they know and trust me as a person.

I see that relationship as the absolute, most critical element in running any kind of business. So, what happens if I lose control over that relationship and hand it off to MetaQuotes?

The business owner blends in with the crowd. MetaTrader 5 isn’t even that popular, but there are already 250 different expert advisors for sale. There’s slim hope of a product standing out from the crowd if setting up a page on MQL5.com is the only marketing strategy.

Customer Profile

The majority MQL5.com visitors come from countries where Western prices seem exorbitant. Yes, a handful of those visitors can afford the $1,000+ price tag that most good strategies charge. As a percentage, though, it’s tiny.

Alexa, the traffic ranking site, is only good for rough approximations. Click the audience tab and scroll the visitors by country section. Alexa says that the US and Australia only form 10% of the MQL5 site’s total traffic. Not good.

Russia makes up the biggest traffic source with 18% of the traffic. Unless you’re thinking of a Muscovite billionaire oligarch, it’s not a country that you associate with disposable income. Most of the other countries in the list have similar profiles.

Vendors on the site more than likely come from similar countries. I can’t help but think of my friend Ardi, who comes from a city in Indonesia where a couple hundred bucks of month is a good income. He’d be willing to sell a quality expert advisor for $99. That’s a lot of money to him.

There are many Ardis out there for every Aussie or Brit that wants to sell his quality product for 900 quid. The price points look ridiculous when you are 5x more expensive than the average seller.
The 20% commission and loss of control over payments doesn’t seem appealing, either. If the strategy is to put up a page and get sales that you otherwise would not have gotten, then fair play.

Any sane business owner is happy to pay a commission on sales he couldn’t do on his own.
That said, using MQL5 as the exclusive marketing strategy doesn’t seem like a good idea, either. I flipped through a couple of the EAs for sale. Not one page contained a link to a sales page with more information. You can put up your one page description, and then that pretty much has to be enough to get someone to pull the trigger.

Conclusion

One of the guys in my bible study owns an online marketing company. We were chatting about web sites the other day and how important social media is to driving traffic.

He mentioned how so many customers approach him the goal of selling their products online. The first question that he asks a new customer is, “what is your marketing strategy?”

When they usually respond, “Um, I don’t have one,” he likes to joke that it’s a Field of Dreams web site. If you build it, they will come.

Anyone with online marketing experience gets the joke. Nobody shows up at your web site, and they certainly don’t buy products, just because you have a page. It takes time and effort to build a relationship with the customer.

I don’t see that happening on the MQL5 market, either now or in the future. MetaQuotes is a large company, so I’m sure that somebody will buy something. It probably won’t be your product.
I wouldn’t put more time into the site beyond the 5 minutes that it takes to fill out the forms. It is, after all, a free option.

Filed Under: MetaTrader Tips, MQL (for nerds) Tagged With: expert advisor, MetaQuotes, metatrader

MQL Debugging

March 6, 2012 by Shaun Overton 1 Comment

MQL is a very simple scripting language. Debugging MQL, unfortunately, is not easy at all. The MetaEditor compiler that MetaQuotes supplies simply does not contain the sophisticated tools that most programmers are accustomed to using.

MQL debugging problems

Visual Studio and other sophisticated IDEs (integrated development environments) contain a number of features that make it easy to debug code while the programmer writes it. The biggest example of this are break points. A break point is a point in the code where the compiler tells the computer to cease running the program when it arrives at a certain line of code.

Consider the example where a trailing stop sets the new stop incorrectly. The natural instinct for most programmers would be to run the expert advisor on the visual backtester, then insert break points on the lines of code shortly after the trailing stop calculations. Break points halt the code, allowing the programmer to peer inside the brains of the software to see what it thought at the time it made a decision. The key advantage in Visual Studio is that the values of all of the variables are clearly visible. It is possible to walk through the program step by step. Whenever one of the steps does not follow the desired rules, the required change is usually obvious. MetaQuotes thankfully included break points in MQL5. They are not available in MQL4.

The lack of full intellisense support affects my programming speed more than anything. Intellisense detects the use of reserved words like OrderSelect() or ObjectGet(). The MetaEditor includes a rudimentary intellisense, but it lacks the fine details that make it so convenient in Visual Studio.

I am used to programming in C# where I can type the first few letters of a variable or class, then the IDE fills out the rest. When I type “Mes” in C# and push the space bar, I know that the MessageBox option will appear (assuming that I declared the appropriate namespace). The MetaEditor provides a list of candidates for reserved words. The programmer must then either select the option with the mouse or press enter.

I know it seems trivial to require pressing enter instead of the space bar, but think about how many times code resuses the same reserved words or variables. The extra key presses really do add up to a lot of unnecessary typing motions. That’s doubly true for a thirty year old that already wears a wrist brace for carpal tunnel pain.

The MetaEditor’s biggest weakness is that it does not detect variable names. We often write expert advisors that contain several thousand lines of code. Tracking the names of tens of variables poses its own challenges. When the coder types in the same set of variable names repeatedly, it would be nice to simply type the first three letters and move on. Copy and paste might provide a decent alternative. The problem is that variables usually group together. You cannot keep 5 different copy and paste items readily available.

The MetaEditor allows functions to return invalid types. Functions declared as double can return strings, integers or nothing at all. The MQL4 compiler does not track whether or not these are valid. It leaves it up to the programmer to discover the invalid type during real time testing. This oversight is a nightmare for the unwitting programmer that mistakenly returns the wrong type.

This is doubly true when a double function is mistakenly returned to an integer variable. MQL4 does not prevent illegal double to int casts. Even worse, the expert advisor continues running with a 0 value for the interger instead of throwing an exception or error message. I cannot count how many hours that I’ve wasted tracking down variables that look perfect, only to realize that I declared the wrong data type. This usually happens when I’m on autopilot, pounding out code. What seems efficient at the time usually costs several hours of hair pulling frustration.

MQL debugging techniques

The MQL programmers on staff here usually resort to any of the following techniques. You may find that using them in combinations helps improve the debugging process even more.

Debug compiler error

This one can be the most frustrating. The MetaEditor attempts to hint at which line of code causes the compiling error. I say attempts because it gets it wrong more often than it gets it right. There’s nothing more irritating than looking at a perfectly legitimate line of code that the compiler flags as problematic.

I almost always resort to commenting out increasingly large sections of code until the error disappears. I start with commenting out a single line of code. If that doesn’t work, then I comment out ten lines. If that doesn’t work, I might comment out entire functions or sections of code. When the compiler finally runs properly, you know that the last section of commented out code contains the bug.

Next, you backtrack. Start making the offending commented-out section smaller and smaller until the error reappears. Now, you have finally zeroed in on the actual source of the problem.

Debug in real time or on the backtester

My preferred method of debugging is to comment most of the relevant decision information onto the screen, which is done using the Comment() function. I then run the visual backtester, watching how the data behaves in relation to the visual information.

On screen comments are essentially jury-rigged break points. Controlling how and when they appear allows the programmer to step through the code to uncover the issue. The only difference is that comments do not forcefully prevent the code from running. The text which appears is very small. Aside from that, I really like that fact that it’s so robust. The comment function always works without a hitch, making it the best friend of a programmer that’s debugging code.

Taking screenshots takes this to the next level. Whenever customers ask questions about why an expert advisor behaved a certain way, the easiest answers come with screenshots. Commenting the imitation break points usually provide bullet proof answers – the programmer and customer can literally see what the EA thought at the time it made a decision. MQL4 offers the WindowScreenShot() function to do this.

The EAs that we program always take screenshots during critical actions, such as entering a trade or adjusting an exit condition. The goal is to provide a visual record of every decision with an eye to answering future questions about the behavior.

Our default template includes a true/false variable called WriteScreenshots. Traders control whether they want to bother with this debugging feature or not. The only downside to it is that every recorded action eats up about 50kb of hard drive space.

Log files represent the final debugging option. The major drawback is that they are so ugly and difficult to read. I almost always prefer screenshots for this reason.

Nonetheless, log files do have their place. The main way to use them is as error catchers. Whenever a process goes awry due to a problem with either MetaTrader itself or with a broker transaction, the log file is the easiest place to catch it.

Debugging MQL files is a skill that takes awhile to learn. The tools at the programmer’s disposal are much different from those available to higher level languages. Once you get used to working with the much simpler tools in the MetaEditor and MetaTrader, the bug clearing process usually gets much easier.

Filed Under: MetaTrader Tips Tagged With: break point, comment, log, metaeditor, MetaQuotes, metatrader, mql, MQL4, MQL5, screenshot, Visual Studio

Optimize an Expert Advisor

February 20, 2012 by Shaun Overton 1 Comment

One of the lesser known features of the MetaTrader backtester is the optimization feature. It’s so small that you could be forgiven for overlooking it.

Optimization is the process to maximize a certain outcome. In this case, it’s profit. Any EA developer wants to maximize the amount of profit made over a given period of time. The MetaTrader optimizer allows the trader to search for the combination of inputs that yielded the maximum profit over a given period of time.

The process is identical to running a backtest, except that MT4 runs multiple backtests at the same time. It then organizes the results and offers up the best combination.

Telling the backtester to run in optimization mode is easy. Simply put a check next to the word Optimization. MetaTrader will then sort through the combinations that you tell it to consider.

MetaTrader EA Optimization option

Place a check in the box next to Optimization in the MT4 backtester

The next step is to click on the Expert properties button to the right. A new window appears that contains three tabs: Testing, Inputs and Optimization. These screens allow the trader to inform MetaTrader which variables to consider for testing and how to weight the results.

Testing

The top of the testing section applies to every type of backtest. Here you can select the starting balance. MetaTrader defaults the option to $10,000, although you can make this any amount of your choosing.

The second default option allows the trader to restrict the direction of trades. It’s a frequent expert advisor programming request. It’s also one that is unnecessary. Both the backtester and expert advisor options screen allow the trader the option of restricting trades to long only or short only without additional programming. If the EA is not well programmed, this setting may cause errors 4110 or 4100 to appear all over the trading journal. It’s harmless. The only effect should be that the backtester slows down. It’s the result of writing to the journal hundreds of times or more.

The testing tab of the MetaTrader backtester

The testing tab of the MetaTrader backtester

A groupbox appears underneath these options that inexplicably relates to the optimization process. You’d think it would make more sense to place it in its namesake tab. That’s typical MetaQuotes logic at work.

The first line contains numerous parameters for choosing the best option. User overwhelmingly select for the largest account balance, but other options include the profit factor, expected payoff, maximum drawdown and drawdown percent.

The last line automatically uses a genetic algorithm. Optimization processes use either brute force methods or genetic algorithms. Brute force strikes most people as intuitive although obviously exhausting. The software tests every combination possible. Genetic algorithm’s attempt to make the process more intelligent. When the software sees that certain parameters almost inevitably lead to a losing performance, the algorithm skips similar tests where it expects to lose.

This is a great idea if you have a quality genetic algorithm. My opinion of the MetaTrader backtester is less than stellar. I don’t feel very confident about the algorithm at all. If you don’t mind spending extra time waiting for test results then I suggest unchecking this option. You don’t want to miss a potentially important combination.

Inputs

Most people find this screen confusing. The first column, called value, strictly controls inputs for simple backtests. The Value column is totally ignored during an optimization run.

The inputs tab of the MT4 backtester expert settings

The inputs tab of the MT4 backtester expert settings

The important columns for this task are Start, Step and Stop. Start is the lowest number that the MT4 backtester will consider. Step refers to the interval between the lowest value and the highest value. Tightly controlling this setting allows the user to gain quick insights into how changing the variable values affects performance without dragging the tests out for a full week. Stop is the highest number that the expert advisor will use.

The most obvious candidate for testing in this example is the Take Profit value. The default setting is listed at 50. If you trade the majors, you might want to consider settings ranging between 10 pips and 200 pips. That means that you set Take Profit row to 10 for the Start column and 200 for the Stop column. The real trick here is selecting the Step. If you choose Step = 1, then MetaTrader will run a separate test for every value between 10 and 200. That’s 190 tests, which is overkill. A step of 10 cuts the total number of tests down to 19.

Optimization

This section is the nit-picky part. If a trader feels it’s unacceptable to have 10 consecutive losses in a row, he can place a check next the the Consecutive wins box. MT4 automatically discards any tests which yield a result that contains anything checked off.

The optimization tab in the MT4 backtester expert properties

The optimization tab in the MT4 backtester allows users to discard tests with undesirable traits.

When you finish going through each of the tabs, push OK in the bottom right corner. It’s time to launch the tests.

Curve fitting in the MT4 Optimizer

A word of warning: my personal opinion is that optimizing an expert advisor is usually a very bad idea. The unique settings that yield the most profit in 2012 are unlikely to yield the most profit in 2013. If you don’t control for random chance, there’s a good probability that the 2012 best combination may result in catastrophic losses in 2013.

I recommend that traders pursue any strategy development work in NinjaTrader. I don’t like the idea of optimizing at all. Instead, I always focus on testing strategies for entry and exit efficiency. I know from years of experience that these values never fundamentally change on instruments of the charts traded. Entry and exit efficiencies make wonderful metrics for automated trading because they are so stable.

Filed Under: MetaTrader Tips, Test your concepts historically, Trading strategy ideas Tagged With: backtest, backtester, brute force, curve fitting, drawdown, EA, expert advisor, genetic algorithm, inputs, MetaQuotes, metatrader, mt4, optimization, optimizer, profit factor, Take Profit, testing

FREE trading strategies by email

Trending

Sorry. No data so far.

Archives

  • Dominari
  • How does the forex market work?
  • Indicators
  • MetaTrader Tips
  • MQL (for nerds)
  • NinjaTrader Tips
  • Pilum
  • QB Pro
  • Stop losing money
  • Test your concepts historically
  • Trading strategy ideas
  • Uncategorized
  • What's happening in the current markets?

Translation


Free Trading Strategies

Privacy PolicyRisk Disclosure

Copyright © 2023 OneStepRemoved.com, Inc. All Rights Reserved.