Optimize an Expert Advisor
February 20th, 2012 by Shaun Overton
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.
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.
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 important columns for this task are Start, Step and Stop. Start is the lowest number that the 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.
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.
Volatility & Divergence Commentary
February 17th, 2012 by Shaun Overton
This week has been an ideas week. An unusual number of clients are asking for my opinion on the ideas that they want to program into an expert advisor. Divergence and volatility keep popping up as themes for the week.
Simple Volatility Filter
Volatility is one of those factors that you cannot ignore in trading. It highlights the overall risk context of the market and says something about the likelihood for a trade to get some wheels.
The number of tools that we have to study volatility is unfortunately very limited. Almost everyone uses ATR, which is the average true range. The calculation for it is very basic. The true range is simply the high minus the low. The ATR is simply the average of all the true ranges over a certain period. Most traders use a 14 period ATR by convention.
I sent the chart below to a client in Australia yesterday who asked if I had any ideas for a volatility filter. It compares a fast and slow volatility window using ATR. The red line represents the 14 period ATR, which I call the fast line. The blue line represents the 300 period ATR, which I call the slow line. I suggested that period he could use the fast line appearing above the slow line as an indicator of high volatility. The opposite indication would indicate low volatility.
I created the above chart by dragging and dropping the ATR custom indicator onto a chart. I then dragged and second ATR indicator onto the first ATR indicator. Doing that way overlaps the lines. 0therwise, you would see two lines in separate windows.
When I opened MetaTrader again this morning, the same chart was left open. I immediately noticed that the line crossings appeared to match up with some of the longer term trends. Although it would not indicate the direction of a trend, the ATR crossings might prove useful as a trend detection indicator. If you decide to research this idea, please leave your comments and observation on the blog page below. I enjoy hearing from my readers.
Divergence
I buy into the idea that the market contains price points that are more relevant than others. A lot of the math that I work with involves autocorrelation, which many refer to as the long term memory function. It’s a mathematical tool that allows nerds like myself to find hidden statistical patterns among a bunch of noise in a signal.
Divergence takes a similar idea and applies it to indicators, the most common of which are the MACD, RSI and stochastics. When the price rises above a previous critical point and the indicator does not exceed its previous critical point, then divergence exists. Most traders claim that divergence signals the potential end of a trend.
My biggest gripe with divergence is that the length of trends exhibit random periods. I’ve done plenty of independent research on this topic. Regardless of the method that you use to pick market tops and bottoms or how you define a trend, the time period of the measured trend is always random. It has a probability density, but it definitely does not have a set number.
Divergence completely fails to address this concern. There’s no reason why you can’t have 2 divergences or even 5 divergences in a trend. Divergence does not help the trader distinguish between the end of a trend or a continuing trend. You could use divergence as a trend detection tool, but by that point some traders are already calling for it to end. My personal opinion is that it’s not very useful.
My other complaint with divergence is that the method for picking critical points is totally arbitrary. If you put 10 traders in a room and ask them to draw a trend line, you will get 10 different answers. The absence of consensus on such a basic concept ought to say a great deal about the value of subjective interpretation.
Traders also attempt to draw the points between swing highs and lows. That task should be obvious, but it’s not. I always recommend using the zig zag indicator when customers want to go down the swing trading route. They quickly discover the same problem – how sensitive should the settings be. Again, we circle back to the issue of period length. The swing high that Bob’s Zig Zag settings draw looks like market noise to the swing highs that Alex draws.
My opinion is to stay away from divergence and look for other techniques.
Market Depth
February 14th, 2012 by Shaun Overton
Moving from small time retail forex accounts to a serious account size comes with some bumps in the road. Most traders see the prices of forex pairs on the screen and assume that they can buy and sell unlimited quantities at any time. Although the forex market is the largest market of any in the world, making it the most liquid, there is still a limited size to what you can trade at any moment.
Reading Forex Market Depth
NinjaTrader and MB Trading both make market depth information available in their trading screens. It shows where all of the nearby liquidity lies. Say, for example, that you wanted to place a big order for EUR/USD. You can see in the screenshot from MB Trading’s platform that the liquidity gets bigger as you get further from the price. They call these “Level 2″ quotes, which is jargon taken from equities traders.

MB Trading's Navigator shows the market depth of the EUR/USD. Light colors show the best prices, darker prices indicate distance from the best price.
I took this screenshot in the late afternoon when liquidity is at its worst. The best bid shows a depth of 200, which is measured in mini lots of 10,000. You could sell up to 2 million EUR/USD and get filled at that price. Notice, however, that most of the liquidity is further away. 3 million sits at the next best price and another 3 million even further from that. The net available liquidity is 8 million on the short side and 6 million on the long side for a total of 14 million.
The FX Pro screen in NinjaTrader makes it even clearer. I took this screenshot several minutes later, which is why liquidity numbers are different. One thing I really like about this screen is that NinjaTrader converts the liquidity depth into more tangible numbers. The formatting makes more sense to me. Plus, it’s much easier to keep track of the varying spread.
What you learned in economics doesn’t apply to trading. Dealing in bulk actually leads to worse pricing instead of improved pricing. The reason is that forex instruments are so standardized that there’s effectively never a lack of customers. It’s really an issue of getting how much much you want at a certain speed.
Only a fool would hit the market with 20M EURUSD instantaneously unless you’re desperate to exit a position. If you push a market order judging solely from the quote on the screen, you may get 2-8 million filled at the displayed price. But, the rest of the order will get filled at progressively worse prices. The traders making a market want their pound of flesh for letting someone into the market so quickly.
Traders cannot see the liquidity depth of most brokers because they elect not to show it. Their platforms encourage the buy this, buy that psychology. The more information that they broadcast, the more bandwidth that’s required, which means that better servers are required.
The EURUSD is the most liquid forex pair in the world. This varies largely by broker, but at any given time you should be able to trade 20-30 million EUR/USD. That doesn’t mean that you’ll get filled at the price on the screen. What that means is that that is the sum quantity available at any given moment.
Some brokers hide their quantity. It’s not like the stock market where if there are 15,000 shares of Microsoft ready to trade at any given moment, you can see 100% of the liquidity available. In forex, as an OTC market, the broker may wish to restrict the viewable book for a few reasons.
If you offer markets from say 5 banks, it’s very rare for the broker to feed the best competitive price and to let the banks fight it out? Why? Because the broker also needs the banks to stick around when nobody wants to trade.
It’s an informal agreement that if I’m retail broker A and UBS is my main liquidity feed, I go out of my way to give UBS the good flow. My customers expect to trade during NFP and other volatile markets (although they really shouldn’t!). If the brokerage simply lets the banks fight it out, then the banks have every reason to let the brokerage rot on the vine when their customers want to trade but it’s bad for the banks. The banks certainly don’t want to take positions in volatile markets. Their only incentive for doing so is if the “good flow” that the forex broker sends during normal markets incentivizes them to accept the risk of losing more than they care to during NFP.
News traders are the most likely to try trading during a thin market. They are also the most likely to complain about not being able to trade. These are the arguments to which I’m least sympathetic. If you’re trading the news, you are overwhelmingly likely to have less than one year of trading experience. The decision has nothing to do with researching systems or evaluating whether or not it’s a good idea. It has everything to do with gambling.
Retail traders are the most likely to trade during volatile events, not just news but really any type of momentum. Almost everyone follows a breakout or momentum strategy. It has everything to do with what traders perceive as the most likely outcome. When the market explodes in one direction, it takes nerves of steel to stand in front of the freight train. Therefore, it’s probably a good idea because it’s counter-intuitive.
Trends happen so slowly that they don’t excite the gambling buzz that most retail forex traders are after. My friend Afshin in Dublin fell victim to this last week. He saw the EUR/USD rising day after day after day. He felt like it was simply overdue for a correction. The urge to participate, rather than coming from a desire for a quick hit, instead came from a desire to be right before there was any clear indication of the opportunity to be right. The point is that what feels natural to do is often precisely the wrong thing to do. It feels natural to every other trader, too.
Market Depth and Direction
One research project that I’d eventually love to do is to study how market depth on any given side of a market affects direction. Some traders run simple liquidity businesses where they receive trading rebates in exchange for accepting the risk of holding a position over the short run. These entities are less likely to concern themselves with picking the direction of the market.
Trading desks that make markets, however, often want the flow so that they can establish a position and earn the spread while doing so. These entities are picking direction – and they are backed by very intelligent math geeks with PhDs and a lot of time on their hands. If those desks make a visibly deep market and it’s sufficiently one sided, then it’s probably safe to assume that they expect to the market to move in the opposite direction.
When you’re buying a forex pair, the bank is selling it to you. So if everyone stacks the liquidity so that you can buy but the liquidity is thin on the short side, it should be telling you that the smart money wants to go short right now.
High Frequency Forex Seminar
February 2nd, 2012 by Shaun Overton
One exciting opportunity popped up while I’m in Dublin next week. Best of all, it’s free and open to the public. If you’re in the neighborhood and would like to discuss trading in person, I’d love to meet you.
Trinity College Dublin invited me to present a graduate level seminar to MSc students in Finance and Alternative Investments on Wednesday, February 8, at 6 pm. The seminar will be hosted in the MBA room, which is on the second floor of the business school. The topic will be high frequency market making in forex.
Topics for the high frequency forex trading seminar (about 10 minutes per subject):
- Market making versus price taking
- Comparing frequency to expectation. The more you trade, the more you make
- Liquidity risks and self-feedback loops
- Technical approaches and limitations
Trading Time in Programming
February 1st, 2012 by Shaun Overton
The major automated trading platforms such as MetaTrader 4, NinjaTrader and TradeStation all count time in the same way. This makes it quite convenient for ordering trading strategies and expert advisors; you don’t have to do any mental gymnastics to describe the strategy in different platforms. The consistent arrangement of time makes it easy for us to translate trading strategies across multiple platforms.
We tend to think of time as moving in the same direction as when we read. English speakers, who read from left to right, think of time as moving the same direction. If you speak a language like Arabic that reads right to left, you tend to think of time as marching to the left.
All of these charting platforms are written by speakers of left to right languages. The past is anything that’s not on the far right side. The present is the square on the far right. Each square represents an equal time interval. Traders know these as bars.
What tends to confuse everyone ordering expert advisors is that even though time marches to the right, trading programmers count the bars to the left. What makes things more confusing is that programmers always start counting from 0 instead of 1.
If you want to trade a moving average cross strategy that waits for the bars to close, what you’re looking at is “bar 2″ and “bar 1″. The way I describe this in the scope of work is the value at two closed bars ago and the value at the last closed bar, respectively.
An expert advisor that uses closed bars ignores bar 0 because it is still open, which causes the moving average values to fluctuate. The only way to know for certain a moving average value at a particular bar is to wait for the bar to close, which means it is no longer bar 0. When a client requests an expert advisor that trades intrabar, they intend to compare the moving averages at “bar 1″ with “bar 0″. In plain language, that means to compare the value at the last closed bar with the currently open bar.
Hopefully, this description makes sense when you open a chart and see the bars already loaded. The final confusing element is when a new bar pops onto the screen. The previous examples showed 5 bars on the chart (bars 0-4). When a sixth bar pops up, the count is reset to the new time period on every update.
Say that we’re looking at an H1 chart in MetaTrader and that the current time is 06:00. When the new hour strikes, the chart loads a new candle to represent 07:00. It’s at this time that the count resets.
High Frequency NinjaTrader Strategy
January 30th, 2012 by Shaun Overton
I’ve been working on a high frequency trading system for NinjaTrader on behalf of a long term client. My live account is with MB Trading. Rather than placing market orders and paying a commission, I changed the order types to limit orders. We want to receive a small commission for the market making strategy rather than paying a commission to accept the displayed prices.
MetaTrader suffers two major disadvantages that make NinjaTrader a superior option for high-frequency trading. MT4 does not offer charts lower than the M1 time frame and the trade context is busy error prevents multiple charts from running simultaneously. NinjaTrader is complex enough to where I can control most details, but simple enough that I don’t need to invest hundreds of hours to test an idea. After extensively testing the strategy on M1 charts as a price taker, I feel very confident that the strategy is sound. The only issue now is determining whether or not whether taking a passive (i.e., market making) approach will result in enough fills to make the strategy worthwhile.
The first issue that I came across wasn’t with NinjaTrader; it was with MB Trading’s API. The strategy worked fine on the simulation account, which only routes orders to NinjaTrader (NT). NT then makes guesses when fills would occur. The goal of that phase was not to test the strategy. I only wanted to test the programming to make sure that it worked properly.
100 trades went off without a hitch in the Sim account. The strategy only made it through 2-3 microlot trades on the live account before the pending orders hung. NinjaTrader pending orders pass through 3 states before they actually hit the market. For the programmers out there, these are the OrderState properties of IOrder objects.
- Pending submit – the strategy sent the order to the broker and is waiting to hear back
- Accepted – the broker acknowledges receipt of the order, but is still placing the order into the market
- Working – the order is available for others to trade
The strategy updated orders on every tick. What often happened was that the pace would go far too quickly, creating a major communications backlog during fast markets. NinjaTrader never threw an exception. The only evidence of a problem was that I would see a hanging order with the PendingChange property. The inconvenient solution was to exit NinjaTrader and reload everything.
I figured that perhaps that the managed order state caused the issue. I changed my approach to unmanaged orders, but that did not make a difference. I eventually came to the realization that the MB Trading API cannot handle more than one order every few seconds.
The strategy found the sweet spot after changing from tick to second charts. Updates of 6 seconds or longer seem to give the MB Trading API enough time to update wihle still preserving something of a high frequency approach. Any trades that need to run faster than that threshold at MB Trading need to use the FIX protocol.
The other element that drove me crazy is that NinjaTrader limit orders automatically delete themselves once per bar. I nearly tore my hair out, and I don’t have all that much hair, for several hours trying to figure out why orders deleted themselves automatically. Many people identify with the school of hard knocks approach to learning. I’m as thick headed as most. I figured out the cause when I revisitied NinjaTrader’s online documentation and discovered a limit entry method that allows good till cancelled (GTC) orders.
The speed problem also manifested with overfills. An overfill is when a strategy requests to cancel a pending order, but the broker fills the order before the cancellation takes effect. The biggest concern with overfills is that NinjaTrader automatically disables a strategy and exits positions at market when an overfill occurs. The only way to programmatically prevent this is to change the entry methods to an unmanaged approach.
The easiest way to develop for a high frequency strategy in NinjaTrader (but not ultra-high frequency) is to use managed orders. Whenever an exit is needed, place the limit entry in the opposite direction. NinjaTrader takes care of placing the exit order for the open market positoin. Limit the updates to every handful of seconds. It allows the broker API to catch up and helps avoid the problem of overfills.
Reverse engineer expert advisor
January 27th, 2012 by Shaun Overton
I guarantee that you are not the first trader to consider the idea of reverse engineering an expert advisor. The idea pops up most frequently among traders that don’t want to pay for a commercial expert advisor. Alternatively, they want to use the same strategy when another trader that doesn’t want to share the idea. The motivations for reverse engineering remind me of decompiling EAs, making me leery of the idea.
Reverse engineering a strategy only stands a chance when some parameters are known about the strategy. If, for example, you knew that the strategy involves MACD and moving average crossovers, it at least provides a reasonable starting point. The programmer could write software which combines every possible combination of two moving averages of various types with every known type of MACD. The programmer could then make guess about which types of signals might result in a buy or sell decision. If the guesses are not very good, then the outcome of the reverse engineering attempt is certain failure.
Then you have the problem of guessing on which chart to base the decisions. Many traders use standard charts like the M1 and M15, but many others use less common options like an M3. If the trader uses multiple charts like an M2 and M10, the resulting trade history would clutter together. Good luck trying to pry apart the different series.
Making things worse is if the trader uses a chart that doesn’t depend on time at all. Tick charts are the most common, although you occasionally see less orthodox options like Point and Figure charts and Kagi charts. Time is irrelevant. You wouldn’t have any idea on which charts to run the test.
This approach of making somewhat intelligent guesses while throwing mud at the wall is called a brute force attack. You literally designate every unique possible combination, then see which one opens the metaphorical safe. Some results will bear no resemblance at all to the actual results. If you get extraordinarily lucky and/or have fantastic intelligence, then you might find a close replica of the strategy.
It would be possible to study the correlation of the tested values with the values in the supplied account statement. You would ideally want to find data clusters with similar variable settings that do not dramatically alter the correlation between the reverse engineered strategy and the actual account statement.
If you don’t know very much about the strategy, or if what you think you know turns out to be wrong, then you stand no chance at all of reverse engineering the expert advisor. For all that you know, the EA that you thought used RSI might turn out to run on phases of the moon (yes, there are real strategies that do that) or that make decisions based on coin flips.
Most people assume that they know more than they really do. I would discourage all but the most fool hearty or stubborn from making the attempt, unless you had a very good reason for doing so.
Scripts in MetaTrader
January 26th, 2012 by Shaun Overton
Scripts are executable files in MetaTrader that only run one time. They are perfect for tasks that are routine but time consuming or unpleasant to do. The most advantageous use of scripts is that they do not rely on incoming price ticks in order to run. The script executes the moment that the trader drops it onto a chart.
An expert advisor runs continuously, but it relies on incoming ticks to know that it should update itself. The frequency that the market changes price varies with the time of day. This means that the period between updates for an expert advisor is highly unpredictable. The predictability of a script’s timing – it runs immediately – makes it more suitable for some trading tasks than an EA.
Script examples
A scalper wants to open a trade quickly. He routinely applies a 20 pip stop loss and a 3 pip take profit. His usual process would involve:
- Click inside of MetaTrader to open a trade
- Select the correct forex pair
- Wait for the trade to open
- Frantically add the take profit as quickly as possible
Alternatively, the trader could keep his chart open and the scripts window nearby. Whenever he decides to trade, he drags the script onto the chart. The steps above still occur. The critical difference is that they happen in a fraction of the time. The script runs once, then it removes itself from the chart.
Some tasks require a tiresome amount of clicking rather than speed. Scripts are also useful in that scenario. A lot of MetaTrader users like to stack multiple pending orders above and below the market in a grid pattern. An example would involve placing 10 orders above and below the market at different prices. Doing this manually would take a few minutes.
The alternative is to run a script that does it one time for you. Scripts can display input screens just like expert advisors. That way the user can control the settings.
When the trader is ready to bracket his orders, he drags and drops the script onto the chart. The orders show up on the screen at the requested prices. The total time takes a few seconds instead of several minutes.
Other script uses
The most common, though unorthodox, use of a script is to feed prices into the History Center for a custom offline chart. The script is programmed to run at a set interval such as every half second. The script samples the price, then records the information where the historical prices are kept. The offline chart then re-reads the information and updates the price.
MQL programmers elect to use a script instead of an expert advisor because they are setting an infinite loop. Although scripts technically run once, this script is never allowed to finish its first run. It keeps waiting every set interval to update the price. EAs would not work well here because new, incoming ticks would create a backlog of occasions where the EA is supposed to have run. I would expect MT4′s memory use to eventually get out of control and crash the program if someone elected to take this approach. Even though it is not an ideal solution, scripts update historical prices successfully without the tick backlog concern.
MetaTrader Logs
January 23rd, 2012 by Shaun Overton
Log files are written records of all trading activity in MetaTrader. Whenever a trader submits an order, modifies a stop loss or connects to the broker, MetaTrader notes everything that happens along with the time.
We use log files to reconstruct a sequence of events when expert advisors run on a live account. Knowing the order in which things happened helps us to determine why an EA may not work properly.
Consider the logical steps where you want to go to the grocery store. If I were writing software to do this, my log file might read something like this:
1) Find my car keys
2) Find my wallet
3) Get in the car
4) Drive to the grocery store
5) Buy groceries
If my log file only says “find my wallet” and “get in the car”, I intuitively know that something is wrong. Why would the software not work when I get in my car? Because I don’t have my keys.
The log file helps your MQL programmer think along the same lines. When the log says, “calculate the entry rules” and the log only talks about the exits, it’s clear that the flow of the program doesn’t match the design intention.
Log files only come from the computer where the expert advisor runs. When a problem inevitably arises, your programmer will request that you send the log files from the computer where you’re running the EA. This is unfortunately a necessary part of the debugging process.
We do all of our quality assurance testing in the MetaTrader backtester. Although this usually catches the most obvious bugs, new errors will always pop up while forward testing the EA. The log file is what helps connect us to the problem, even though it happened on another computer.
Find your MetaTrader 4 log file
MetaTrader keeps two sets of log files. The most basic logs are located in YOUR BROKER NAME\logs. Most of our clients navigate here accidentally and assume it’s the file that we need. Expert advisors cannot write to this log file, so it unfortunately doesn’t do us much good.
Locating the correct log file for your programmer will vary based on your operating system. Anything in capital letters changes based on your personal information.
Windows XP and Windows Server 2003 users can find the logs in C:\Program Files\YOUR BROKER NAME\experts\logs
Expert advisors that run on Windows Vista or 7 have to put in more effort. Those log files are found in
C:\Users\YOUR USER NAME\appdata\local\virtualstore\Program Files (x86)\YOUR METATRADER INSTALLATION\experts\logs.
The part that confuses most Windows 7 users is that when they navigate to the folder with their USER NAME, the appdata does not appear as an option. The easiest trick is to double click on the current folder name at the top of the screen. Once you’ve clicked, the entire directory name will appear. If you type “appdata” after the final backslash and push enter, the window will navigate to the correct location. You can then continue clicking until the log file appears.
The name of the file corresponds to the date. The format is year, month and date (YYYYMMDD). Today is January 23, 2012, so the log file for today is named 20120123.log.
Finally, log files are often enormous – 50 MB or more. Please right click on the file and select “Compress” or “Send to, Zip File”. Sending the zip file can reduce the file size by 80% or more.
Donchian Channel
January 16th, 2012 by Shaun Overton
A Donchian channel measures the highs and lows of the price over a certain period in time. A lot of traders use this concept in their trading, although they are not familiar with the name Donchian.
Most Donchian channel expert advisors attempt to catch breakouts. I almost never see people use it with a ranging approach. Most traders want to ride the excitement of an ever-increasing market. The price, especially with the forex majors, often strikes the previous high or low. The price surges for a minute, only to retrace to well within the previous channel.
The hazard of using Donchian channels as breakout strategies is if you jump too early, you risk making a big fuss over nothing. If you jump too late, then you miss the move. I have not found any method for predicting when these moves will happen. My experience with fractal markets is that the period of a new movement, big or small, is totally random. The condensed trading time and low liquidity make it extremely difficult to try catching a move as it happens, at least on an intraday basis.
I have not done any testing on this, but I suspect that a ranging approach might work better. Most momentum traders are weak hands. They only play when there’s action. As soon as the action disappears or reverses itself, they all tend to leave the party. The dominance of retail traders favors a contrarian approach.
Most traders look at similar points to decide when momentum is truly occurring. They use Donchian channels, although different traders tend to use different periods. The important take-away is that the precise price that they care about tends to vary ever-so-slightly based on the period selected. The Donchian price is more or less the same, regardless of the period.
As an example, you might choose a lookback period of 55. The Donchian channel would consist of the highest high that occurred within the past 55 bars. The high could have occurred on the 55th previous bar or 10 bars ago. Time is ignored. The channel’s low corresponds to the lowest low in 55 bars or periods.
Turtle Traders
The most famous Donchian channel method comes from Richard Dennis and his Turtle traders. Dennis and friend argued over whether good traders were made or born. As wildly successful traders, they had several million dollars at their disposal to settle the bet.
The system used the 55 period high and low to determine the entry. When today’s price strikes the highest daily high in the past 55 trading days plus one tick, the trader enters at market. The system focused on commodity futures.
Most people tend to focus on the methodology that they used to pick the market direction. The original turtles argued that their success came from the unique money management and portfolio selection methodology that they used.
As a winning trade increased in value, the Turtle Trader added a second trade to his floating winner. They used recent volatility and their own risk variable, called N, to determine how far or near the second entry should occur from the original. They would do this up to 4 times, eventually letting their massive winners ride for months.
The system worked extremely well through the 1980s. My understanding is that the performance degraded towards the end of the decade.
If you’d like to read through the entire list of the Turtle rules, I suggest that you read through the Turtle Trader PDF that’s been floating around the web for years.








