Wednesday, December 28, 2011
S&P 500 Snaps 5-Day Rally Amid Europe Concern
Wednesday, December 21, 2011
Monday, December 19, 2011
Repainting Indicator
If this sounds familiar, then you need to consider whether or not the indicator repaints.
What is a repainting indicator?
First consider a baseball analogy. Last week, the St. Louis Cardinals beat the Texas Rangers to win the World Series. A repainting indicator is like asking you today, "Would you bet on the Cardinals or Rangers?," then pretending like you placed your bet 3 weeks ago and not today. You had no way of knowing for certain who would actually win.How normal indicators work
If that sounds stupid, that's because it is. Repainting indicators use knowledge of the "historical future" to "predict" which way the market was going to go. Indicators typically start with old bars on the left side of the chart, then walk forward to the right side until they obtain enough information to make a decision. Say, for example, that you want to create the RSI indicator on a daily chart and you want to start on October 25. You start at October 25, and make decisions based on information from Oct. 24, 23, etc., until you've collected 14 bars worth of data or however long you set the period. You then say definitively that the RSI on October 25 is X.Now you move on to October 26. You look back at October 25, 24, and so on, until you get the final RSI value for October 26. All of the examples move forward into the future, then look back into the past to get the current value.
A hypothetical repainting indicator
Now let's make a hypothetical RSI indicator that repaints. Say our first date under consideration is October 25. We might start by looking into the past, which is what we did last time. But for the sake of making the example obvious, let's look the other way - into the future.We gather data from October 26, 27, and so on. Now, having learned the future, we jump back to October 25 and pretend that we knew the future all along. The RSI looks amazing.
A Real Example
I receive copies of the 3_Level_ZZ_Semafor every once in a while and it tends to cause problems. It's based on the same idea as the zig zag indicator, which helps it to pick perfect tops and bottoms. Trend traders love looking at it. The information seems like it would be so valuable.
Making an EA off of it, however, presents numerous problems. The trades that the Expert Advisor makes do not match up with what the indicator looks like a few hours later. What actually happens is that the indicator changes its mind. It doesn't leave behind any evidence of its incorrect prediction. The novice EA designer naturally concludes that the programming is all wrong and that we need to fix it.
The first image below shows the value of the semafor on a EURSUD M5 chart at 00:00 on October 10, 2011. You'll notice that a purple dot with the number 2 appears on that bar. The market is moving strongly upwards. The indicator at this point predicts that the move is likely overextended.
If we jump 2 bars into the future at 00:10, now magically a number 3 dot appears. What's worse is that the number 2 dot disappears entirely from the 00:00 bar! The indicator sees that the price jumped up, so it goes back in time and deletes the evidence of its incorrect prediction. If you weren't watching the indicator or taking screenshots, it is as though the number 2 dot was never there.
Test your indicator and look for repainting
No automated process exists to determine whether or not your indicator repaints. It's something that you have to do by staring at the chart during a backtest to see if the values change or not.I like to do this by selecting an Expert Advisor without caring too much about which one I pick. If you don't have any installed, you can grab one from the free Expert Advisor page for the sake of testing.
You'll need to select settings to get the backtester to run. The options that you choose are not important, so long as you have selected something. I highlighted the required items in red below. I personally prefer to use M5 EURUSD charts. M5 is good because the backtester moves over the data quickly on full speed without going so fast that I cannot control the process. It strikes a nice balance between speed and following what's actually happening. I like EURUSD simply because I always have EURUSD data loaded. I don't have to worry about the tester not working, whereas that would likely be an issue if I selected an exotic currency like TRY/ZAR.
When the visual backtest chart pops up, the first thing to do is to load your indicator onto the chart. As the test progresses, watch how the indicator behaves. Some repainting indicators like the Semafor are completely obvious. They repaint on most bars, so it's easy to tell that it is not consistent. You can safely assume that it repaints.
Other indicators are more tricky. They only plot once every 50 bars and sometimes even less frequently. You have to watch closely to make sure that where plots appear, that they don't subsequently dance onto another bar. I like to use the same technique in the first screenshot that I posted with a vertical red line. Whenever the indicator plots something on the chart, mark it with a vertical line. Continue doing so for about a day's worth of data on the M5 chart. Stop the test, then scroll back through the chart. If 100% of the plotted values match the vertical lines, then your indicator does not repaint.
Wednesday, December 14, 2011
Time based orders in MetaTrader 4
The short summary is that time based orders in MT4 are possible. You just need to keep in mind some of the technical limitations. MetaTrader 4 EAs work based off of incoming ticks. Whenever the bid/ask changes by a micro pip or more, that event triggers the EA to do something.
When the markets hum along at a rapid pace, this effect is not noticeable. When the quote flow slows down, however, it can cause the EA to sleep entirely through your trading window.
Many news traders want to bracket buy and sell stops around the price at 08:29 on NFP Friday. Everyone knows that a major news event is about to release. Trading slows down, as does the flow of quotes. The pending orders may not set in time if an incoming tick does not arrive in the 60 seconds between 08:29 and 08:30. This seems unlikely to many novice traders, but it happens frequently enough that we inevitably receive these types of questions whenever we program a time-based order placement EA.
The workaround typically satisfies most traders. EAs place an order at the first available tick within a certain time window. Using NFP as the example, the EA might seek to place bracket orders around the first tick between 08:29-08:32. The chances of making it 2 minutes past 08:30 without a single tick are low. And given that you are taking the first tick, the orders will succesfully bracket around the price the vast majority of the time. It is important to keep in mind how the backend works for those one-off events where the orders do not function as desired.
MetaTrader 5 addresses MT4′s time weakness by offering event driven programming. It is possible to rewrite MQL4 EAs into MQL5 and to demand an action at a precise moment in time. The MQL5 timer actively watches the clock. Regardless of what the markets do, the EA can know to wake up and do whatever action is needed. This is one of the few scenarios where converting from MQL4 into MQL5 comes with obvious advantages.
Wednesday, December 7, 2011
Automated Choice of Brokerage Company for an Efficient Operation of Expert Advisors
Introduction
- Quotes. They slightly differ because of two factors - different data feeds and different filtration that smooths quotes. For some Expert Advisors this may be relevant. Situations may occur when an EA trades often with one brokerage company and rarely on another one.
- Slippage. It may differ much in different brokerage companies. This also may lead to worse characteristics of an EA because of lower expected profit.
- Requotes. In some brokerage companies they are oftener than in others. In this case an EA will miss successful entering points because of large number of requotes.
http://articles.mql4.com/508
Color Changing Indicators in MetaTrader
Many custom indicators in MetaTrader use lines that change colors to indicate a change in trend or market condition. Those types of indicators are among the more common requests that we get for programming Expert Advisors. Unfortunately, these indicators often present problems. What you see on the chart is not necessarily what the indicator says.
Take a look at the image below or click the link to view it in full size. You'll notice that I included the data window for the indicator, which is SuperTrend. As we walk from left to right, the data window does not suddenly shift from Trend Up to Trend Down. Instead, it shifts with an in between period where the trend is both up and down.While the visual effect is immediately obvious, the numbers do not clearly indicate the indicator's condition. In fact, it frequently happens where the indicator entirely misrepresents its true calculation. If the last bar was only green and the indicator says that the current bar is red-green, then we can safely assume that the indicator is switching from green to red.
When the indicator says it's red-green and the past bar was red-green, it gets more tricky. We are forced to keep looking back through time until a "clean" red or green value appears. This enables us to capture the indicator's real value.It does not, however, make for a happy trader. Consider the case where the indicator plots red-green, red, red-green, red. Because of the way MetaTrader draws lines from point to point, the indicator actually appears as a solid red line - a long, beautiful sell signal, right?
In fact, its true calculated values are red, green, red, green. This glitch can make for some ugly surprises. This is especially so when traders expect to ride a down trend and the line appears as solid red, but the indicator (and thus EA) keeps flip flopping on the trade direction. You have to keep this in mind when building EAs around custom indicators.Tuesday, December 6, 2011
Copyright Issues When Programming Expert Advisors
The crux of the matter is what you intend to do with it. Intellectual property (IP) law has a concept called public domain. If you create an indicator and then share it on a public web site, then the file is presumably free for all to use. Essentially, you give away the copyright when you share it for all to see. The only caveat would be if the file or hosting page places an explicit restriction on how the file may or may not be used.
Personal use of an Expert Advisor does not pose a problem. This includes indicators that you purchased. The only legal reason that prevents you from using a commercial indicator in a personal EA is if the purchasing agreement for the indicator forbids creating derivative products, such as using the indicator to build a new EA.
Writing a commercial EA with a public domain custom indicator also meets the hurdle. You cannot take someone else's work and pass it off as your own; you must substantially alter or improve it before the work becomes yours. Turning an indicator into an automated strategy qualifies as a substantial improvement.
The thorniest issue pops up when you want to use a commercial indicator to create a commercial EA without the permission of the indicator's owner. Most people, myself included, would call this theft. The only way that you can do this legally and ethically is to secure an agreement from the indicator's copyright owner.
I am a programmer. If you're deeply concerned about this issue and want to ensure this information truly reflects US law, then I strongly suggest that you speak with an intellectual property attorney. The information above is for general information purposes and should not be construed as legal advice.
Here's a quick summary:
Create a private EA from a public domain custom indicator - Almost always ok, unless the indicator owner forbids it
- Create a private EA from a commercial custom indicator - generally OK, unless your purchasing agreement forbids it
- Create a commercial EA from a public domain custom indicator - generally OK, unless the indicator's creator forbids it
- Create a commercial EA from a commercial indicator - never OK, unless you strike an agreement with the copyright owner
Thursday, December 1, 2011
Central Banks coordinated move - lower USD Swap lines by 50 bp
TOKYO: Asian shares extended gains on Thursday after the world's six major central banks moved to tame a liquidity crunch for European banks by providing cheaper dollar funding.
MSCI's broadest index of Asia Pacific shares outside Japan jumped 1.3 percent, after U.S. stocks rallied 4 percent and European equities rose 2 percent on Wednesday. Japan's Nikkei opened up 1.7 percent on Thursday.
The U.S. Federal Reserve, the European Central Bank and the central banks of Canada, Britain, Japan and Switzerland said on Wednesday they would lower the cost of existing dollar swap lines by 50 basis points from Dec. 5, and arrange bilateral swaps to provide liquidity for other currencies.
A move by China on Wednesday to cut the percentage of cash banks must keep as reserves also boosted sentiment.
The central banks' move aims to thaw severe funding strains for European banks as lenders had been extremely reluctant due to concerns over the eurozone's ability to quickly resolve its debt crisis, and could warm investor stance towards risk.
Monday, November 28, 2011
MF Global foreign branches to return funds
http://www.cftclaw.com/2011/11/mf-global-international-branches-return-funds/
Sunday, November 27, 2011
Europeans prepare for Euro breakup, riots
Banks brace for breakup of euro...
RIOTS WARNED...
Prepare for riots in euro collapse, Foreign Office warns
British embassies in the eurozone have been told to draw up plans to help British expats through the collapse of the single currency, amid new fears for Italy and Spain.
Saturday, November 26, 2011
EES Hardware Development Survey
http://eesfx.com/portal/ees-fx/surveys?survey=1
Understanding RAM Timings
http://en.wikipedia.org/wiki/Memory_timings
Memory timings (or RAM timings) refer collectively to a set of four numerical parameters called CL, tRCD, tRP, and tRAS, commonly represented as a series of four numbers separated with dashes, in that respective order (e.g. 5-5-5-15). However, it is not unusual for tRAS to be omitted, or for a fifth value, the Command rate, to be added on. It also remains a common practice to advertise only CL. These parameters define, in clock cycles, the various forms of latency (responsiveness to random requests) that affect fundamental performance metrics of random access memory. Lower numbers indicate fewer clock cycles are needed, implying faster performance.
Friday, November 25, 2011
Moody's cuts Hungary to junk HUF down 1.8%
Wednesday, November 23, 2011
Germany, Euro on death watch
AP |
"Disastrous" bond sale shakes confidence in Germany
http://www.reuters.com/article/2011/11/23/us-eurozone-idUSTRE7AM0VR20111123