Forex Search Bar

Custom Search

Weekend Robot Development II

Monday, December 28, 2009


While not fully tested, as the market isn't open for trading, I have also completed both the meta-robot concept and a notification system.The meta-robot will look at the trades made via the current profitable robot and impose rules that require trades to open at a better price. The required difference, in pips, will be divided in two and added to the meta-robot's take profit point. For example, if the existing robot makes 6 pips on a position then the new meta-robot may open two pips lower and require a take profit of 7 pips.The combination of a lower entry point and a lower take profit point imply that the meta-robot will always get a better deal. It will also have a higher chance of getting out of it's positions faster. Heh, nothing wrong with making pips faster! Of course, this also implies that the meta-robot may have less ability to open positions as better priced positions may not always be available. There is a bit more complexity to it but I won't bore you with the details.Anyway, as usual, real life trading will tell the real story.Finally, the notification system is implemented as a request to a web site. The web site will be able to look at the request parameters and decide what to do. For now, the web site does nothing interesting. Once I've seen the system in action for a while, and I decide it's working well and that it's useful, I'll see about putting more effort into a delivery system.

Forex Robot Mania


As suggested in my last post...
As a side note, I'm planning to make opposing robots this weekend. They will trade long and short positions in different sub-accounts.I've put together yet another robot. It will trade the same currency both long and short in separate sub-accounts. I'll have to wait until Monday or Tuesday to activate it.A few points I feel are worth mentioning:
I've been developing software and systems for my entire career -- I don't expect everyone can just snap together trading robots.
There are rate limitations, position size limitations and margin use limitations built into a common framework used by all the robots I'm putting together.Anyway, each robot I make has customizations in several areas. Basically these all involve trade entry and exit conditions -- which can range from very simple to very complex.Here is a chunk of common code used in each of my robots. Basically, I call the set of information relating a sub-account and a currency pair a trading context. Here is part of a function that gathers this context:// ***************************************************// Given strings representing the account to trade and// the pair to be traded generate a trading context.// ***************************************************function getTradingContext(useacct,usepair){ // Determine account ID from it's name // ----------------------------------- var acctid = 0; for (id in accounts) { if ( accounts[id].name == useacct ) acctid = id; } if ( acctid == 0 ) { write("Account name '" + useacct + "' not found!"); return null; } // Capture sub-account details in the trading context // -------------------------------------------------- var myContext = accounts[acctid];Once we have the account details we can determine various trading limitations. Here I use the account balance as well as manually controlled "reserve" and "release" values that determine default lot size and margin limit values: // Calculate various balance values for various purposes // ----------------------------------------------------- reserve = 0.00; release = 0.00; bal = myContext.balance; // Avoid silly mistakes // -------------------- if ( release > reserve ) release = reserve; lsbal = bal - reserve; // lot balance trbal = bal - reserve + release; // margin balance ls = (lsbal/20) / 100000; // lots size ml = trbal * 0.099; // margin limit myContext.reserve = reserve; myContext.release = release; myContext.lsbal = lsbal; myContext.lotsize = ls.toFixed(5); myContext.trbal = trbal; myContext.marginlimit = trbal * 0.095;Before a trade can be made the current account margin usage will be compared to the margin limit determined above. When a trade is made the default size of the trade is the lot size determined above. Some other items loaded into the context are shown here: // Capture currency pair details // ------------------------------- myContext.usepair = usepair; myContext.pair = pairs[usepair]; myContext.pipsize = pairs[usepair].pip; myContext.spread = pairs[usepair].ask-pairs[usepair].bid; // Set a spread limit for various currencies // ----------------------------------------- myContext.spreadlimit = (4.26 * myContext.pipsize); if ( usepair == "CHFJPY" ) myContext.spreadlimit = (2.26 * myContext.pipsize); if ( usepair == "USDJPY" ) myContext.spreadlimit = (2.26 * myContext.pipsize); if ( usepair == "EURUSD" ) myContext.spreadlimit = (2.01 * myContext.pipsize);Including the currency pair information, especially the spread, is significant. For example, I do not let my robots trade when the spread is above certain values. This is because higher spreads are generally present when significant news events occur.Later in my robots, in a function that is called when price changes are detected, I'll have something like the following: longctx = getTradingContext("sub1",currentPair); if ( longctx ) tradeLong(longctx); shortctx = getTradingContext("sub2",currentPair); if ( shortctx ) tradeShort(shortctx);Generally, I'll use short term charts and limit robot operations to the opening of a new candle. This avoids needless processing but how you activate your trading functions is up to you. Notice how I can simply pass the context, as developed above, into a trading function? The trading functions have the job of deciding whether or not to open a position in a sub-account that it controls. It may or may not use all the details available to it.There you go. While this isn't complete it is by far the majority of a basic robot framework. If you are a programmer you simply have to figure out the trading rules to apply and write one or more functions that embodies those rules. For example, you may want to apply indicators to a chart, examine previously opened orders, or even trigger an email signal.Hey, as a bonus for reading this far, here is a function that examines current open orders to see how many fall within a price range. Basically, I use this function to make sure that my robots aren't able to accumulate positions around any particular price point. Notice that one of the parameters is the trading context developed above.// ***************************************************// How many orders are open between min an max prices?// ***************************************************function rangeOrderQty(ctx,min,max){ var qty=0; for (ticket in activeOrders) { if ( activeOrders[ticket].accountId != ctx.id ) continue; if ( activeOrders[ticket].pair != ctx.usepair ) continue; if ( activeOrders[ticket].price >= min && activeOrders[ticket].price <= max ) qty++; } return qty;}Finally, the previous code is for the FxSpyder trading platform. This is what I'm using to write robots these days. I continue to trade via Oanada.

US Economy Heads Up !!


If you are wondering what is going on with the US economy, this puzzle piece from CNBC will fit in very nicely.
Dunkelberg: You Can't See Main Street From Wall StreetWhat this is saying is that there probably is not a small business collapse in the works due to credit issues. Smaller businesses will simply wait until they see consumer spending before they bother to access credit.Personally, I am going to suggest that old habits die hard. For all those that did not suffer unemployment, which will be the majority of consumers, the lure of credit and consumption will be waiting for them once confidence returns. As well, they will have fattened their bank accounts to the point that they won't know how to resist putting some of it to use.While we do perhaps have a lot of reasons to fear gloom and doom, we also have a consumer tinderbox waiting for a spark. I don't know which one will win out nor do I know how long it will do so. For example, I don't know if the tinderbox can be lit before housing prices start to rise. What is the ratio of renters vs owners? I do know that the nuggets of information regarding real people, real habits, and their likely actions are few and far between. Too much of the material we read (on CNBC) is very biased by political viewpoints... and you need to find a way to see past that barrier to the good information the partisan baloney conceals.UPDATE: Wednesday 7-Oct-2009As a counterpoint, here is another article talking about problems caused by the ongoing lack of various debt-securitization markets.
Why It's Still Difficult for Many Americans to Borrow MoneyHowever, I will point out that the title seems a bit broad for the issue at hand. It seems that the article is pointing to the idea of a systemic inability for large lenders to resell their lending in order to enable more lending.Perhaps the fact that these institutions, and their rating agency cohorts, have just burned half the planet with their prior recklessness is one reason that purchasers of these products are a bit gun shy?

Buy AUDJPY (On Dips)???????????????


It's very plausible that the RBA (Reserve Bank of Australia) has started the slow process of moving interest rates from emergency levels to normal.
RBA Starts Rate RisesWe'll want to see what happens over the next couple of months in order to confirm this analysis. However, from now on whenever the markets are panicked about the latest downward surprise, it might be time to dip your toes in.We're staring at the bottom of a long term AUDJPY carry trade cycle. I know that Japan has made some noise about not wanting a weak dollar -- but you have to look at the size of their debt load before you start to worry about them being willing or able to withstand high interest rates.The recently touted alternate carry trade, consisting of the AUDUSD, is much more precarious in my opinion. It's great in the short term. However, in the longer term, perhaps a year or more, I think you'll find the greenback starts to get supported by higher interest rates. How else will the USA entice foreign entities to continue to buy and hold debt once the worldwide spate of risk aversion fades?Personally, I think this is a good time to raise capital and slowly work on getting carry trades protected by an in-profit stop loss. Presumably, over the course of months and years, we should find that 80.00 represents resistance, then perhaps 85.00, 90.00, 95.00 or more. We'll probably have Yen intervention from time to time as well and language designed to scare us out... but if you keep an eye on the fundamentals you can probably view these as opportunities to place more capital into stop loss protected profitable trades.Also, if I was managing a countries financial reserves I think I'd be looking for currency trading opportunities involving countries that are both economically sound and likely to continue to raise interest rates over the years as inflation gathers steam. The general business cycle is probably not going to disappear this time around either... regardless of all the hyperbole in the mainstream media............................................................................

Recent Forex Results


It's very rewarding to make an observation and then have results conform to your expectations.Anyway, I'm still letting my robot do my trading for me. It's earning north of 1% per day and I continue to make minor tweaks in an attempt to push the appreciation rate closer to 2% if I can.Recent tweaks involve looking at various stochastic values in order to adjust position entry scale to some degree. Obviously, as the robot only opens long positions, the idea is to open less positions during periods of strength and more positions during periods of weakness.It's never as simple as it sounds.For more radical tweaks or outright departures from the main trading robot I'll strike out with a small amount of capital in a new account. I have one of these experimental robots running right now. It's very heavily tweaked.I've got another radical, but simple, idea in the wings. It will have to wait until next weekend so that I'll have time to implement it.

Robot Trading Six Weeks


Things are going well. As you can see BREAD (Basic Robot Earning All Day) is starting to look like a winner. Return Day 0.1900% Sun 13 September 3.2339% Mon 14 3.1616% Tue 15 3.2615% Wed 16 2.1510% Thu 17 0.4442% Fri 18 --------------- 13.05% 0.1850% Sun 20 2.0259% Mon 21 0.9016% Tue 22 1.1536% Wed 23 0.2460% Thu 24 0.1338% Fri 25 --------------- 4.72% 0.0000% Sun 27 0.1900% Mon 28 0.6862% Tue 29 2.3444% Wed 30 0.3317% Thu 01 October 0.7376% Fri 02 --------------- 4.44% 0.7311% Sun 04 1.0346% Mon 05 1.0587% Tue 06 1.9310% Wed 07 1.6854% Thu 08 0.9897% Fri 09 --------------- 7.75% 0.0915% Sun 11 1.2179% Mon 12 1.4263% Tue 13 1.9298% Wed 14 1.3023% Thu 15 1.2064% Fri 16 --------------- 7.38% 0.2985% Sun 18 1.6787% Mon 19 2.1774% Tue 20 2.3200% Wed 21 2.3552% Thu 22 1.2715% Fri 23 --------------- 10.52%Looking back, this system was too aggressive during the first week. Later tweaks reduced this aggressiveness to some degree but also lead to lower earnings. At the moment aggression is scaled based on market factors so that in some situations it will take a larger slice.Although the last week of earnings was great it's really too early to know how this robot will perform in the long term. As mentioned in a recent post I know that BREAD will earn the most during a consolidation period with prices confined in a range that ends in an upward break. I do expect the AUDJPY to exhibit this behavior a lot but it certainly won't do this all the time.Now what?This thing has been trading live for a while now. The only thing I plan to do is keep on letting it run until I'm able to create something better. ARTFAB (A Rising Tide Floats All Boats) is the latest attempt...UPDATE: Something I'm curious about is if I'll notice a longer term cycle in robot behavior. For example, the last time BREAD earned more than 10% in a week there were a couple of weeks that then underperformed. It is possible that the market will exhibit behavior that is clearly visible through trading profits.UPDATE: I have discovered this very good blog... Hack the market. This suggest to me that I can gauge my daily returns against that of the bigger players to see whether not I'm doing well. Notice that the smallest group seems to have much better returns -- and thus is where I should be comparing my results. Perhaps my stretch goal of 2.5% is a little two low? Regardless..............................................

Minor BREAD Adjustments


The BREAD trading robot has had a minor tweak during this last weekend.To make a long story short, another risk modification metric has been defined. If things work as planned this will give the robot the ability to trade over a wider currency pair price move. Obviously, the plan is to simultaneously maintain the same level of profitability.My initial readings on quantitative analysis, via forums, seem to indicate another insular pool of thinking. Unfortunately, it seems that ego often persuades people that their own area of expertise is the right area while other areas have nothing to offer.Advice to any that will take it...Find the important or valuable information without consideration of the source. Often, combining a few great insights from various fields (validly) will provide greater value than being very proficient at all the skills of a particular field. The real world often is not as simple as the assumptions made in order to perform calculations at the edge of the envelope.

Challenging Times !!!!!!!!!!!!!!!!!!!


While I realize the world went through a bit of an unwind, before and after the Dubai incident, I've been busy with work and family issues instead.Things have just been incredibly busy!In any case, what with the volatility and unwinding that has been going on it's probably a good time to be inactive. I did manage to blow up my small discretionary account (my robots are far better traders than I am) but that's insignificant.However, the big news, from my own point of view, is that I have some tweaks for my up-and-coming robot. Basically, I need it to detect a downward slide quickly and then decide not to waste it's risk capital on redundant positions.

The new global balance – Part II: Higher rates rather than weaker dollar in 2010


Many expect the dollar to continue to depreciate over the foreseeable future. This column suggests that it may strengthen in 2010 if the Federal Reserve exits quantitative easing sooner than its counterparts and the US economy enjoys a strong rebound.



Many expect the dollar to continue to depreciate over the foreseeable future. This column suggests that it may strengthen in 2010 if the Federal Reserve exits quantitative easing sooner than its counterparts and the US economy enjoys a strong rebound.
In the early months of the crisis at the end of 2008, the US dollar rose sharply as US interest rates fell sharply (IMF 2009). In a previous column, we argued that the puzzling response of the dollar and US rates during the panic of the fourth quarter of 2008 – stronger dollar and lower rates – would be temporary and that the return of risk appetite and structural aspects of the new global balance – smaller gross capital flows and the savings drain resulting from global fiscal policies – would steepen rates and weaken the dollar. Since the end of March, ten-year US Treasury yields have increased 76bp (to 3.4%)

How will the value of the dollar and long-term interest rates respond in 2010? It seems likely that both US monetary and fiscal policy will join forces to push long-term rates higher when quantitative easing ends. The end of quantitative easing in 2010 and the start of the tightening cycle in the US – both supportive forces for the dollar – should also compensate dollar-negative fiscal considerations. Thus, contrary to the popular view of a continuously weaker dollar, the phasing out of quantitative easing implies that the dollar may strengthen in 2010 relative to other currencies.
Exiting quantitative easing in 2010: Dollar positive, rates negative
A priori, one would have expected the bold US fiscal stimulus to have already shown its teeth by now; after all, the US fiscal deficit will be close to -12% of GDP in 2009. So isn’t the mild steepening of US rates (roughly 80bp for ten-year Treasuries since March) disappointing? We believe that the stimulus has barely affected the market yet, courtesy of the unrelenting efforts of the Fed to purchase long-term risk-free assets. The supply of fixed-income issuance in the US has more than doubled in 2009 relative to the average of recent years (Figure 3), but the net issuance net of the Fed’s purchases – that is, the supply of assets that effectively hits the private market – is expected to be only $845 billion in 2009, around 30% smaller than in normal times. We can safely say that the effect of the fiscal expansion on US bond markets has been dramatically offset by the Fed’s quantitative easing.

But the supply net of Fed purchases is expected to rise considerably in 2010, both as quantitative easing purchases taper off and the supply of US Treasuries ramps up (an increase to $2.1trillion seems likely, almost twice as large as a normal year). Moreover, short-term US rates are also likely to increase in 2010 if expectations about the US economy continue to be revised upward. Thus, even if demand for riskless assets remains temporarily high in 2010 (due to a steep yield curve and large demand for riskless assets by capital-scarce banks), these suggest strong upward pressures for US long-term rates.
Quantitative easing purchases also have had crucial implications for currencies. As we highlighted in March, quantitative easing is a policy that favours “rates over currencies” in the sense that the central banker chooses to keep rates low at the expense of a weaker currency. In a recent report, we document how the directional implication of global quantitative easing are consistent with the departures from the so-called recovery trade observed over the summer months. In particular, they are consistent with the rally in equities without an increase in long-term yields, the fact that the effective dollar index continued its decline (consistent with the strong quantitative easing in the US relative to the rest of the world), the yen appreciated vis-à-vis the dollar (consistent with the relative tightening in Japan), and sterling weakened against the euro and yen (consistent with the relatively stronger quantitative easing in the UK).
As a result, the timing of the remaining asset purchases is critical for the evolution of rates and currencies in coming quarters. Asset purchases of around 3% of US GDP remain in the pipelines (Figure 4). The Fed has said that, without changing the total amount of its agency mortgage-backed securities and agency debt purchases, it would “gradually slow the pace of these purchases in order to promote a smooth transition in markets and anticipates that they will be executed by the end of the first quarter of 2010.” Whether the Fed’s quantitative easing will slow down enough in the coming months to imply higher rates is uncertain. It will likely continue to put downward pressures on the dollar temporarily, but the pressure for lower rates is bound to be smaller. The increase in supply and the continuation of the unwinding of risk aversion should be enough to get long-term yields rising again by the end of 2009.


This implies an interesting scenario for 2010 where quantitative easing in the US is set to end. The implications for long-term rates are clear – they can only move up. But contrary to the popular view of a continuously weaker dollar, the phasing out of quantitative easing implies that the dollar may strengthen in 2010 relative to other currencies, especially if the Fed swings into tightening mode faster than Europe and Japan.
The misleading undoing of global imbalances
Some commentators would add the sharp improvement in the US current account deficit to the set of supportive factors to the dollar in 2010. Figure 5 shows that the US current account deficit fell from 6.5% of GDP in 2006 to about 3% of GDP in the second quarter of 2009, reducing the net supply of dollar assets to the world by more than half. But the narrowing of the US current account deficit may not be as benign for the dollar as most believe, as it partly reflects temporary considerations that mask the effects of US fiscal policy on the dollar.

First, the reduction of global trade balances is partly the result of the cyclical collapse in global trade. A proportional contraction of imports and exports has the effect of moving deficits and surplus closer to equilibrium. As soon as global trade picks up, the process is likely to be at least partially reversed. Thus, the decline in the US current account deficit has temporary components that may have initially led to an overcorrection. Second, as Figure 5 shows, the improvement in the current account was the result of the sharp fall in investment, as the increase in personal savings has been more than offset by the public dis-saving (the “savings drain” discussed in our previous column). If a strong US rebound materialises, this could imply that investment finally starts increasing after a long period of contraction and, as risk aversion simultaneously fades away, a growing US current account deficit may face tougher financing terms through 2010. In terms of the value of the dollar, this is likely to have a negative impact, partly compensating the supportive role of the relative tightening of US monetary policy.
The dollar path relative to emerging market currencies may face old challenges. The post-crisis version of the so-called Bretton Woods II – the desire of some emerging markets’ central banks to prevent sharp currency fluctuations through leaning-against-the-wind intervention – is likely to imply that the countries with less central bank resistance will likely have their currencies strengthen the most relative to the dollar in the next year.1 Thus, while currencies in emerging Asia and Latin America appear the natural candidates to appreciate vis-à-vis the dollar, the undoing of global imbalances may also fall disproportionately on more flexible G10 commodity currencies such as the Australian and New Zealand dollars (and even on the euro), a pattern that has become more visible in recent weeks.

In short, in contrast with growing dollar scepticism and even though US external accounts continue to point to dollar weakness despite the recent correction, the fast rebound of the US economy and the undoing of the monetary stimulus may deliver higher rates in lieu of a weaker dollar in 2010.
Footnotes
1 See Kiguel and Levy-Yeyati (2009). If the crisis taught anything to central bankers, it was the convenience of liquid foreign currency reserves in times of trouble. In a recent paper, Obstfeld et al. (2008) make a strong case for the prudential motive for reserve accumulation.
References
Broda, C., P. Ghezzi and E. Levy-Yeyati (2009), “The new global balance: Financial de-globalisation, savings drain, and the US dollar”, VoxEU.org, 22 May.
Kiguel, A. and E. Levy-Yeyati (2009), “Back to 2007: Fear of appreciation in emerging economies”, VoxEU.org, 29 August.
Obstfeld, M., J. Shambaug, and A. Taylor (2008), “Financial Stability, the Trilemma and International Reserves”, NBER Working Paper 14217.
IMF(2009) World Economic Outlook, Crisis and Recovery, April.

Tides may turn in the forex market into 2010


The final weeks of 2009 have brought a sense that tides may be turning in the foreign exchange market reflecting broader developments in the global economy. The predominant changes relate to the dollar.
December’s 5 percent recovery in the USD index is linked to an improved outlook for the U.S. economy.
There are risks to this optimism, but short dated U.S. yields have pushed higher since late November allowing the dollar to shrug off the downtrend that characterised it during 2009 and potentially embark upon a cyclical recovery; at least against some currencies.
Better U.S. economic data in early December couldn’t have come soon enough for the Japanese authorities. In late November USD/JPY had fallen to a 14-year low.
Having proclaimed the economy to be in deflation the Japanese government openly pressured the Bank of Japan to take further supportive policy measures.
The Bank announced an emergency credit facility and subsequently stated it will not tolerate a negative inflation rate. This, combined with a rise in short dated U.S. yields, has allowed the JPY to take back the mantle of favoured funding currency from the dollar. The downtrend in USD/JPY that has been in place since mid 2007 may be turning.
In view of weak domestic growth prospects, there is a lot of political will in Japan and the Eurozone in favour of a stronger dollar.
During 2009 EUR/USD was driven almost exclusively by the pros and cons (mostly cons) of the USD; Eurozone fundamentals were decidedly in the back seat. Over the last couple of weeks, there has been an increase in the negative press surrounding the fiscal difficulties of some EMU members which has pressured the EUR.
No doubt there is more bad news on budgets waiting in the eurozone’s wings which could come from Greece, Ireland, Spain or Portugal.
Austria, the Baltics and Iceland may also have a few nasty surprises up their sleeves. While there appears to be no real risk of the European Economic and Monetary Union breaking down, there could be sufficient bad news to highlight the inadequacies of EMU’s budget criteria and bring a rocky ride for the euro.
December’s 2.9 percent drop in cable is more moderate than the 4.8 percent decline in EUR/USD. The EUR’s underperformance reflects its sovereign deficit problems. That said the outlook for the UK remains mired by its own weighty problems.
While decent labour data have brought the first really good UK news since the start of the recession, the issues surrounding the budget deficit, slow growth and forthcoming general election are likely to weigh on sterling at least into the spring; with the EUR under pressure, cable is likely to reflect most of this weakness.
It is feasible that the USD could maintain a better tone vs the EUR, the JPY and GBP while still underperforming higher yielding currencies.
AUD/USD has moved off its recent highs on fears that having tightened policy three times the RBA may leave rates steady for an extended period.
Given Australia’s proximately to the fast growing Asian region, in all likelihood the RBA will be hiking again before the Fed is even off the starting blocks. AUD/USD may see parity in 2010.
While the dollar’s downtrend may persist against some currencies, dollar appreciation vs the yen and the euro would likely be sufficient to keep the USD index trending higher.
This would relieve immediate pressure on China to revalue its effective USD peg. That said once China is confident that external demand has strengthened a revaluation of the CNY will become more likely, meaning a move is possible in H2 2010.

 
Forex Crown - Wordpress Themes is powered by WordPress. Theme designed by Web Hosting Geeks and Top WordPress Themes.
por Templates Novo Blogger