Algorithmic and Mechanical Forex Strategies | OneStepRemoved

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

How to Create a Synthetic Instrument In MetaTrader 5

January 2, 2018 by Shaun Overton Leave a Comment

The last version of MetaTrader required offline charts for anyone that wanted to create a synthetic currency pair or instrument. Since MetaTrader 5 still does not allow for offline charts, the ability to create synthetic time frames isn’t possible using the charting time series.

The new build 1640 for MT5 introduces the ability to create synthetic instruments. I, for example, want to watch VIX Calendar Spreads. Instead of just using my indicator, I also would like to see a chart that helps me track the calendar spread.

VIX calendar spread

A synthetic instrument chart displaying VIX Calendar Spreads

Market Watch MT5

How To Create A Synthetic Instrument Chart

Right click on the Market Watch window (look to the image on the right). You’ll see Symbols appear in a dropdown menu. Click on it.

Alternatively, just push Ctrl + U on your keyboard.

Create Custom Symbol MT5

Now enter in the Synthetic Instrument name. The name can be anything that you choose with allowed characters.

The most important step is to enter in your formula. As you can see in the image below, mine is a symbol subtraction. The primary keywords that you’ll use are bid() and ask(). So, if you want the bid of EURUSD, for example, you type in bid(EURUSD).

Finally, make sure to set the number of digits in your instrument. Otherwise, your chart will show a large number of unwanted, extra decimals.

Filed Under: MetaTrader Tips Tagged With: metatrader, synthetic, synthetic currency, VIX

Working 8 days a week

December 6, 2016 by Shaun Overton 22 Comments

Reaching an all-time high in my equity curve means it’s time to buckle down and keep improving. My Dominari strategy has done very well over the past 7 months and especially this and last month.

Dominari Equity Curve December 6, 2016

Is the party going to continue?

I certainly expect so. Drawdowns are inevitable, but that’s part of trading. Short-term performance is exciting, but my ambitious goal is to turn my starting balance of €8,000 into €50,000 within the next 3 years. As of this writing, I’m at €9,323.

You’re probably wondering how a 16% profit leads me to extrapolate an annual return of nearly 100%. The answer is that I dramatically changed my leverage at the end of September… just in time for that ugly drawdown. If I was trading on my current leverage, the current live return would be around 40% (i.e., right on track to hit my goal).

What really counts is what I’ve really done. So far, I’m up €1,323 with another €40,677 to go by December 6, 2019.

The research for Dominari is effectively finished. It’s been slightly more than a year since I began researching the strategy. Although minor variations of Dominari popped up or came from traders copying my signals, none of them improved the long term outcomes.

One version that improved the risk profile was to trade with limit orders. The original blog post mentioned limit orders, but the variation placed them considerably further from the current market than what I tried previously. I also lacked a system for choosing settings appropriate to every pair, which I’ve more than likely resolved. The problem is that I have a million things on my to-do list and only 8 hours a day. You’ll see some of my top projects when you scroll down.

Pilum: The latest and greatest

Pilum is a strategy based on a statistical process that identifies momentum. One of the scary elements about most quantitative strategies is that most of them are mean-reverting. They buy when the price drops and sell when the price rises. The approach is favorable (i.e., profitable) in the long run, but it takes some psychological fortitude to trade.

Pilum is a major advancement because now I’ll have a strategy that should profit exactly when Dominari is most vulnerable to a drawdown.

dominari trade outcome histogramThe new strategy uses limit orders to enter the market. Something like 90% of these orders never execute. But when they do execute, I win 75% of the time. Additionally, my profile of winners to losers is very comfortable.

Most traders understand the ideas even if the statistical jargon is unfamiliar. Pilum’s biggest winner is larger than its biggest loss. The average winner is bigger than the average loser. And, it wins 77% of the time.

Pilum trade outcome histogram

So far, I’ve done a sort of piecemeal backtest using R. When I finish the Quantilator (see below), I’ll redo the backtest in a fully fledged trading platform. More than likely, I’ll use QuantConnect to test the strategy level approach.

Trading platforms drive me crazy! The biggest problem that I have as a trader is continuously reallocating capital across my portfolio. MetaTrader, NinjaTrader and the likes implicitly assume that I want to trade some percentage of my account balance on every trade. Either that, or that I trade fixed lots.

Trading that way is extremely inefficient. I’m trying to trade 40+ currencies, so I need to be able to decide which ones need the money for trading and which ones don’t have signals. Then, among the ones that do have signals, I need to dish out their allocations proportionately. The allocations aren’t the same for each instrument. If you know of any good FX platforms that meet this requirement, then let me know in the comments section.

Testing Pilum on its own is important. More important than the performance of Pilum is how that performance interacts with Dominari. That means taking the daily equity values of each currency. Does Dominari lose when Pilum wins and vice versa? Should I allocate capital 50-50 between the strategies or does one strategy deserve the lion’s share of the portfolio? Is one strategy so good that it should get all of the money?

The main concern with portfolio allocation is how it relates to leverage. Dominari historically make 96% annual returns, inclusive of trading costs. But, it’s also trading with leverage of roughly 19:1. It’s possible for markets to rip over stops and create significant losses.

USDCHF lost 40% of its value in one hour in January 2015. Say that the scenario was even more extreme and that nobody could place a trade during that time at any price. That 40% move is multiplied by the 19x leverage used. That’s a theoretical 800% loss; more than the money in the account.

Everyone loves leverage because they think of profits. Leveraging losses is a lot less exciting.

So, if you could earn 96% annual returns and only use 5:1 leverage, that is exponentially superior to earning 96% on 19:1 leverage. I need to compare the returns of Pilum to Dominari per unit of risk. That allows me to do cool things like

  • Minimize the negative variance of the returns
  • Increase absolute return
  • Dynamically increase/decrease strategy allocations if I find patterns in their interactions

It’s a lower tech way of averaging strategies, like the litte guy’s version of what Numerai is doing… except that I have to create all of the strategies myself.

Quantilator

I spent the last few months sending surveys to segments of my subscribers asking how I can better serve you. Articles about indicators are overwhelmingly my most popular content. The trouble with that content is that I can’t complete the research fast enough to keep up.

The most valuable thing I’ve learned from the developing algorithms for the past 11 years is my process of deciding whether or not an indicator offers predictive value.

Moving Scale

Say that you’re interested in gaps: do gaps predict future returns? What I normally do is code a gap indicator in R, implement my analysis methodology and give a verdict. My methodology is kind of like a system for building systems. Using my approach usually takes an hour for every new idea that comes along.

An hour is pretty short. An hour is REALLY short compared to when I didn’t have a research methodology. I used to waste months on junk strategies.

With Quantilator, I’ll be able to analyze anything in under 5 minutes. I’ll only have to follow 3 steps:

  1. Run a script in MT4 to export price data and indicator data
  2. Upload the exported data to Quantilator
  3. Analyze the results

This tool will be 100% free. I’m planning to go through the most popular indicators in MetaTrader to analyze whether or not they offer an edge. I’m building a library of small edges that can be combined into powerful strategies like Dominari and Pilum. And, in the spirit of open source, I plan to make that library available to you for free.

I’m writing this tool in Django, which is a Python framework for displaying web content. The initial version will do the analysis. I’m hoping to use this as an education tool. A bit of momentum can justify make it a fully fledged library with sample data, indicators and training videos and more.

Quantilator’s name comes from a key concept in my system analysis methodology; I break data into quantiles. These quantiles calculate average market returns for a given period of time. The quant in Quantilator refers to quantiles, but I really like the implied double entendre of making you a quant. After all, that is what I’m doing for you!

Update: The Quantilator is now freely available at http://q.onestepremoved.com/

Filed Under: Dominari, Indicators, Test your concepts historically Tagged With: backtest, metatrader, portfolio allocation, portfolio systems, python, quant, QuantConnect, quantile

How To Build a MetaTrader Risk/Reward Tool

February 5, 2014 by Andrew Selby Leave a Comment

The key to trading success is having a solid understanding of the risk your capital is exposed to and how that risk relates to potential profits. That is the reason that we are constantly breaking down how the average annual profit of a strategy relates to its maximum drawdown. In order to understand a strategy, we have to understand how each of its trades work from a risk/reward perspective.

metatrader

Using the Fibonacci tool in MetaTrader, we can create our own risk/reward tool to evaluate trades.

Nial Fuller from Learn to Trade the Market is a strong advocate of risk/reward analysis. In a recent post, he said:

It is critical to understand that most traders who are successful over the long-term are not winning more than about 50% of their trades, but it doesn’t matter as long as they are harnessing the power of risk / reward.

In that post, Nial breaks down the tool he uses to analyze the risk/reward for each of his trades. He provides a simple walkthrough for how to build his risk/reward tool in MetaTrader. The tool is constructed by adjusting the settings of the Fibonacci tool that is already built into the program.

How To Construct The Risk/Reward Tool

In his post, Nial explains that his risk/reward tool is basically a modification of the built in Fibonacci tool. The first step to construct the risk/reward too is to open the Fibonacci tool, then right click on it and go into Fibonacci properties.

The next step is to set a stop-loss level. The distance between the entry price and the stop will define the 1R distance that all of the reward projections will be based on.

After the 1R distance is determined, Nial’s next step is to delete all of the other levels from the fibonacci tool except for the levels that mark the entry and stop prices. Then, the final step is to add profit targets as levels that are mulitples of that 1R distance.

After completing this simple tweak on the fibonacci tool, you will have an overlay that provides you with a visual representation of your current trade in relation to your strategy’s profit and loss targets. This visualization can provide interesting insight into how likely a given trade is to hit whatever reward level your system is anticipating.

Advantages of Using a Risk/Reward Tool

Nial also covers the fact that there are many positive uses for a risk/reward tool like the one he describes.

The biggest advantage is the ability to quickly and visually identify profit targets. In theory, this should make planning trades much easier. The tool will make this process much faster, which will allow a trader to process trades quicker.

The tool also allows the trader to experiment with how adjusting the stop level will alter the profit target levels. It can also be used as a method of filtering out good and bad trades, or as an early exit signal if a trade fails to perform after a certain period of time.

 

Filed Under: Trading strategy ideas Tagged With: Fibonacci, metatrader, risk/reward

Can my broker steal my expert advisor?

October 17, 2013 by Shaun Overton 4 Comments

I get this question often enough that it’s time to put this out on the internet. There are plenty of reasons for traders to remain wary or suspicious of their broker. If you’re using the broker’s software, can they steal the expert advisors in your account that are making money?

Steal MT4 expert advisor

Can the broker steal your EA for MT4 or MT5?

The answer is an emphatic no. I started my career working as a broker and have been involved with forex for 7 years this month. I’ve seen the backend systems and tools that the MT4 brokers use to manage clients and their positions. I’ve also seen them on the floor of one of the MetaTrader bridge companies.

The brokers use a piece of software called the MetaTrader Manager. The manager is basically a database that tracks the open positions and equity for clients. It does not have a button for sucking MT4 expert advisors from client accounts.

Filed Under: MetaTrader Tips Tagged With: broker, expert advisor, metatrader, MetaTrader Manager, mt4

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

Build a Trading Robot

April 10, 2013 by Shaun Overton 1 Comment

I talk a lot about the importance of building your trading plan. The same thing applies for building a trading robot or an expert advisor.

Most people approach EA development as digging frantically looking for huge gold nuggets. That approach is a good way to waste a lot of time and money.

Most people dive into the process without considering the details. The purpose of this post is to slow everything down so that you can develop some sort of business plan for your trading.

Steps to building a trading robot

Three long, difficult steps are involved with deploying a trading robot. You first need to obtain data for testing. A good strategy, once discovered, then needs to be programmed to automatically place trades. Finally, you need to select a broker to execute the orders in the live market.

The importance of data

A good number of traders brag about their best trades. One trade gave them a million dollar profit and other such and such.

What newbie system traders don’t realize is the tedious process of how these people reached their status. Knowing whether or not a system has an edge or not entails researching your idea using historical price data. Here are some tips that you can use when looking for data:

• You need to get data, you need to analyze it, and then you need to trade it. It is really simple on the surface, but when you are trying to go about this, every step creates huge obstacles. The easiest work around is to use the trading platforms listed at the bottom of the article.

• If you are looking for free options, you might go look somewhere like Yahoo! Finance where you can get data on lots of stuff that is mostly end of day prices. It’s no good for high frequency. You can get some options data, you can get forex and you can get some indices and some futures data.

• The reason why data quality is important is when we go on to analyze and come up with potential ways that you might want to trade algorithmically, if you have garbage data, you have a garbage analysis. Be very careful about the data that you decide to accept.

Problems gathering data

Now that we learned how important data is, we now discuss the other side of the picture in data gathering which is its disadvantages.

• Unreliable. Sometimes it’s just wrong. Sometimes there are duplicate entries. Sometimes there are gaps in the data that are unexplained. And if you don’t really know what you’re looking for, what kind of problems there might be in the data, you can come up with some weird discoveries.

• Delays. Technology bridges the information gap. But sometimes, due to time differences and the most annoying part when your broker or you are having problems on your internet connection at times, delays are inevitable.

• Clutter. There are a gazillion sources of information on the internet. This equates to a huge amount of data. Different brokers have their own set of websites and blogs which displays various analyses on a single instrument. It will now be a problem on what data will you consider credible and useful in your trade. Sometimes, analysts just anticipate most especially technical analysts posting price forecasts and so on. Those who waits for news like Unemployment rate has their own views on figures that will show up prior and during the announcement which basically creates clutter.

The Trading Platform

When you trade online, a trading platform is like your playing field. It is the software through which you manage your trades when you open, close or set limits or stops. Usually, a trading platform is provided by the broker.

There are platforms, APIs and all sorts of different companies that offer data and trading capabilities all in the same product. The advantage to those types of software is that it makes your life a lot easier because if you go about this on your own it’s a monumental task.

A lot of people that like to play with R, and you can just custom program your own research platform. Matlab and R are the most common tools in this category. The problem is that you have to build the trading components entirely on your own.

Here are some popular platforms MetaTrader, NinjaTrader, ThinkorSwim and Multicharts. All these platforms use their own different language and solve the data problem. They also include the ability to trade automatically. Most of the heavy lifting has already been done.

MetaTrader uses a custom language called MQL4, which is really a C Scripting Language. NinjaTrader uses C# .NET 3.5. Trade Station and Multicharts is a language called EasyLanguage, which for programmers will probably bore you to tears. To understand more about these platforms, you can check different brokers and their offerings.

Trading Platforms and data

We’ve covered the languages, the markets they cover and then, the other problem is really data. These platforms offer very different set-ups and they all handle the data problem differently.

MetaTrader

MetaTrader is kind of like the AK-47 of Trade Platforms. You download it and it doesn’t matter how novice or not good with computers you are. You will have a hard time not figuring out how to work the platform. It is simple, it’s very friendly. It’s also not sophisticated.

If you’re trying to do something sophisticated, that’s probably not the place to be. And for your analysis, you have to be very careful, because when you download MetaTrader, charts just pop up. You think, “Oh this is great, I got my data and everything looks good”, but the problem is that most of the time the data is junk. You can’t actually rely on it and do any serious analysis.

Getting the data and getting it formatted to MetaTrader is the most convoluted, difficult problem that traders face everyday. This is the platform that we deal with and everybody has problems with their backtesting and getting familiar.

This is good enough if you want to trade every couple of minutes and you’re not super execution sensitive and you are just trying to get something out cheaply. If you try every 4 hours and you trade 3 currencies, MetaTrader is fantastic for that.

But if you try to day trade or trade 20 different currencies at the same time, that’s a disaster, because MT4 isn’t multi-threaded. Every time you push an order into the market, MT4 can only handle it one at a time.

If you have 5 orders firing off together, this one has to finish, and you have all the latency in the middle where they connect and then bounce and the trade confirms okay. Now you repeat the process four more times to get all 5 trades filled. If you’re pushing too many orders through, MT4 will choke.

NinjaTrader

You have to find somebody to give you the data. There are some paid options, there are some, there’s one that’s free called Kinetick, and they give you end of day data. Brokerages also provide limited historical data. The quantity varies substantially from broker to broker.

The problem when you’re programming all this stuff and you’re trading in the live market, if you program to a broker specific platform, you probably spend 4 to 6 months developing and testing it and getting it working, and a lot of money and time. If you go to start trading live and you’re not happy with the broker, too bad. You married them.

What NinjaTrader did is, let’s say that there are Brokers A, B and C. NinjaTrader sits on top to bridge everything together.

NinjaTrader is an API shoved on top of multiple broker APIs so that you can write your strategy in NinjaTrader. They’ve done all the integration with every broker partner they have.

It’s a different way to handle the same problem as MetaTrader. MetaTrader just goes to these brokers and say “You should use our platform”. If you developed in MetaTrader, you can go switch on a whim.

If you have NinjaTrader, you can go switch on a whim. The difference is that you don’t just have NinjaTrader. You have to download the broker platform, then you download NinjaTrader. Then, you get everything hooked up and make sure everything plays nicely together.

There’s a steep learning curve with getting this all set-up to the point where you can actually download historical data and start trading with your broker. Once you have the data set-up, though, NinjaTrader is awesome.

TradeStation and Multicharts

TradeStation and Multicharts offer the same quality of analytics as NinjaTrader. They are easier to develop in. Obtaining data quickly makes these platforms easier for testing trading robots.

If you program with TradeStation, you trade with Trade Station. You can’t go trade with anybody else. However, if you’re ever unsatisfied with the broker because they slip you or because they charge bad commissions or whatever goes wrong with your trading, you don’t have any alternative. You’d have to move to MultiCharts or to redevelop the programming completely from scratch in another platform.

A trading robot

The Broker

Remember that your broker is your trading partner. It provides you the platform, data and most importantly the access in the market. Brokers are also service providers, and traders are their customers. It’s common for a customer to encounter some difficulties regarding the provider. There are two common reasons why a customer sometimes feels dissatisfied.

• First, bad service. When you are having difficulties opening your platform to execute a trade, you call on a customer service representative. And just like any other companies, a structured way of handling complaints will be given to you. Sometimes they can’t just give you what you need because they do not want to understand what you need.

• The second reason is bad execution. The broker is the market maker. They set the buying and selling prices at every single second. When you place a trade, they can present prices that are favorable to them. As a trader, when you know that the trend is on your side, sometimes you do not mind trading few pips higher or lower than your order. So you grab the offer. Until you realize that the broker made some hefty spread on your trades. This affects the trader emotionally and emotions should be out of trading. Emotions spoil strategies nut as a human being, it’s natural to feel upset.

Conclusion

Building your own trading robot is not as easy as ABC. It entails allot of effort in research, trying and testing trading signals and detaching every trade from your emotions. All of these steps are built on the foundation of your trading experience.

Remember that building a trading robot is anchored with the basic steps:
• Gathering and identifying the data you will use. Be very keen on what data to retain and what data will go directly to the bin. Not all data fed by your broker, articles written by analysts or data given to you by someone you know are reliable. Make sure to get the right data, analyze the data and trade using the data.

• A trading platform you are comfortable with. Before you start making your own trading robot, feel free to try different trading platforms. It’s like trying on some new pair of shoes before buying them. Do not go for something very complicated and you cannot even decode some basic functions. Remember that your platform is your playing field. It is more fun to trade through a platform you know how to operate than to get the most technical one and read through the help section while some other traders are gaining fast from a current trend.

• A reliable broker that will assist you on your trades. Your broker is your partner. It gives you data, platform and sometimes analysis in real time. Make sure to choose the broker that can give you what you demand and what you need.

If you will follow some of the above tips, you are on the right track on making your own trading robot.

Filed Under: Trading strategy ideas Tagged With: business plan, expert advisor, metatrader, MultiCharts, ninjatrader, TradeStation, trading robot

Order Retry Logic

January 21, 2013 by Shaun Overton 5 Comments

The difference between a backtest and live trading is that nothing ever goes wrong on a backtest. If a strategy traded correctly for EURUSD in 2011 yesterday, you know that the same test will work properly today.

The backtester is not designed nor is it able to catch the types of problems that occur in live trading. I made an effort to list common issues by platform and to detail the most common solutions.

 

MetaTrader

Most older EAs attached stops or take profits to its orders. The NFA rules from around 2009 require all forex trades to enter without any exit conditions attached.

The rule created a nightmare for US MT4 brokers. They were forced to go back, modify MetaTrader and disallow tickets with a stop or limit.

The solution is to confirm correct execution of a trade. Once the trade enters, only then should the expert advisor attempt to add the stop or take profit.

The rule is unfortunate as it requires additional communication time. The process slows order execution, which can cause the trade context is busy error.

order denied

These are not words that you want to see when placing live trades

Our Expert Advisor Programming Template

Kamal O. asked on Friday about the words RETRYCOUNT and RETRYDELAY in our EA template code. Those 2 words are critical for maintaining code that handles all possible situations, or at least 99.9% of them.

We set them by default to 10 attempts and 1,000 milliseconds, respectively. That is, an order will attempt to order up to 10 separate times. Each attempt will wait at least 1,000 milliseconds (1 second) before making another attempt.

In between attempts, we also check to see if the trade context is busy. If it is not, then we proceed. Otherwise, the code waits for an opportunity to submit the new order up to the specified maximum.

The same retry ad wait logic also applies to submitting stop losses and take profits. One of the most horrifying real world events that a trader can discover is an open trade with no exit conditions attached. Such things really do happen.

The same retry logic is in place in our template code to dramatically reduce the chance of that occurring. We do this for every expert advisor that we program. If you have an expert advisor that does not include retry logic, then contact us about making your EA’s source code more robust.

NinjaTrader

NinjaTrader largely handles errors and problems for the programmer. However, there are common situations where NinjaTrader’s solution frustrates the user. Disabling strategies and closing all trades whenever an overfill occurs comes to mind.

Anything but the simplest trading strategies are better handled using an unmanaged approach. Managed approaches using pending orders will almost always create a need for rewriting a strategy.

One of the most common reasons NinjaTrader users contract us relates to something going wrong with their live trading. The best way to avoid programming something twice is by making the code ready for real world trading on the first attempt.

Filed Under: MetaTrader Tips, NinjaTrader Tips Tagged With: managed order, metatrader, ninjatrader, trade context is busy, unmanaged order

Automated Trading Part II

January 7, 2013 by Shaun Overton 1 Comment

The second part in Nathan’s interview series with me focuses on the role of high frequency trading in the markets and testing trading strategies. If you missed the first automated trading interview in the series, you can read it here.

Nathan Orange(Nathan):
Do you have any specific thoughts or opinions on HFT (High Frequency Trading)? This is such a hot topic among traders and I would imagine you have a unique insight into algo trading in general.

Do you see machines eventually replacing the “human” trader or could HFT eventually get banned from the markets? At least for day traders it seems to give quite an unfair advantage to the HFT camp for executions?

Shaun Overton(Shaun):
There is a huge difference between algorithmic trading and HFT. HFT is obviously automated due to the speeds involved, but that does not imply that all automated trading is HFT. It’s only a subgroup.

 

Nathan Orange(Nathan):
Sure, there are plenty of automated systems that are not HFT. I bring it up under the context that HFT uses deceptive algorithms for their order posting tactics.

 

 

Shaun Overton(Shaun):
HFT is uniformly destructive to capital markets and their purpose. It nickels and dimes investors and traders through market manipulation. Just last week Nanex detected a single organization that pushed through 4% of all the order flow on US equities quotes. Even worse, not a single one of the orders executed. Posting orders without the intent to trade is blatantly illegal.

The other negative consequence of HFT comes from the rebates that the dark pools and exchanges pay to “liquidity providers,” which are really the HFT bots. The arrangement tangibly alters the motivation for participating in markets. Rather than investing or even speculating on price, the HFT algos generally do not care about market movements. They just want the liquidity rebate.

Nathan Orange(Nathan):
This to me is the bigger issue. The whole arrangement is shady and as you said it alters the motivation for market participation. What steps or changes do you recommend?

 

 

Shaun Overton(Shaun):
The Market Ticker blog is one of my favorites on that subject. Karl Denninger advocates a regulatory rule of a two second minimum order time. I support the idea. Nobody can plausibly claim that an order placed for such a short duration is for any trading purpose. If an order is not intended to be filled, it should be not permitted.

 

Nathan Orange(Nathan):
I cannot argue with that logic. Back to testing, how important is accounting for commissions and slippage to the integrity of any back-testing data in your opinion? To me, as you go down the scale from longer term trading to day-trading the importance grows exponentially.

 

Shaun Overton(Shaun):
I fully agree. The consequences of trading costs pile up with increased frequency. Shorter time frames multiply the frequency, which as you pointed out, grows exponentially.

My personal preference is to skip trading costs and commissions on short time frames so that I can obtain a sufficient sample size for my analysis. I do not foresee myself ever trading on one minute charts, but I almost always use one minute tests to analyze randomness within a strategy. Unlike most systems developers, the profitability of a system is a backseat concern.

I read a newsletter this morning written by a multi-million dollar businessman. He concluded today’s article saying that if you start a business to make a lot of money, you’ll more than likely fail. You have to excel at providing a quality product and service in order to succeed over the long run. When the inherent business excels, only then does the long term money follow.

Trading is a business in precisely the same sense. Most traders rush through the system development process to spit out quick profits. They rarely, if ever, consider a strategy’s performance over a lengthy period of time. Everything is about the here and now. Additionally, good systems frequently lose money. You need something more in the toolkit besides the random scorecard of profit and loss.

Nathan Orange(Nathan):
Good systems do have losing periods, yet many traders seem to be convinced there is a “holy grail” approach out there that will buck this fact. If some of the most successful traders ever have posted losing periods (or even years) and have been around for 20+ years it seems hard to fathom beating their performance from day 1.

Regarding testing platforms, you were one of the first people that really explored the issues with back-testing Forex – can you provide more detail on the problems for those that are interested in developing and back-testing a system for FX (MetaTrader platform)?

Shaun Overton(Shaun):
You’re opening a can of worms on this one. MetaTrader is hands down the worst platform available for backtesting. The data is notoriously unreliable. Even when good data is at hand, the instructions for importing it and turning it into something usable fill a dozen pages of instructions.

You’re much better off doing real analysis in NinjaTrader, TradeStation or MultiCharts. The metrics are vastly superior and require a tiny fraction of the effort. I still think that MetaTrader is sufficient for live trading most strategies.

Nathan Orange(Nathan):
I am a huge fan of live testing/trading alternate strategies. One of my biggest “A Ha” moments came during live testing alternate exit strategies. I traded my account with my original exit approach but also demo traded alternate exit strategies in real time. There is value gained that you don’t always get from a back-testing print out. How do you compensate for slippage when testing a strategy?

 

Shaun Overton(Shaun):
Forex is thankfully unique in that it doesn’t come with unique problems other than rollover. The markets are the most liquid in the world. As a retail forex trader looking at charts longer than five minutes, you can generally assume that the historical prices are reasonably reflective of executable prices for the strategy.

I compensate for slippage and bad ticks by doubling my expected transaction costs. For example, I pay 1.5 pip spread on the EURUSD. When I test a strategy, I demand that it must hold up on 3 pips transaction cost on every trade.

Nathan Orange(Nathan):
Before we wrap this up, are there any specific strategies or common parameters that you have noticed in systems that make it? We both know how small of a percentage of traders become successful, but as it relates to mechanical systems are there recurring themes for those that are profitable?

 

Shaun Overton(Shaun):

No, there are no recurring themes that I see. The lowest common denominator is that they do not overtrade and that they use low leverage. Other than those two items, each successful strategy differs substantially from all the others.

The most important ingredient in system development is the developer. I have yet to program a successful trading system for someone without years of full time trading experience under their belt. You have to go through the school of hard knocks if you’re going to make it. Almost all of us are too stubborn to listen to good advice.

Nathan Orange(Nathan):
Shaun, I can’t thank you enough for providing such honest responses and sharing your insight. If you are interested in learning more or considering coding your system, go to MetaTrader Programming for more information.

Filed Under: MetaTrader Tips, NinjaTrader Tips, Trading strategy ideas Tagged With: algorithm, backtest, HFT, high frequency trading, metatrader, mt4, Nathan Orange, ninjatrader, trading

EA Problem Checklist

January 3, 2013 by Shaun Overton Leave a Comment

It drives me crazy when I call tech support and the customer service person asks, “Is your computer plugged in?” When I step back and think about it, however, they ask dumb questions for a reason. Some people really do forget to check the obvious things.

If you’re stuck trying to load a MetaTrader expert advisor and you cannot get it to trade, this checklist will help you resolve the most obvious problems.

You should see the name of your expert advisor and a smiley face in the top right corner of your open chart. The image below contains a blue line. Everything is correctly displaying above that blue line.

MT4 EA

Expert Advisor Problem Checklist

Do you see the name of your expert advisor on the chart? If yes:

  • If an X appears, then click the big EA button at the center top of the screen. It should appear pressed down
  • If an upside down smile (a frown appears), then right click on the chart. Choose Properties. Click the Common tab. Select “Allow live trading” and “Allow DLL Imports”. Remove the check next to “Confirm DLL Function calls”
  • Click the Inputs tab. Change the inputs to whatever values you desire. Push OK.
  • If a smiley face appears, you’re all done.

Do you see the name of your expert advisor on the chart? If not:
Drag and drop the EA onto the chart.

  1. Click the Common tab. Select “Allow live trading” and “Allow DLL Imports”. Remove the check next to “Confirm DLL Function calls”
  2. Click the Inputs tab. Change the inputs to whatever values you desire. Push OK.

 

MT4 EA Button unpressed

The X appears on the chart because the Expert Advisors button is not pushed down

EA frown

The frown on the chart indicates that “Allow Live Trading” is not enabled.

The EA button correctly pressed

The smiley face appears on the chart after the Expert Advisors button is pushed down.

Filed Under: MetaTrader Tips Tagged With: EA, expert advisor, metatrader, mt4

Custom Indicator MetaTrader

December 27, 2012 by Shaun Overton 1 Comment

If a trader dreams up some information that he’d like to see on the chart, a custom indicator is more than likely the way to go. Custom indicators support the display of

  • Dashboards
  • Buy and sell arrows
  • Any type of line

Custom indicators require programming. That is, after all, the item which makes them custom.

The custom indicator box in MT4

The advantage to developing a custom indicator is that it offers maximum control over the process. The designer controls the inputs, which are the items that the user can change.

Moving averages, for example, offer common inputs such as the type (EMA vs SMA) and the period (a 55 period moving average). If you anticipate changing your mind later, it’s easy to facilitate that from the beginning.

Most traders care most about how the indicator looks on the chart. Whether you tend to focus on colors or prefer arrows over lines, the great thing about the custom process is that you can build the tool to match your tastes.

Some traders prefer the dark black background in MetaTrader. Others prefer lighter colors, which are easier on the eyes. It’s completely up to you, the designer, to dictate how the indicator should display the information.

Do you have a custom indicator that you’d like to create? Email us at info@onestepremoved.com with a description of what you’d like to build.

Filed Under: MetaTrader Tips Tagged With: chart, custom indicator, metatrader, mt4

  • 1
  • 2
  • 3
  • Next Page »
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.