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

Triangular Arbitrage

November 8, 2012 by Shaun Overton 23 Comments

Triangular arbitrage is a bit of forex jargon that sounds cool. It represents the idea of buying something and selling it near instantaneously at a profit. Instant, free money appeals to nearly everyone. The theory is sound, but it’s extremely difficult to pull off in real life.

If you are unfamiliar with synthetic currency pairs, I highly recommend that you read my post on the subject from December 2011. None of this explanation will make sense without understanding that the synthetic pair concept.

Triangular Arbitrage

Triangular arbitrage opportunities occur when a currency pair shows a price, while the same synthetic currency pair shows another price. If the asking price for the EURUSD is 1.2820 and the bid price of the synthetic currency pair is 1.2823, a triangular arbitrage opportunity exists.

The synthetic currency pair can involve any medium of exchange. Yen pairs are extremely liquid, so perhaps a may use USDJPY and EURJPY to build the synthetic EURUSD.

The great thing about the triangular arbitrage trade is that there are multiple opportunities using the same instrument. Although the named pair does not change, which in this case is EURUSD, a trader could use any of the other 6 major currencies to shop for the best price on the trade. I listed the examples below using the assumption that we’re buying EURUSD.

Arbitrage currencyAction for arbitraging long EURUSD
JPYSell EURJPY, Buy USDJPY
GBPSell EURGBP, Sell GBPUSD
AUDSell EURAUD, Sell AUDUSD
NZDSell EURNZD, Sell NZDUSD
CADSell EURCAD, Buy USDCAD
CHFSell EURCHF, Buy USDCHF

Example

Assume that the trader spots an arbitrage opportunity in EURUSD and finds that yen crosses offer the best opportunity. The mechanical implementation of the strategy would follow this approximate process:

  1. Buy 100,000 EURUSD at market
  2. Confirm execution of the EURUSD order at or near the requested price.
    • If the order receives poor execution that is worse than the synthetic currency pair or will make the trade too expensive, then close the trade and look for a new opportunity. The cost is the spread and whatever commission was paid.
    • If the order receives reasonable execution, continue.
  3. Choose half of the synthetic leg to fulfill. The order does not matter. If it the EURJPY is the first order to use, then the task is very easy. The EURUSD and EURJPY pairs both use the same base currency. The lot sizes on the trades should be identical. Because we bought the EURUSD in the named currency pair, we will need to sell the EURJPY to hedge out the euro component of the trade. The EURJPY sell for 100,000 should be executed at market.
  4. The remaining leg of the trade is the USDJPY. Buying EURUSD put us short dollars. In order to hedge the dollars, we need to buy dollars. Thus, we must buy USDJPY. We cannot, however, blindly purchase $100,000. Although we bought €100,000, that trade put us short $128,200. The unit size should be a purchase of $128,000 against the yen. The extra $200 is rounded to off due to position sizing restrictions in the forex market. We are forced to accpept the risk on the $200 position
  5. The entire trade has now executed. The exit will occur when the opportunity reverses itself so that the bid is now below the ask, as you would expect in a market. Exit all open trades at market.

Correcting Lot Sizes

It’s hard to grasp the concept of triangular arbitrage from a single example. At the risk of boring my readers, I present a second example below for the sake of thoroughness. The need to correct for lot sizes is what I expect will trip up most traders. Skip this section if you feel like I’m beating a dead horse.

Let’s use the NZDJPY as an off the wall example. The pairs involved are as follows:
NZDJPY, trading at 66.32
NZDUSD, trading at 0.8281
USDJPY, trading at 80.07

The named NZDJPY price is 66.32. The synthetic price, however, is 66.305. An arbitrage opportunity of 1.5 pips exists. This is calculated by:

1 NZD/USD 0.8281 * 1 USD/JPY 80.07 = 1 NZD/66.305 JPY
66.32 – 66.305 = 1.5 pips

The named currency shows a bid price above the ask. This means that we need to sell the named currency and buy the synthetic currency. Assuming that we deal in standard lots on the base currency, the trader executes an order to sell NZD $100,000 at market.

The first task is to buy back the kiwi dollars using NZDUSD. No conversion among units is necessary. Both the named and synthetic currencies share the same base currency, NZD. The last and final step is to sell the JPY that was purchased in the NZDJPY short transaction. Selling JPY using USDJPY involves buying USDJPY. Remember the warning about unit sizes.

We need to purchase NZD $100,000 worth of yen in US dollars. As you can see, it’s complicated. Converting the dollar base currency into NZD is:

NZD $100,000 * USD $0.8281/NZD $1 = $82,810

We need to buy $82,810 worth of USDJPY. The forex market restricts transactions to 1,000 unit increments. The least risk involves purchasing $83,000 USDJPY and accepting $190 in exposure.

Why triangular arbitrage is so common

Almost all retail forex brokers mark up their spreads in lieu of charging direct commissions. The purpose is to camouflage the true cost of trading. Like most gimmicks, however, it creates an unintended consequence. The artificial mark ups in the spread are the reason for many of the triangular arbitrage opportunities.

The broker must decide which side of the spread receives the markup. Occasionally, the entire markup is subtracted from the bid or added to the ask. More often than not, brokers hedge their bets by adding portions of the markup on both sides of the bid and ask.

The markups are invariably higher on the crosses. The extreme differences between the bid and ask make trading those crosses directly undesirable. It’s something of a paradox, but that undesirable trait becomes a positive one in the context of triangular arbitrage. The bid is lower than its real rate. The ask is higher than its real rate. When the majors trade on reasonable spreads, it’s common for the markup to create near permanent arbitrage opportunities on the crosses.

The trade only achieves a realize-able profit whenever the markup begins skewing in the opposite direction. If a broker applies most of the markup on the ask, the triangular arbitrage would not profit until the broker shifted the markup mostly or entirely to the bid. The flip flops typically take several hours to occur, which limits the number of daily opportunities.

Brokerages almost always view arbitrage traders as toxic order flow. Arbitrage only occurs when someone is asleep at the wheel; the profits ultimately come out of somebody’s pocket. Even in the instance where brokerages offer an ECN or pass through execution, they care far more about their relationships with the banks than any individual customer. Brokerages are essentially wholesalers for the trading arms of banks. If the banks cut them off, then they have nothing to sell. Triangular arbitrage in this situation earns its money from the banks. If a trader makes too much money too fast, the trader will get the axe at the bank’s request.

Traders on the FXCM dealing desk or other brokers face no chance of an ongoing relationship. The profits come directly from the broker’s pockets. If they’ve been in business for very long, they will know what you’re up to relatively quickly.

Splitting trades across multiple brokers is the best opportunity for the strategy to succeed. Breaking up the orders creates more opportunities. More importantly, no single entity knows your combined order flow. It makes it much more difficult for the sore loser to track down who is bleeding him dry.

Forex Platforms

MetaTrader

Running triangular arbitrage expert advisors in MetaTrader involves a clunky workaround. The same risks that apply to broker arbitrage also apply to triangular arbitrage. The trade context is busy problem stands out as a primary concern. It might realistically take 3-5 seconds to execute all three orders if done within a single expert advisor. Many bad things can happen in such a large time window. Also, I would expect the broker to catch on quickly to this scheme and shut it down.

The only practical solution is to use three separate instances of MetaTrader running a shared memory DLL. One instance would be dedicated to the “bad” broker marking up its spreads. The other two instances would execute each single side of the synthetic trade with a “good” broker. Executions would obtain the ability to enter simultaneously without queuing. The disadvantage is that the EA would only update on incoming ticks. If a long interval occurs between ticks, it delays one corner of the triangle from entering.

NinjaTrader

NinjaTrader can ideally execute the orders if done within a single brokerage. Again, this makes your tracks pitifully simple to trace. You could build a great strategy with sound engineering that only works in the real world for a few days. You’re then stuck going broker shopping once again.

The best way to trade undetected is to use NinjaTrader with a multi-broker license. Apply one strategy on the bad broker, then apply the second strategy on the good broker. The strategies would also need a way to communicate, perhaps through a shared memory resources or an intranet client-server.

I am interested in building well engineered solutions as products for sale on this web site. If trading something like this interests you, please email me and mention the platform that you prefer. I’m keeping a list to help us prioritize what traders want.

Filed Under: How does the forex market work?, MetaTrader Tips, NinjaTrader Tips, Trading strategy ideas Tagged With: arbitrage, expert advisor, forex, mt4, spread, synthetic currency, triangular arbitrage

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 © 2021 OneStepRemoved.com, Inc. All Rights Reserved.