Algorithmic and Mechanical Forex Strategies | OneStepRemoved

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

How badly do I want in?

March 22, 2016 by Shaun Overton 10 Comments

You absolutely must check your trading system’s performance on a regular basis. You’re going to miss most of the problems from watching your equity curve alone.

That almost happened to me a few weeks ago. When I observed my account, I noticed that the real results had dramatically underperformed the hypothetical results. A quick review showed me that I only took 271 trades over the prior week, whereas my backtest expected to find 360.

I was only trading 75% of the setups! What could explain the missing trades?

Finding the flaw

One feature that I wrote into the MetaTrader version of the Dominari was a maximum spread feature. I’m paying commissions, so the idea of the rare but possible scenario of paying a 10 pip spread to enter a trade seemed intolerable. I added a maximum spread feature to prevent getting ripped off.

I also didn’t put much thought into what happens if the spread is too wide. My initial instinct was to put the EA into hibernation for a few seconds. It would then wake up and check the spread. If the spread narrowed enough, it would send a market order. But in my haste to start trading, I forgot to also require that the price be near my original requested price. That design would have allowed the market to drift up 10 pips and then, if the spread narrowed, dramatically overpay to get in the trade.

The new method for capping the spread paid uses limit orders if the spread is too wide. The advantage to this method is that it solves two simultaneous problems. The first one is easy to understand. A limit order has a limited price. It’s not possible for the price drift described in the above paragraph to occur. I either get the price I want or the market moves without me and I miss the trade.

Equity curve since I made the execution changes on March 16.

Equity curve since I made the execution changes on March 16.

The second advantage to using limit orders on entry is the fact that a limit order rests on the broker’s server. The hibernating method could potentially miss fractions of a second where the spread temporarily narrows to an acceptable price. Limit orders catch all price quotes, improving my theoretical likelihood of a fill.

Reality proved the theory after a week of trading. Instead of taking 75% of all possible signals, I’m now taking 87.5% of signals. That’s a result of the new limit method and my willingness to pay a wider spread to enter a trade.

More improvement

The question at the top of my mind was, “Should I be willing to pay even more to enter these trades?” Like a good quant, I immediately decided to calculate the question instead of haphazardly guessing.

I wrote a script in MetaTrader to search for every limit order in my account which was cancelled. I then looked at what the hypothetical performance of those trades would have been if I had simply paid the exorbitant spread.

It turns out that I should be willing to pay a lot more money to enter these trades.

There have been 50 cancelled limit orders within the past week, 44 of which were theoretically profitable. The average theoretical profit per trade was €1.28 compared to €0.33 for all executed trades. That’s a massive 287% difference in profitability!

The other shocker was the percent accuracy. 44 out of 50 implies an accuracy of 88%, compared to 64% accuracy on executed trades. 50 signals isn’t a lot. Am I getting too excited about missed profits or is that bad luck?

Basic statistics gives an answer with a high degree of precision. If the real accuracy is 64%, then you would expect to see 50 * 0.64 = 32 winning trades in a random sampling. My observed, theoretical accuracy with these limit orders was 44 orders out of 50, which is 88% accurate.

It turns out that I should be willing to pay a lot more money to enter these trades.

The standard deviation for 64% accuracy on 50 orders is 0.48, which we can then use to calculate the standard error. The standard error on 50 orders is sqrt(50) * 0.48 = 3.42 orders.

And finally, the standard error gives us enough information to compute the z-score. The z-score is the observed values-expected values/standard error, which is (44-32) / 3.42 = 3.5. A z-score of 3.5 has a probability of 0.000233 occurring due to random chance, or about 1 in 4,299 tests.

Conclusion: The statistics say with high confidence that my non-executed orders are substantially more accurate than my executed orders.

With the orders being both more accurate and having a higher per trade value, I increased the maximum spread that I’m willing to pay by 53%. While that sounds oddly precise, the per trade value might be substantially overestimated. I ball parked a guess that paying 40% in trade costs for a high quality trade seems reasonable. That number may have to go higher in order for me to measure the details.

Ideas for exploration

The amazing extrapolation from the live order analysis is that the spread seems to predict my likelihood of success. Wider spreads make me more likely to succeed and with a better risk:reward ratio. My project over the next few days will be to start logging my spreads at signal generation time to evaluate whether the spread predicts the profitability of my signals.

Oddly enough, there might even be a paradoxical outcome where narrow spreads predict my failure. More on that when I have enough data to answer the question.

Filed Under: Dominari Tagged With: execution, limit, quant, slippage, standard deviation, standard error, statistics, Z-score

Have Your Algo Running like a Swiss Watch

January 11, 2016 by Lior Alkalay 6 Comments

Setting up a trading algo that works smoothly, like a well-oiled machine, is not a trivial endeavor. There are many, many parameters that you have to take into account.  It begins with the signals your algo is generating to the margins in your account, volatility, gains and, of course, risk. Certainly you’ve used our previous tips to build your algo and to draft your strategy. So how do you incorporate all those elements and optimize your algo for the greatest precision?

How do all the quants make their algos run smoothly like a Swiss watch? You have to treat your algo like a machine, built up with numerous mechanisms. Because of course, that’s what an algo really is. I like to call those mechanisms boxes. Now don’t despair if you think it all sounds a bit too complicated. By the time you reach this article’s conclusion you’ll have realized that it’s all quite simple and logical.

An Algo Made of Boxes

So what is the approach quants use that I like to call boxes? You divide your algo into separate mechanisms, or boxes, if you will. Each box will become a stand-alone mechanism that receives input data and generates an output. There will be one box that we can consider the brain; that box decides if it is a go/no go for the specific trade. The brain box gets all the inputs from all the other boxes.

Algo Boxes

Signal Box- The signal box scans prices and parameters, such as the moving average or any other condition you have written into it. Basically, these inputs are the rules of engagement you had early written for your algo. One simple rule could be, let’s say, 14 days moving average < 30 days moving average = signal to sell. Typically, this box will be running prices in several pairs.

In other words, its input data and its output would normally be three parameters; an entry signal, a recommended stop loss and a limit. Of course, once again, these inputs are according to the parameters you have already defined.

Risk Box- The risk box, as its name implies, is the box in charge of risk monitoring. This one is a bit more complicated. The risk box gets input from several sources. It gets the risk, i.e. stop loss required, from the signal box. Moreover, the risk box constantly reads your available margin.

Its output is a go/no go on each trade that exists, based on the parameters you entered. For example, how much you want to risk in total or the minimal available margin to be left in the account.

Let’s say you have a free margin of 11% and you set up a minimal margin of 10% in the risk box. The signal box will send output of an upcoming trade.

The risk box can calculate that the executed trade would take 2% from your remaining margin. You started with 11% so that would leave your free margin at 9%. Therefore, the output from your risk box will be a no go for this trade.

If you had had 13% free margin rather than the 11%, the output would be a go. Of course, there are many more options to program into this box but this is the simplest one.

Volatility Box- The volatility box might be the most complicated to program. However, volatility charting is something we covered fairly thoroughly in these articles – Volatility & Your Trade, The World of the VIX, Using VIX Alternatives. The box’s task is to chart market volatility and provide an output if volatility is about to change dramatically. A major change to volatility could, of course, warrant a change in your strategy.

Execution Box (aka the Brain Box)- Easily can be considered the most important box of all. This box is in charge of making the finally decision. It gets input from all the other boxes and decides if the trade should be opened or not. It also decides if a strategy needs to be changed.

For example, if the volatility box signals an upcoming surge in volatility the execution box may decide to close some trades. Or it could instruct the signal box to change into a secondary signal model suited to high volatility. There are many other ideas that you can program into it.

Algo

How Boxes Help You Win

All of those boxes can help you make your algo run more smoothly and efficiently. How? Quite simply because it lets you optimize your algo to a much higher level. It provides you with flexibility to easily adjust each mechanism. More importantly, it lets you monitor the inputs and outputs of each box and assess which needs fixing.

Algo Box: The Bottom-line

Of course, the partitioning into various boxes is not a new algo concept. It’s also not rigid; there’s no need to do it exactly as I did. If you’re intrigued by the Algo mechanism box concept and want to delve into it a bit farther you’re in luck. I highly recommend the book Inside the Black Box by Rishi K. Narang. I’ve found that it sheds a great deal of light on what some might construe as a complicated strategy.

And for those of you that are short of time? You can use this as a basic guide on how to make your algo run smoothly, without reinventing the wheel.

Filed Under: Trading strategy ideas Tagged With: algorithmic trading, execution, risk, VIX, volatilty

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

EnglishEnglish
中文(简体)中文(简体)
DeutschDeutsch
日本語日本語
Bahasa MelayuBahasa Melayu
PortuguêsPortuguês
EspañolEspañol
by Transposh - translation plugin for wordpress

Free Trading Strategies

Privacy PolicyRisk Disclosure

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