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.

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