BTCapital Advisors

Your Prosperity is Our Priority

Archive for April 15th, 2008

Timing Trades With The Commodity Channel Index

Posted by IWAN BUDHIARTA on April 15, 2008

The Commodity Channel Index (CCI) is an oscillator originally developed by Donald Lambert and featured in his book “Commodities Channel Index: Tools for Trading Cyclical Trends”. Since its introduction, the indicator has grown in popularity and is now a very common tool for traders to identify cyclical trends not only in commodities but also equities and currencies. In this article, we’ll take a look at what exactly the CCI calculates, and how you can apply it to enhance your trading.
Understanding the CCI
Like most oscillators, the CCI was developed to determine overbought and oversold levels. The CCI does this by measuring the relation between price and a moving average (MA), or, more specifically, normal deviations from that average. The actual CCI calculation, shown below, illustrates how this measurement is made.

The one prerequisite to calculating the CCI is determining a time interval, which plays a key role in enhancing the accuracy of the CCI. Since it’s trying to predict a cycle using moving averages, the more attuned the moving average amounts (days averaged) are to the cycle, the more accurate the average will be. This is true for most oscillators. So, although most traders use the default setting of 20 as the time interval for the CCI calculation, a more accurate time interval reduces the occurrence of false signals. Here are four simple steps to determining the optimal interval for the calculation:

  1. Open up the stock’s yearly chart.
  2. Locate two highs or two lows on the chart.
  3. Take note of the time interval between these two highs or lows (cycle length).
  4. Divide that time interval by three to get the optimal time interval to use in the calculation (1/3 of the cycle).

Here’s an example of this method applied to Sun Microsystems (SUNW):

Figure 1: Chart courtesy of StockCharts.com

Here we can see that one cycle (from low to low) starts at Oct 6 and finishes on Aug 9. This represents roughly 225 trading days, which, divided by three, gives a time interval of about 75.

Applying the CCI
Since it was invented, the CCI calculation has been added as an indicator to many charting applications, eliminating the need (thankfully) to do the calculations manually. Most of these charting applications simply require you to input the time interval that you would like to use. Figure 2 shows a default CCI chart for SUNW:

Figure 2: Chart courtesy of StockCharts.com

Note that the CCI actually looks just like any other oscillator, and it is used in much the same way. (To learn more about oscillators, see Getting to Know Oscillators.) Here are the basic rules for interpreting the CCI:
Possible sell signals:

  • The CCI crosses above 100 and has started to curve downwards.
  • There is bearish divergence between the CCI and the actual price movement, characterized by downward movement in the CCI while the price of the asset continues to move higher or moves sideways.

Possible buy signals:

  • The CCI crosses below -100 and has started to curve upwards.
  • There is a bullish divergence between the CCI and the actual price movement, characterized by upward movement in the CCI while the price of the asset continues to move downward or sidesways. Figure 3 shows another chart of SUNW, but for this chart, the time interval of 75 (which we calculated above) was used for the calculation:

    Figure 3: Chart courtesy of StockCharts.com

    The red arrows show turning points that emit sell signals, while the green arrow shows a turning point emitting buy signals. The short blue lines, indicating the impending trends, show the divergence between the CCI and price.
    Always Get Confirmation
    It is extremely important - as with many trading tools – to use the CCI with other indicatorsPivot points work well with the CCI because both methods attempt to find turning points. Some traders also add moving averages into the mix. In Figure 3 above, you can see that the 60-day exponential moving average (violet horizontal line) provides a good support level; however, determining which MA level is best varies by stock (to learn more, see Introduction To Moving Averages ).

    Another possible supplement to the CCI is the use of candlestick patterns, which can help confirm exact tops and bottoms throughout the CCI’s “selling period” (time in which it is above 100) or “buying period” (time in which it is below -100).

    Conclusion

    The Commodity Channel Index is an extremely useful tool for traders to determine cyclical buying and selling points. Traders can utilize this tool most effectively by (a) calculating an exact time interval and (b) using it in conjunction with several other forms of technical.

Posted in Investment Strategy | Leave a Comment »

Introduction To Types Of Trading: Scalpers

Posted by IWAN BUDHIARTA on April 15, 2008

One of the most confusing aspects of the trading profession is there is no single definition of “trader”. Traders come in many different shapes and sizes, colors and varieties.

Traders generally focus on a specific class of security, mostly common stocks, but they may also trade equity options, commodity futures, financial futures, futures options, bonds, foreign markets, and so forth. The security of choice also dictates the specific market(s) on which they trade: NYSE or Nasdaq, Chicago Board Options Exchange, The Chicago Board of Trade and so on.

When trading common stocks, professionals will generally undertake one of several styles and stick only to that style. This is an important point since traders are always at the risk of being distracted by the din of ubiquitous market commentary and conflicting trading styles. Traders are constantly soul searching and questioning their own chosen approach. Some amount of experimentation is advisable, particularly at the beginning of your trading career, but deviating from a disciplined, focused approach can be disastrous later when you are establishing your style.

Some of your first decisions will determine where your niche is and what type of a trader you want to be. There are at least five distinct styles of common-stock trading, each completely unrelated to the others. The style that you choose will likely reflect your intellectual strengths, your understanding of various aspects of the markets’ operations and your temperament.

Here are the major styles of equity trading:

  • Scalping - The scalper is an individual who makes dozens or hundreds of trades per day, trying to “scalp” a small profit from each trade by exploiting the bid-ask spread.
  • Momentum Trading - Momentum traders look to find stocks that are moving significantly in one direction on high volume and try to jump on board to ride the momentum train to a desired profit.
  • Technical Trading - Technical traders are obsessed with charts and graphs, watching lines on stock or index graphs for signs of convergence or divergence that might indicate buy or sell signals.
  • Fundamental Trading - Fundamentalists trade companies based on fundamental analysis, which examines things like corporate events such as actual or anticipated earnings reports, stock splits, reorganizations or acquisitions.
  • Swing Trading - Swing traders are really fundamental traders who hold their positions longer than a single day. Most fundamentalists are actually swing traders since changes in corporate fundamentals generally require several days or even weeks to produce a price movement sufficient enough for the trader to claim a reasonable profit.

Novice traders might experiment with each of these techniques, but they should ultimately settle on a single niche, matching their investing knowledge and experience with a style to which they feel they can devote further research, education and practice. Entire textbooks are devoted to each style, although many titles such as “Day Trade Online” or “How to Get Started in Electronic Day Trading” are unclear about what type of trading they espouse.

I devote the balance of this article to explaining scalping, a trading technique which which the trader scalps small profits by exploiting the spread of a slow-moving stock. Here are articles that explore the other types of trading: momentum tradingtechnical trading and fundamental trading and swing trading.

The Scalper
The scalper generates trading profits from stocks that are not moving, make tiny (or teenie) profits from each trade by buying a stock on the bid and then turning around and selling at the ask. Provided that the stock does not move, scalpers can profit all day by making dozens (or hundreds) of trades, buying at the highest price at which they feel comfortable and selling at the lowest price that guarantees sufficient profit while still being attractive to buyers.

The scalper’s role is exactly the same as that of the market maker (also known as the specialist), a dealer who, by trading stock from his or her own inventory, maintains an orderly market in any given stock. The specialist is basically a scalper on steroids, as the specialist trades many times more volume per day than the average scalper. The specialist, however, is bound by strict exchange rules while the individual trader is not. For example, on the Nasdaq all market makers are required to post at least one bid and one ask at some price level, thereby making a two-sided market for each stock that they cover.

Due to the overlap of roles, the scalper is always competing with the market maker for profits. Unfortunately, the lowly scalper is almost always at a disadvantage due to the market maker’s advantages: superior execution speed, perhaps a greater knowledge of trading and the ability to “bluff” the market by placing a bid or ask that exaggerates his or her own true position.

The other factor working against the scalper is decimalization, whereby stock prices that were previously quoted in fractions are now quoted in decimals. With fractions, scalpers were always aiming for at least a sixteenth of a point in profit, also known as a teenie, equating to 6.25 cents per share. On a 1,000-share trade, for example, buying a stock at 10 and selling it at 10 and one sixteenth, a scalper would generate $62.50 in profits before commissions.

With the advent of decimalization, teenies are now toast, and the difference between bid and ask may be a single penny. On the 1,000-share trade described above, buying at $10 and selling at $10.01 generates only $10 in profits, most likely not even enough to cover trading commissions.

This is not to say that scalpers’ opportunity for profits have been lost. Depending on the stock traded and its liquidity, spreads may remain much higher than a penny, allowing scalpers to generate even more than a teenie. By increasing the number of shares bought and sold (trading 2,000 instead 1,000, for example), scalpers can compensate for any realized decline in spreads, but this comes at the expense of increasing their risk. As for any style of trading, finding a niche from which he or she can derive profits is the trader’s utmost goal. Once that niche is found, the scalper can refine his or her technique, successfully trading for pennies just as he or she was trading for teenies.

Again, here are other articles on the other types of trading: momentum tradingtechnical trading and fundamental/swing trading.

Posted in Investment Strategy | Leave a Comment »

Scalping: Small Quick Profits Can Add Up

Posted by IWAN BUDHIARTA on April 15, 2008

Scalping is a trading style specializing in taking profits on small price changes, generally soon after a trade has been entered and has become profitable. It requires a trader to have a strict exit strategy because one large loss could eliminate the many small gains that the trader has worked to obtain. Having the right tools such as a live feed, a direct-access broker and the stamina to place many trades is required for this strategy to be successful.

Scalping is based on an assumption that most stocks will complete the first stage of a movement (a stock will move in the desired direction for a brief time but where it goes from there is uncertain); some of the stocks will cease to advance and others will continue. A scalper intends to take as many small profits as possible, not allowing them to evaporate. Such an approach is the opposite of the “let your profits run” mindset, which attempts to optimize positive trading results by increasing the size of winning trades while letting others reverse. Scalping achieves results by increasing the number of winners and sacrificing the size of the wins. It’s not uncommon for a trader of a longer time frame to achieve positive results by winning only half or even less of his or her trades - it’s just that the wins are much bigger than the losses. A successful scalper, however, will have a much higher ratio of winning trades versus losing ones while keeping profits roughly equal or slightly bigger than losses.

The main premises of scalping are:

  • Lessened exposure limits risk - A brief exposure to the market diminishes the probability of running into an adverse event.
  • Smaller moves are easier to obtain – A bigger imbalance of supply and demand is needed to warrant bigger price changes. It is easier for a stock to make a 10 cent move than it is to make a $1 move.
  • Smaller moves are more frequent than larger ones - Even during relatively quiet markets there are many small movements that a scalper can exploit.

Scalping can be adopted as a primary or supplementary style of trading.

Primary Style
A pure scalper will make a number of trades a day, between five and 10 to hundreds. A scalper will mostly utilize one-minute charts since the time frame is small and he or she needs to see the setups as they shape up as close to real time as possible. Quote systems Nasdaq Level II, TotalView and/or Times and Sales are essential tools for this type of trading. Automatic instant execution of orders is crucial to a scalper, so a direct-access broker is the favored weapon of choice.

Supplementary Style
Traders of other time frames can use scalping as a supplementary approach in several ways. The most obvious way is to use it when the market is choppy or locked in a narrow range. When there are no trends in a longer time frame, going to a shorter time frame can reveal visible and exploitable trends, which can lead a trader to scalp.

Another way to add scalping to longer time-frame trades is through the so-called “umbrella” concept. This approach allows a trader to improve his or her cost basis and maximize a profit. Umbrella trades are done in the following way:

  • A trader initiates a position for a longer time-frame trade.
  • While the main trade develops, a trader identifies new setups in a shorter time frame in the direction of the main trade, entering and exiting them by the principles of scalping.

Practically any trading system, based on particular setups, can be used for the purposes of scalping. In this regard, scalping can be seen as a kind of method of risk management. Basically any trade can be turned into a scalp by taking a profit near the 1:1 risk/reward ratio. This means that the size of profit taken equals the size of a stop dictated by the setup. If, for instance, a trader enters his or her position for a scalp trade at $20 with an initial stop at $19.90, then the risk is 10 cents; this  means a 1:1 risk/reward ratio will be reached at $20.10.

Scalp trades can be executed on both long and short sides. They can be done on breakouts or in range-bound trading. Many traditional chart formations, such as a cup and handle or triangle, can be used for scalping. The same can be said about technical indicators if a trader bases decisions on them.

Three Types of Scalping
The first type of scalping is referred as “market making”, whereby a scalper tries to capitalize on the spread by simultaneously posting a bid and an offer for a specific stock. Obviously, this strategy can succeed only on mostly immobile stocks that trade big volume without any real price change. This kind of scalping is immensely hard to do successfully as a trader must compete with market makers for the shares on both bids and offers. Also, the profit is so small that any stock’s movement against the trader’s position warrants a loss exceeding his or her original profit target.

The other two styles are based on a more traditional approach and require a moving stock where prices change rapidly. These two styles also require a sound strategy and method of reading the movement.

The second type of scalping is done by purchasing a large number of shares that are sold for a gain on a very small price movement. A trader of this style will enter into positions for several thousand shares and wait for a small move, which is usually measured in cents. Such an approach requires highly liquid stock to allow for entering and exiting 3,000 to 10,000 shares easily.

The third type of scalping is the closest to traditional methods of trading. A trader enters an amount of shares on any setup or signal from his or her system, and closes the position as soon as the first exit signal is generated near the 1:1 risk/reward ratio, calculated as described earlier.

Conclusion
Scalping can be very profitable for traders who decide to use it as a primary strategy or even those who use it to supplement other types of trading. Adhering to the strict exit strategy is the key to making small profits compound into large gains. The brief amount of market exposure and the frequency of small moves are key attributes that are the reasons why this strategy is popular among many types of traders.

(For further reading, see Introduction To Types Of Trading: Scalpers.)

Posted in Investment Strategy | Leave a Comment »

Trading Systems Coding

Posted by IWAN BUDHIARTA on April 15, 2008

INTRODUCTION

Trading systems are simply sets of rules that traders use to determine their entries and exits from a position. Developing and using trading systems can help traders attain consistent returns while limiting risk. In an ideal situation, traders should feel like robots, executing trades systematically and without emotion. So, perhaps you’ve asked yourself: What’s to stop a robot from trading my system? The answer: Nothing! This tutorial will introduce you to the tools and techniques that you can use to create your own automated trading system.

How Are Automated Trading Systems Created?
Automated trading systems are created by converting your trading system’s rules into code that your computer can understand. Your computer then runs those rules through your trading software, which looks for trades that adhere to your rules. Finally, the trades are automatically placed with your broker.

This tutorial will focus on the second and third parts of this process, where your rules are converted into a code that your trading software can understand and use.

What Trading Software Supports Automated Trading Systems?
There are many trading programs that support automated trading systems. Some will automatically generate and place trades with your broker. Others will automatically find trades that fit your criteria, but require that you place the orders with your broker manually. Moreover, fully automatic trading programs often require that you use specific brokerages that support such features; you may also have to complete an additional authorization form.

Advantages and Disadvantages
Automated trading systems have several benefits, but they also have their downsides. After all, if someone had a trading system that automatically made money all the time, he or she would literally own a money making machine!

Advantages:

  • An automated system takes the emotion and busy-work out of trading, which allows you to focus on improving your strategy and money management rules.
  • Once a profitable system is developed, it requires no work on your part until it breaks, or market conditions demand a change.

Disadvantages:

  • If the system is not properly coded and tested, large losses can occur very quickly.
  • Sometimes it is impossible to put certain rules into code, which makes it difficult to develop an automated trading system.

In this tutorial you will learn how to plan and design an automated trading system, how to translate this design into code that your computer will understand, how to test your plan to ensure optimal performance and, finally, how to put your system to use.

Trading Systems Coding: System Design

The first step when coding any application is the design phase. Whether coding a software application or a trading system, careful design and planning will help you finish in a shorter amount of time with fewer errors. We will be using a simple three-step process to design our trading system.

Step 1: Create Your Trading System Rules
The first step when designing a trading system is simply coming up with the rules by which your system will operate. There should be four core rules to every trading system:

  1. Buy – Identify when you want to buy a position.
  2. Sell – Identify when you want to sell a position.
  3. Stop – Identify when you want to cut your losses.
  4. Target – Identify when you want to book a gain.

So, for example:

  1. Buy – When the 30-day moving average (MA) crosses above the 60-day MA
  2. Sell – When the 30-day MA crosses below the 60-day MA
  3. Stop – Maximum loss of 10 units
  4. Target – Target of 10 units

This example system will buy and sell based on the 30- and 60-day moving averages and will automatically book gains after a 10-unit profit or sell at a loss after a 10-unit move in the opposite direction.

Step 2: Identify the Components of Each Rule
Now that we have our rules down, we need to identify the components involved in each rule. Each component should contain two elements:

  1. The indicator or study used
  2. The settings for the indicator or study

These components should be constructed by typing the shorthand name for the study, followed by the settings in parentheses. These settings in parentheses are referred to as “parameters” of the indicator or study. Occasionally, a study may have multiple parameters, in which case you simply separate them with commas.

Let’s take a look at a few examples:

  1. MA(25) – 25-day moving average
  2. RSI(25) – 25-day relative strength index
  3. MACD(Close(0),5,5) – Moving average convergence divergence set based on today’s close, with a five-day fast length and a five-day slow length

If you are unsure of how many parameters a certain component requires, you can simply consult your trading program’s documentation, which lists these components along with the values that need to be filled in. For example, we can see that Tradecision tells us that we need three parameters with MACD:

So, for the example mentioned in step one, we would use:

  1. MA(30) – Meaning 30-day moving average
  2. MA(60) – Meaning 60-day moving average

Step 3: Adding Action
Now we will add actions to our rules. Each action adheres to the following basic format:

IF Condition [WHILE Condition] THEN Action


Typically, the condition will consist of the components and parameters you created above, while the action will consist of buy or sell. Conditions may also consist of simple English if no component is present. Note that the “while” component is optional.

Here are a few examples to help illustrate this point:

  • IF MA(30) Crosses Above MA(60) THEN Buy
  • IF MA(30) Crosses Below MA(60) WHILE Volume(20,000) THEN Sell
  • IF EMA(25) Is Greater Than MA(5) THEN Sell
  • IF RSI(20) Is Equal To 50 THEN Buy

So, for the example we’ve been using, we’d simply list:

  • IF MA(30) Crosses Above MA(60) THEN Buy
  • IF MA(30) Crosses Below MA(60) THEN Sell
  • IF our trade has 10 units of profit THEN Sell
  • IF our trade has 10 units of loss THEN Sell

What’s Next?
Next, we’ll take a look at converting these rules into a code that your computer can understand!

Trading Systems Coding: The Coding Stage

Now that we have a design document in hand, we can look at how these rules are put into code that a computer can understand. In this section, we’ll break down a section of code and look at it piece by piece. For this example, we will use MetaTrader’s programming language MetaQuotes II to build a very simple moving average trading system.

Defines: MATrendPeriod(100);

Var:MaCurrent(0),MaPrior(0);

If Bars < 100 Then Exit;

If FreeMargin < 1000 then Exit;

maCurrent =iMA(MATrendPeriod,MODE_SMA,0);

maPrior =iMA(MATrendPeriod,MODE_SMA,1);

If maCurrent > maPrior then

{SetOrder(OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,RED); Exit;};

If maCurrent < maPrior then

{SetOrder(OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,RED); Exit;};

The If/Then Format
After taking a brief look at this code, you should recognize a few elements that we touched on in the design phase. For example, you should recognize the If/Then format that we used when constructing our design. To get a better understanding of this code, let’s break it down and analyze each part:

Defines: MATrendPeriod(100);

Var: MaCurrent(0),MaPrior(0);

Here, we’re simply defining the moving average that we are using by saying that we want it to be an average of the last 100 bars. The Defines function here lets us do that for any type of data we want. After that, we simply invent two variables (items which we create to hold data) MaCurrent(0) and MaPrior(0). These two variables will hold the data that we will set in a later step.

If Bars < 100 Then Exit;

If FreeMargin < 1000 then Exit;

Here we see the If/Then format that we used in the design phase put to work. These two statements tell the computer to exit if certain conditions aren’t met. Let’s translate these two commands into English:

If Bars < 100 Then Exit; à “If there are fewer than 100 bars (data points) on the chart, then exit the program without doing anything.”

If FreeMargin < 1000 then Exit; à “If my account has less than $1,000 in available funds, then exit the program without doing anything.”

You can translate any criteria you want into this format and put it at the beginning of your program in order to adapt to certain situations.

Buy and Sell Signals

maCurrent =iMA(MATrendPeriod,MODE_SMA,0);

maPrior =iMA(MATrendPeriod,MODE_SMA,1);

Now let’s make use of the two variables we described above. Let’s take these statements apart to see what they are doing:

maCurrent = à Here we are telling the computer to assign the following information to “maCurrent”.

iMA(MATrendPeriod,MODE_SMA,0); à Here we are using a simple statement, which uses the following basic format: Study(TimePeriod,Mode,Start).

Note that you can replace iMA with MACDRSI or any other studies your trading system may be using. You can also replace the parameters to suit your own system.

If maCurrent > maPrior then

{SetOrder(OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,RED); Exit;};

Now we are getting somewhere! Here is the part of the code that tells the computer when to buy. Notice that we are making use again of the If/Then format that we used in the design document. Let’s translate this to English to see what’s happening:

If maCurrent > maPrior then { à “If the current Moving Average is greater than the prior Moving Average, then…”

SetOrder( à “Create an order entry to …”

OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,RED à “Buy my defined number of lots at the ask price plus my take profit point, and mark it as a red point on the chart.”

); à “End the order.”

Exit; à “Exit the trading strategy.”

}; à “End the If/Then statement.”

Note that the Take Profit Point is something that is defined by users when they add the trading system to their charts. Also notice that we are buying at the ask price and selling at the bid price – this is a key feature, especially when creating a system for stocks.

If maCurrent < maPrior then

{SetOrder(OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,RED); Exit;};

Finally, we have our code that tells the computer when to take a short position. Note that this statement is almost identical to the “buy” statement, aside from the OP_SELL instead of OP_BUY as well as the usage of the bid price as opposed to the ask price.

Conclusion
And there you have it – the bare bones of what a trading system code looks like. Please note that the above code is not a complete trading system, as it does not include any commands to close open positions. Such additional aspects can be implemented using a format similar to the code we’ve shown.

In the next section of this tutorial, we will go into greater depth regarding the specific ways in which your trading system can be converted to code.

Trading Systems Coding: The Coding Process

By now you should have a design in hand as well as a basic idea of what the code looks like. In this section, we’ll take a more in-depth look at how a program is created. After reading this section, you should be able to understand basic program structure and be able to convert your design to code!

An Overview
There are two basic parts to a program:

  • Variables – These are items that hold data. This can be data that you collect from the user, or any other data.
  • Statements – These form the core of the program. Statements manipulate the data to get results that can be converted to actions.

In addition to these core components, there are also several optional components:

  • Functions – These are simply collections of related statements that can be used to perform a specific task. For example, a function telling you when to buy might include a statement to check whether you have enough money, a statement to determine whether it meets your criteria and a statement to place the order. A function combines these, allowing you to simply call on the function instead of rewriting these statements each time you want to buy.
  • Arrays - These are simply data structures that hold similar data and enable you to access and manipulate the data more efficiently.

A Look at Variables
Variables are simply objects that you define to hold data. You may recall from the previous section that we used three variables: MATrendPeriod, MaCurrent and MaPrior. MATrendPeriod held a number that defined how many days we would use in our moving average calculation; MaCurrent held a number representing the current moving average; and MaPrior held a number representing the prior moving average.

Creating a Variable
You can use almost any name you want when naming a variable. The only exception is a list of ”restricted words” that you are not allowed to use because the names are already used by other parts of the program. You can find your trading program’s list of restricted words in the program’s documentation. In general, names should describe the data being held. For example, notice that we used MaCurrent to define the current moving average.

After you have created a name, you must declare and define the variable. Declaring a variable tells the computer what type of data it is, and tells it to make space for that data. Defining the variable is where actual data is assigned, or added, to the variable. Let’s take a look at these processes:

1. Declaring a Variable

In MetaTrader, variables are declared automatically when you assign information to them. In other programs, you may have to declare a variable, which is typically done using the following format:

<data type> <variable name>;

The two types of data are numbers and text, but these are broken down into more groups like integers (whole numbers), double (large numbers), float (decimal numbers), string (text), and others depending on the program you are using. For example, the following code will declare numberOfDays as an integer:

Int numberOfDays;

2. Defining a Variable
After your variable has been declared, the computer has created space for it. Now, all you have to do is add actual data to that space. This can be done in two ways: you can either define a set amount, or you can perform a calculation to obtain a value, which you then assign to the variable.

In MetaTrader, you can add set data using the following format:

Defines: <variable name>(<set amount>);

In other programs, set data is often assigned simply using the equals sign:

<variable name> = <set amount>;

If you want to perform a calculation to obtain data to assign to the variable, then you simply assign the variable to the calculation:

<variable name> = <calculation>;

For example, to set a 20-day moving average in MetaTrader, we use the following code:

<variable name> = iMA(20,MODE_SMA,0);

Note that the iMA(20,MODE_SMA,0) portion of the code is the calculation. The format for this calculation was developed by MetaTrader and will differ if you are using another trading program. To find these calculations, you must consult your trading program’s documentation, which usually contains a list of all available calculations.

3. Using Variables

Once declared and defined, variables can be used anywhere else within the program to represent the data they contain. To do this, simple type the name of the variable in place of the data. For example, if MATrendPeriod contains the number of days we want a moving average calculated for, we can use it to replace the 20 in our example above:

<variable name> = iMA(MATrendPeriod, MODE_SMA, 0);

There are two advantages to using variables as opposed to just the data: (1) you can change the data in one place, and (2) the result of an entire calculation can be contained within one variable.

A Look at Statements
Statements are the core of any program – they contain all of the commands that manipulate data to make decisions. Here we will take a look at several of the most common types of statements and how they can be used.

1. Comments
If you have designed a complex trading system, it may take a lot of code to implement your rules; therefore, it would be prudent to insert comments in your code to help yourself understand it in the future, and to help out anyone with whom you may share your code. Almost all trading applications share a similar method for creating comments:

Single Line Comments:

//<your comment here>

Multi-Line Comments:

/* <comment line one>
<comment line two>
<comment line three> */

2. The ‘If’ Statement
This is the statement you will use most when coding a trading system. This statement lets you create scenarios as we did in the design portion of this tutorial. You may have also noticed that this was the only statement we used in the example program we created. This type of statement is implemented using the following format:

Standard If/Then:

If <condition> Then <action>;

Standard If/Else:

If <condition> Then <action> Else <action>;

So, for example:

If accountBalance < 200 then Exit;

Note that the conditional part of the ‘If’ statement is constructed using the following:

<object one> <condition> <object two>

The condition can be:

· Greater Than (>)
· Less Than (<)
· Equal To (=). Note that one ‘=’ assigns, two ‘==’ returns either true or false.

3. The While Loop
This loop is commonly used to tell the computer to continue doing something while a certain condition is true or false. So, for example, maybe you want to have the trading system keep a position open while your account is above a certain balance, but close it if it ever falls below that balance. These statements are created using the following format:

While <condition> <action>;

4. The Exit and/or End Statement
An ‘Exit’ or ‘End’ statement is used to indicate to the computer that your program will be ending at that particular point. Typically, this is done using:

Exit;
Or,
End;

These are usually placed in the ‘If’ statements if that statement is executed so that the computer doesn’t continue to look at the rest of the ‘If’ statements.

Trading System Implementation
Note that different trading applications will differ slightly in how they implement statements. For example, in some trading applications, the ‘If’ statement is constructed by using:

If (<condition>, <then do this>, <else do this>);

Meanwhile, other applications may split up this code into two parts:

If (<condition>) { <then do this> } else { <else do this> };

We can see that the same idea is present, but the implementation differs. It is important to consult your trading application’s documentation, or application programming interface (API), to determine what differences exist.

Putting It All Together
Now you should have an idea of the different components that can be used when coding your trading system. All that remains to be done is to put everything together. To do this, simply take your design document and determine the following:

  • What variables will I have to define?
    • Calculations à Moving averages, RSI, MACD, etc.
    • Set Amounts à Time periods, deposit amounts, risk percentages, etc.
  • What statements will I have to make?
    • Convert your rules to the proper statements using the above guides.

Once you know this, all you need to do is piece together all of the parts. The standard structure for a program is:

<includes>
<variables>
<statements>

Conclusion
Now you should have a basic idea of how to put your trading system into code. Be sure to consult your trading application’s documentation often, as it may contain pre-built calculations that you can use, code examples and much more that can help you to better understand the specifics. In the next part of this tutorial, we’ll take a look at testing your new program both technically (to find errors in the code) and theoretically (to find errors in your logic).

Trading Systems Coding: Testing, Troubleshooting and Optimizing

Now that you have a trading system designed and coded, it is time to test it to make sure that your coding is free of logical and technical errors. We will also look at something known as optimization – a feature in some trading programs that allows you to fine tune your trading rules to fit the stocks that you plan on trading.

Testing Your Trading System
The vast majority of trading applications that support programming languages also support testing tools. These tools are divided into two categories:

1. Technical
Technical testing tools search for technical errors in your code. For example, if you forget to add a semicolon after a statement, the technical testing tool will notify you that your statement is invalid.

The location of the technical testing tool depends on the trading application being used. MetaTrader displays an error or flawed results when you try to compile your code, while trading applications like Tradecision have a “code check” utility built into the interface that lets you check your code for errors before applying it.

2. Logical
Logical testing tools search for logical errors in your code. For example, if you happened to use a “greater than” sign instead of a “less than” sign (which is not a technical error), a logical testing tool will show you that your results don’t make sense.

The most popular logical testing tool is the backtesting tool. This tool allows you to take past data and apply your trading system to that data. This gives you an idea of the following:

  • Whether your trading system is a profitable one
  • What conditions prove to be most profitable
  • Where any errors in your rules might exist

(For more information, see Backtesting: Interpreting The Past.)

Troubleshooting Your Trading System
As with any other type of programming, troubleshooting can be a tedious and difficult task. Finding errors in your code requires systematically sorting through your code to identify syntactical errors that, although often minor, can bring your program to a halt.

Here are some common errors to look for:

  • Missing semicolons after statements – These have to be after every statement.
  • Undefined variables – Remember that you have to declare them before you use them!
  • Spelling mistakes – If any names or functions are spelled incorrectly, the trading application will return an error (see example below).
  • Incorrect usage of (=) – Remember that “=” assigns one value to another value, while “==” means “equal to”.
  • Incorrect usage of built-in functions – Consult your trading application’s documentation or application programming interface (API) to make sure that you are using the correct syntax.

Some trading applications contain a feature that will let you test your code before using or compiling it. This feature allows you to see what the error is and on which line it can be found. Take Tradecision for example:


Figure 1

Here we can see that Tradecision gives us the location (line and column) of the error, a description of the error and the type of error (in this case, it is syntactical). If we look at the expression, we can see that in column 8 “xrossBelow” is not a valid function. If we replace the “x” (which is in column 8) with a “c”, then we will have valid code.

If we look at MetaTrader, we can see that the errors come up when we try to compile the program:

Here we can see that in the description it says the “BuyNow” variable wasn’t defined. Double clicking on this error message will bring us to the specific location of the error in the code.

As you can see, most trading applications give you an easy way to locate technical errors and fix them. Fixing the errors simply involves systematically going through each error message and then recompiling the code and/or applying the trading system to your charts.

Optimizing Your Trading System
Some trading applications let you select variables to be optimized. Tradecision, for example, lets you easily select a variable and replace it with code that will attempt optimization. Optimization itself is simply a process that finds the optimal value for a particular trading system element based on past results and performance. Note that over-optimization results in trading systems that are unable to adapt to market conditions; therefore, it is important to only optimize a few important variables, not every variable!

Here is what the optimization feature looks like in Tradecision:


Figure 3

You can see that we declared two new variables and set them equal to “#”. The “#” simply means that the trading program will replace this with the optimal number. Next, you can see that we used the new variables within our trading strategy. Finally, we set a range for the numbers (so that the program will not search to infinity).

Some other trading programs have features that operate in a similar way, allowing you to replace the numerical value with a “#” and telling the trading application to optimize it.

Conclusion
By now you should have developed a working trading system in which you can have confidence. In the next part of this series, you will learn how to apply your trading system to charts and how to use it to make trading decisions!

Trading Systems Coding: Using Your System

You are now on your way to having a working, profitable trading system. All that is left to do is to apply this trading system to your actual trading. In this section, we will take a look at the ways in which this can be done.

Compiling Your Code
The final step in the actual development of your trading system is compilation – that is, converting your code into a file that the trading software can execute, or run, at any given time without re-reading the code.

The way in which code is compiled differs between trading programs. However, the majority of them simply let you click a compile button and do one of two things: either 1) the program will compile the code and create a new file, or 2) the compiler will list the errors that you have made in your code (as we saw in the previous section). Because MetaTrader has a standard setup, we will use its trading application as an example for the purposes of this tutorial.

MetaTrader’s “Compile” button can be found on the top tool bar:

Assuming the compilation goes well, you will now have an executable file that your trading program can quickly read and apply to your charts.

Applying the System to Your Charts
Most trading applications will let you easily apply your trading system within the trading application by either letting you drag the file onto the chart, or inserting it via a menu. MetaTrader allows you to drag the executable file from the “Navigator” window onto the chart to which you wish to apply your trading system.

After this, a dialog box comes up with several options:


Figure 2


Common
The first set of options is standard with many trading applications. The first option simply lets you define what types of positions you are willing to take (long, short, or both). The second option lets you enable “alerts”, which are pop-up windows that notify you when your criteria for a trade have been met.

Live Trading
There are two ways in which you can apply your trading system:

1. Semi-Automated Systems – Semi-automated systems are those that alert you to new trades that meet your criteria. Although the alerts themselves are automated, the trades are not placed automatically – hence the “semi” prefix. Although this type of system carries significantly less risk, it also requires you to be near a computer at all times. However, recent innovations have helped solve some of these inconveniences by allowing signals to be sent via email, phone (short message service) or other hi-tech media.

2. Automated Systems – Automated systems are those that place trades with your broker automatically – that is, they require no intervention on your part. This type of trading system involves significantly more risk, especially if there are logical errors that you did not catch when testing. Therefore, it is imperative that you either paper trade or semi-automate your trading system to be sure that it performs as expected in a live environment. (For further reading, see Demo Before You Dive In.) Note that these trading systems will also require you to complete additional paperwork for your broker stating that they can’t be held responsible if your trading system generates large losses.

Safety
The two options here (see Figure 2) let you determine whether or not you are willing to let the program call external dynamic link libraries (DLLs). Remember that DLLs are libraries that let you reuse code from other people’s trading systems. If your trading system makes use of these external DLLs, then you will need to enable these options. If not, then you are best off leaving these unchecked.

Inputs
Here is where you can define the inputs for the trading system if you did not specify them directly in your code:


Figure 3


Notice that this area enables you to insert custom inputs without modifying the code at all. This is useful if you plan on changing your inputs, but want to use the same basic strategy. Note that if you optimized your variables, this option would not be available.

Conclusion
Now you should be able to compile and apply your trading system! Again, be sure to paper trade – or at least semi-automate – your trading system before allowing the system to place trades automatically. Failure to do this could lead to large losses should there be a logical error in your code.

Trading Systems Coding: Conclusion

After going through this step-by-step tutorial, you should have a fully operational and fully automatic trading system.

As you continue working with your system, keep in mind the following:

  • Always backtest until your system performs well with past data, then paper trade to make sure your system performs well with current data.
  • The market has two phases – trending and ranging – and very few trading systems handle both perfectly. Be sure to only trade in a market that your system can beat.
  • Make changes one at a time so that you can pinpoint which aspects are improving your returns and which are hurting them.
  • Keep it simple. Extremely complex trading systems are often fitted to work well with past data, but are incapable of adapting to new market conditions.
  • Make sure that you know the strategy behind your trading system. As absurd as it sounds, many people develop their systems until they become so complex that they forget the underlying strategy.
  • Don’t over-optimize. Optimizing too much can lead to what is known as curve-fitting, which can reduce your trading system’s effectiveness and ability to adapt.

Resources
Here are some trading applications worth checking out:
MetaTrader – http://www.metaquotes.net/
TradeStation – http://www.tradestation.com/
Tradecision – http://www.tradecision.com/
MetaStock – http://www.metastock.com/
AmiBroker – http://www.amibroker.com/
WealthLab – http://www.wealth-lab.com/
Comprehensive List – http://elitetrader.com/so/

Here are some community resources that can assist you:
Moneytec – http://www.moneytec.com/
StrategyBuilderFX – http://www.strategybuilderfx.com/
EliteTrader – http://www.elitetrader.com/

Posted in Investment Strategy | Leave a Comment »

Leading Indicators Of Behavioral Finance

Posted by IWAN BUDHIARTA on April 15, 2008

Modern finance relies on two key assumptions: a rational homo sapien and a “fair price” being determined by financial markets. Behavioral finance does not serve as a contradiction to these tenets, but complements them by emphasizing the importance of human psychology and groupthink in financial markets. Behavioral finance points to the existence of market bubbles and manias as examples of cases where human behavior may be the missing link that explains such market anomalies. In this article we’ll consider two leading behavioral indicators. (To read more on behavioral finance, see Taking A Chance On Behavioral Finance, Understanding Investor Behavior and Mad Money … Mad Market?)

Search for Reliable Indicators
Many people assume that it should be fairly easy to outperform the market simply by replicating the strategies used by successful professionals and/or taking the opposite position held by the “losers”. Unfortunately, successful investors are very good at hiding their true strategies, which could quickly become worthless if replicated. On the other hand, the behavior of the “losers” or the “crowd” can be easily observed by taking note of certain leading behavioral indicators (the odd lot theory, for example). These indicators show that the “crowd” can be reliably wrong at important market junctures as people fall prey to the collective emotions of fear (at market bottoms) and greed (at market tops).

Let us consider two leading indicators of investor behavior and stock prices:

1. The put-call ratio
2. The number of stocks above their 50-day moving averages (A50 for short)

In contrast to many other attempts to apply behavioral finance theories, these two leading indicators have the virtue of being quantifiable; in other words, they indicate the potential tipping points in human emotions. Keep in mind, however, that the construction of quantifiable indicators is one of the biggest challenges for behavioral finance and all indicators should always be interpreted in a broader context.

Put-Call Ratio
The fact that most option market positions are held over a short period (between one and three months) indicates that, at the very least, some option buyers are investors looking for a quick return on their money or are often just speculating. The buyers of puts could be making a bet that the market will decline while the purchasers of calls are hoping for an upward move. Thus, a high put-call ratio indicates a high degree of pessimism – it suggests that more people are betting that the market will go down than that it will go up. A low ratio, on the other hand, implies a lot of optimism. (For further reading, see Forecasting Market Direction With Put/Call Ratios.)

At the extremes of the put-call ratio, the opposite of what the majority expects usually happens. As a way of explanation, a high degree of pessimism (a high put-call ratio) usually coincides with a declining market and plenty of cash available for investing, which can quickly lure bargain hunters back into the market.

Let’s consider the historical interaction between a 10-day moving average of the put-call ratio and the S&P 500 Index since 2002 (Figure 1). The ratio reached high levels (there were too many pessimists) just at the end of the bear market in the last quarter of 2002. Since then, all peaks and valleys in the ratio correctly forecasted the short-term market swings (except for June 2003 when investors’ sentiment shifted radically following the start of the bull market).

Figure 1

Stocks Above Their 50-day Moving Averages
Let us consider the change in a number of stocks in New York trading above their 50-day moving averages. The A50 is an excellent reality check that reveals whether movements in stock prices are broadly based or supported only by a limited number of stocks. The broadly based moves increase the probability that the move will continue, while narrowly based moves suggest a vulnerability to a potential reversal. This is because if the “crowd” gets increasingly excited by only a few stocks, the rally will be built on a shaky foundation. (For more on this, read The Madness Of Crowds and Trading Volume – Crowd Psychology.)

In case of the A50, it is crucial to identify divergences between the A50 and the stock prices. Since 2002, there have been several instances when the A50 diverged significantly from the S&P 500 Index (Figure 2). Twice the divergence predicted an upswing and three times it gave an advanced warning of a forthcoming correction. (For further reading, check out Divergences, Momentum And Rate Of Change.)

Figure 2

Conclusion
Behavioral finance is a relatively young field that offers considerable opportunity for informed investors. In the not-too-distant future, behavioral finance may be formally recognized as the missing link that complements modern finance and explains many market anomalies. Perhaps some market participants will even wonder how it was ever possible to discuss the value of stocks without considering the behavior of buyers and sellers.

Posted in Investment Strategy | Leave a Comment »

Train To Gain With Neural Networks

Posted by IWAN BUDHIARTA on April 15, 2008

Neural networks are state-of-the-art, trainable algorithms that emulate certain major aspects in the functioning of the human brain. This gives them a unique, self-training ability, the ability to formalize unclassified information and, most importantly, the ability to make forecasts based on the historical information they have at their disposal.

Neural networks have been used increasingly in a variety of business applications, including forecasting and marketing research solutions. In some areas, such as fraud detection or risk assessment, they are the indisputable leaders. The major fields in which neural networks have found application are financial operations, enterprise planning, trading, business analytics and product maintenance. Neural networks can be applied gainfully by all kinds of traders, so if you’re a trader and you haven’t yet been introduced to neural networks, we’ll take you through this method of technical analysis and show you how to apply it to your trading style.

Common Delusions
Most people have never heard of neural networks and, if they aren’t traders, they probably don’t need to know what they are. What’s really surprising, however, is the fact that a huge number of those who could benefit richly from neural network technology have never even heard of it, take it for a lofty scientific idea or think of it as of a slick marketing gimmick. There are also those who pin all their hopes on neural networks, lionizing the nets after some positive experience with them and regarding them as a silver-bullet solution to any kind of problem. However, like any trading strategy, neural networks are no quick-fix that will allow you to strike it rich by clicking a button or two. In fact, the correct understanding of neural networks and their purpose is vital for their successful application. As far as trading is concerned, neural networks are a new, unique method of technical analysis, intended for those who take a thinking approach to their business and are willing to contribute some time and effort to make this method work for them. Best of all, when applied correctly, neural networks can bring a profit on a regular basis.

Use Neural Networks To Uncover Opportunities
A major misconception is that many traders mistake neural networks for a forecasting tool that can offer advice on how to act in a particular market situation. Neural networks do not make any forecasts. Instead, they analyze price data and uncover opportunities. Using a neural network, you can make a trade decision based on thoroughly analyzed data, which is not necessarily the case when using traditional technical analysis methods. For a serious, thinking trader, neural networks are a next-generation tool with great potential that can detect subtle non-linear interdependencies and patterns that other methods of technical analysis are unable to uncover.

The Best Nets
Just like any kind of great product or technology, neural networks have started attracting all those who are looking for a budding market. Torrents of ads about next-generation software have flooded the market – ads celebrating the most powerful of all the neural network algorithms ever created. Even in those rare cases when advertising claims resemble the truth, keep in mind that a 10% increase in efficiency is probably the most you will ever get from a neural network. In other words, it doesn’t produce miraculous returns and regardless of how well it works in a particular situation, there will be some data sets and task classes for which the previously used algorithms remain superior. Remember this: it’s not the algorithm that does the trick. Well-prepared input information on the targeted indicator is the most important component of your success with neural networks.

Is Faster Convergence Better?
Many of those who already use neural networks mistakenly believe that the faster their net provides results, the better it is. This, however, is a delusion. A good network is not determined by the rate at which it produces results and users must learn to find the best balance between the velocity at which the network trains and the quality of the results it produces.

Correct Application of Neural Nets
Many traders apply neural nets incorrectly because they place too much trust in the software they use all without having been provided with proper instructions on how to use it properly. To use a neural network the right way and, thus, gainfully, a trader ought to pay attention to all the stages of the network preparation cycle. It is the trader and not his or her net that is responsible for inventing an idea, formalizing this idea, testing and improving it, and, finally, choosing the right moment to dispose of it when it’s no longer useful. Let us consider the stages of this crucial process in more detail:

1. Finding and Formalizing a Trading Idea
A trader should fully understand that his or her neural network is not intended for inventing winning trading ideas and concepts. It is intended for providing the most trustworthy and precise information possible on how effective your trading idea or concept is. Therefore, you should come up with an original trading idea and clearly define the purpose of this idea and what you expect to achieve by employing it. This is the most important stage in the network preparation cycle. (For related reading, see Lessons From A Trader’s Diary.)

2. Improving the Parameters of Your Model
Next, you should try to improve the overall model quality by modifying the data set used and adjusting the different the parameters.

Figure 1: Specifying the optimization algorithm and its properties

3. Disposing of the Model When it Becomes Obsolete
Every neural-network based model has a life span and cannot be used indefinitely. The longevity of a model’s life span depends on the market situation and on how long the market interdependencies reflected in it remain topical. However, sooner or later any model becomes obsolete. When this happens, you can either retrain the model using completely new data (i.e. replace all the data that has been used), add some new data to the existing data set and train the model again, or simply retire the model altogether.

Many traders make the mistake of following the simplest path – they rely heavily on and use the approach for which their software provides the most user-friendly and automated functionality. This simplest approach is forecasting a price a few bars ahead and basing your trading system on this forecast. Other traders forecast price change or percentage of the price change. This approach seldom yields better results than forecasting the price directly. Both the simplistic approaches fail to uncover and gainfully exploit most of the important longer-term interdependencies and, as a result, the model quickly becomes obsolete as the global driving forces change.

The Most Optimal Overall Approach to Using Neural Networks
A successful trader will focus and spend quite a bit of time selecting the governing input items for his or her neural network and adjusting their parameters. He or she will spend from (at least) several weeks – and sometimes up to several months – deploying the network. A successful trader will also adjust his or her net to the changing conditions throughout its life span. Because each neural network can only cover a relatively small aspect of the market, neural networks should also be used in a committee. Use as many neural networks as appropriate – the ability to employ several at once is another benefit of this strategy. In this way, each of these multiple nets can be responsible for some specific aspect of the market, giving you a major advantage across the board. However, it is recommended that you keep the number of the nets you use within the range of five to 10. Finally, neural networks should be combined with one of the classical approaches. This will allow you to better leverage the results achieved in accordance with your trading preferences.

Conclusion
You will experience real success with neural nets only when you stop looking for the best net. After all, the key to your success with neural networks lies not in the network itself, but in your trading strategy. Therefore, to find a profitable strategy that works for you, you must develop a strong idea about how to create a committee of neural networks and use them in combination with classical filters and money management rules.

For related reading, check out Neural Trading: Biological Keys To Profit and the Trading Systems Coding Tutorial.

Posted in Investment Strategy | Leave a Comment »

Trading Is Timing

Posted by IWAN BUDHIARTA on April 15, 2008

Trading always comes down to timing. To truly appreciate this, we simply need to note that one of the biggest gains in stock market history occurred on October 19, 1987, during the day of its greatest crash. On that day, stocks had declined a mind-harrowing 23% by the end of the day, but at around 1:30pm, they staged a massive rally that saw the Dow Jones and S&P indexes verticalize off the bottom, rising more than 10% before running out of steam and turning down to end the day on the lows.

While most traders that day lost money, those who bought that bottom at 1:30pm and sold their positions an hour later were rewarded with some of the best short-term gains in stock market history. Conversely, traders unfortunate enough to have shorted at 1:30pm only to cover in panic an hour later held the dubious distinction of losing money on their shorts during the day of stock market’s greatest decline.

If nothing else, the stock market crash of 1987 proved that trading is all about timing. Timing is hard to master, but you can still capture significant gains on an ill-timed trade if you follow a few simple rules.

The Advantage of Avoiding Margin
What happens to traders who are terrible timers? Can traders who are poor timers ever succeed – especially in the currency market where ultra-high leverage and stop driven price action often forces margin calls?

The answer is yes.

Some of the world’s best traders, including market wizard Jim Rogers, are still able to succeed. Rogers – and his famous short trade in gold – is well worth examining in more detail. In 1980, when gold spiked to record highs on the back of double-digit inflation and geopolitical unrest, Rogers became convinced that market for the yellow metal was becoming manic. He knew that like all parabolic markets, the rise in gold could not continue indefinitely. Unfortunately, as is so often the case with Rogers, he was early to the trade. He shorted gold at around $675 an ounce while the precious metal continued to rise all the way to $800. Most traders would not have been able to withstand such adverse price movement in their position, but Rogers – an astute student of the markets – knew that history was on his side and managed not only to hold on, but also to profit, eventually covering the short near $400 an ounce.

Aside from his keen analytics and a steely resolve, what was the key to Rogers’ success? He used no leverage in his trade. By not employing margin, Rogers never put himself at the mercy of the market and could therefore liquidate his position when he chose to do so rather than when a margin call forced him out of the trade. By not employing leverage on his position, Rogers was not only able to stay in the trade but he was also able to add to it at higher levels, creating a better overall blended price.

Slow and Low is the Way to Go
For currency traders, the Rogers trade in gold holds many lessons. Experienced traders are familiar with being stopped out or margin called from a position that was going their way. What makes trading such a difficult vocation is that timing is very hard to master. By using little or no leverage, Rogers provided himself with a much larger margin for error and, therefore, did not need to be correct to the penny in order to capture massive gains. Currency traders who are unable to accurately time the market would be well advised to follow his strategy and deleverage themselves. Just like the common cooking saying, success in FX trading is based on the idea that ’slow and low is the way to go’. Namely, traders should enter into their positions slowly, with very small chunks of capital and use only the smallest leverage to initiate a trade.

To better illustrate this point, let’s look at two traders. Both traders start with $10,000 of speculative capital and both feel that the EUR/USD is overvalued and decide to short it at 1.3000. Trader A employs 50:1 leverage, selling $500,000 worth of EUR/USD pair short against the $10,000 of equity in his speculative account. On a standard 1% margin account, Trader A allows himself only 100 points of leeway before he is margin called and forced out of the market. If EUR/USD rallies to 1.3100 Trader A is out with a massive loss. Trader B, on the other hand, uses much more conservative leverage of 5:1 only selling $50,000 EUR/USD short at the 1.3000 level. When the pair rallies to 1.3100 Trader B comes out relatively unscathed, suffering only a minor floating loss of $500. Furthermore, as the pair rallies to 1.3300 he is able to add to his short position and achieve a better blended price of 1.3100. If the pair then finally turns down and simply trades back down to his original entry level, trader B already becomes profitable. Both traders made the same trade. Both were completely wrong on timing, yet the results could not have been more different.

No Stops? Big Problem!
Jim Rogers’ slow and low approach to trading, while clearly successful, suffers from one glaring flaw: it does not use stops. While Rogers’ method of buying value and selling hysteria has worked well over the years, it can very be vulnerable to a catastrophic event that can take prices to unimagined extremes and wipe out even the most conservative trading strategy. That is why currency traders may want to examine the methods of another market wizard, Gary Bielfeldt. This plain-spoken Midwesterner made a fortune trading Treasury bonds in the 1980s when interest rates rose to record yields of 14%.

Gary Bielfeldt went long Treasury bond futures once rates hit those levels, believing that such high rates of interest were economically unsustainable and would not persist. However, much like Jimmy Rogers, Gary Bielfeldt was not a great timer. He initiated his trade with bonds trading at the 63 level but they kept falling, eventually trading all the way down to 56. However, Bielfeldt did not allow his losses to get out of control. He simply took stops every time the position moved a half or one point against him. He was stopped out several times as bonds slowly and painfully carved out a bottom. However, he never wavered in his analysis and continued to execute the same trade despite losing money repeatedly. When bonds prices finally turned, his approach paid off as his longs soared in value and he was able to collect profits far in excess of his accumulated losses. (For related reading, see The Stop-Loss Order – Make Sure You Use It.)

Gary Bielfeldt’s method of trading holds many lessons for currency traders. Much like Jim Rogers, Bielfeldt is a successful trader who had difficulty timing the market. Instead of nursing losses, however, he would methodically stop himself out. What made him unique was his unwavering confidence in his analysis, which allowed him to enter the same trade over and over again, while many lesser traders quit and walked away from the profit opportunity. Bielfeldt’s probative approach served him well by allowing him to participate in the trade while limiting his losses. This strong combination of discipline and persistence is a great example to currency traders who wish to succeed in trading but are unable to properly time their trades.

A Little Technical Help
While both Rogers and Bielfeldt used fundamental analysis as the basis behind their trades, there are also technical indicators that currency traders can use to help them trade more effectively. One such tool is the relative strength index (RSI). The RSI compares the magnitude of the currency pair’s recent gains to the magnitude of its recent losses and turns that information into a number that ranges from 0 to 100. A value of 70 or more is considered to be overbought and a value of 30 or less is seen as oversold. A trader who has a strong opinion on the direction of a particular currency pair would do well to wait until his thesis was confirmed by RSI readings. For example, in the following chart, a trader who wanted to short the EUR/USD on the premise that the pair was overvalued would have been much more accurate if he or she waited until the RSI readings dropped below 70, indicating that most of the buying momentum was gone from the pair. (For more on this, check out Getting To Know Oscillators – Part 2: RSI and Momentum And The Relative Strength Index.)

Figure 1

Conclusion
Timing is a vital ingredient to successful trading, but traders can still achieve profitability even if they are poor timers. In the currency market, the key to success lies with taking small positions using low leverage so that ill-timed trades can have plenty of room to absorb any adverse price action. However, trading without stops is never a wise strategy. That is why even poor timers should adopt a probative approach that methodically keeps trading losses to a minimum while allowing the trader to continuously re-establish the position. Finally, using even a simple technical indicator such as RSI can make fundamental strategies much more efficient by improving trade entries. Some of the greatest traders in the world have proven that one does not need to be a great timer to make money in the markets, but by using the techniques discussed above, the chances of success improve dramatically.

For related reading, see Understanding Cycles – The Key To Market Timing.

Posted in Investment Strategy | Leave a Comment »

Gauging Support And Resistance With Price By Volume

Posted by IWAN BUDHIARTA on April 15, 2008

Many say that charting is nothing more than predicting the direction of a price between significant support and resistance levels. We know that a support level is a price level which a stock has had difficulty falling below. This is where a lot of buyers tend to enter the stock. Similarly, we know that resistance is a price level above which a stock has difficulty climbing. This is where a lot of buyers take profits and shorts enter. Typically, a stock’s price will range between these levels until it breaks out or breaks down. Hundreds of different methods can be used to locate these areas of support and resistance, but one of the most underrated methods is simply using price by volume (PBV) charts. In this article, we explain what PBV charts are and explore techniques that you can use to make effective trades using these charts. (For additional reading on volume, see Volume Oscillator Confirms Price Movements, Volume Rate of Change and Gauging The Market’s Psychological State.)

Trendlines, chart patterns, pivot pointsFibonacci lines and Gann lines are among the most popular methods used to identify areas of support and resistance. But the less commonly used PBV charts, which illustrate volume using a vertical volume histogram, can be invaluable when determining not only the location of key support and resistance levels, but also the strength of these levels. (For further reading, see Support And Resistance Zones – Part 1 and Part 2.)

What Are PBV Charts?
A price by volume chart is simply the standard volume histogram reapplied to price instead of time (price is seen on the Y axis and time on the X axis). So, instead of being able to determine when a stock is going in and out of favor (indicated by increasing volume levels over time), PBV enables you to determine the level of buying or selling interest at a given price level. PBV charts can be created in many different charting applications, as well as by using free online charting services from websites like BigCharts.com and StockCharts.com.

Using PBV Charts
PBV charts are relatively easy to use and understand. There are three major elements involved:

  • Volume strength indicates the amount of shares that traded at the given price level. This is indicated by the horizontal length of the PBV histogram.
  • Volume type refers to the number of shares sold compared to the number of shares bought. This is indicated by the two different colors seen on each bar.
  • Successful reactions or tests means the number of times a stock successfully tests and “bounces off” a given level.

Together, these three factors will allow you to determine the strength of a particular price level. Once you have a good idea of price strength, you can combine this information with trendlines and other studies to determine support and resistance levels, find support bases and even play gaps.

Finding Support Bases
Support bases are simply instances in which a stock ranges before continuing a trend, or reversing. To determine when a stock is basing, simply follow these steps:

  1. Draw two parallel, horizontal lines that connect parallel highs and lows in a trading range after a trending move.
  2. Then, use the PBV histogram to see if these parallel lines are located near key price levels.
  3. Finally, note the buying or selling pressure (colors) as well as the total volume to determine in which direction a breakout is likely to occur.

Figure 1 shows Hudson City Bancorp (HCBK) along with the price by volume histogram. Looking at this chart, we can see that the longer blue bars indicate buying pressure or support, while a longer red bar indicates selling pressure or resistance. Meanwhile, the larger overall bar indicates that that particular price level is of interest to traders. In this case, we note that $12.50 appears to be a level at which we can watch for a breakout to the upside.


Source: StockCharts.com
Figure 1

Locating Support and Resistance Levels
Support and resistance levels are simply areas beyond which the price has difficulty moving due to large buying or selling interests. To determine areas of support or resistance, simply do the following:

  1. Identify areas where the PBV histogram shows significant buying or selling interest.
  2. Determine whether these large interests are buying or selling interests.
  3. Draw horizontal trendlines parallel to these PBV bars, giving preference to those that also connect highs and lows on the chart.

Let’s take a look at Google (GOOG) for an example:


Source: StockCharts.com
Figure 2

Trending between these support and resistance levels should be immediately apparent. These areas are known as “soft areas”, where only short volume bars exist between two long bars. One common strategy is to buy and sell based on the trends between these “soft areas”. In the chart for Google (Figure 2), for example, we’d look to short GOOG when it breaks Support 1 and cover when it hits Support 2.

Playing Gaps
Gaps occur when an asset’s price rapidly moves from one point to another, creating a visible gap or break between prices in the chart. You can use PBV charts to help predict when a gapping stock will find support simply by looking for an area where there was a lot of prior interest. Also, gaps themselves can produce areas of future support and/or resistance, which can be reinforced by the PBV histogram. Let’s take a look at a few examples:


Source: StockCharts.com
Figure 3

In the case of DHB Industries (Figure 3), a PBV trader would look to buy a breakout from Resistance 2 and sell when Resistance 1 is reached. Notice that the gap down creates an area of very little resistance to upward movement – this tells us that it is likely that the second target will be reached.


Source: StockCharts.com
Figure 4


In the case of Elan Corp. (Figure 4), we can see that a trader who bought on a break above $7.60 (the long PBV bar) would have already realized a gain of nearly 100%. Notice that once the key resistance was broken, there was very little resistance to the upside.

Clearly, PBV can be extremely useful when combined with gaps if you are attempting to buy rebounds or retracements after gaps occur. (To learn more, see Playing The Gap and Retracement Or Reversal: Know The Difference.)

Conclusion
PBV charts can be an invaluable tool in your stock analysis arsenal. When you combine it with other methods such as trendline analysis and Fibonacci, it is easy to see how much additional insight can be gained from this charting method. Here are some key points to remember:

  • The first color represents volume on days when the price moved higher.
  • The second color represents volume on days when the price moved lower.
  • When one color of the bar is significantly longer than the other, strong support or resistance is present.
  • Horizontal trendlines connect the top of the PBV bar for resistance and the bottom of the PBV bar for support.
  • PBV bars are used for support and resistance levels, trading bases and gap areas.

Note: This article was written with the help of Cal Stanke, co-founder of ChartSetups.com, where he uses PBV analysis extensively in his own research.

Posted in Investment Strategy | Leave a Comment »

The Daily Routine Of A Swing Trader

Posted by IWAN BUDHIARTA on April 15, 2008

Swing trading combines fundamental and technical analysis in order to catch momentous price movements while avoiding idle times. The benefits of this type of trading are a more efficient use of capital and higher returns, and the drawbacks are higher commissions and more volatility. Swing trading can be difficult for the average retail trader. The professional traders have more experience, more leverage, more information and lower commissions; however, they are limited by the instruments they are allowed to trade, the risk they are capable of taking on and their large amount of capital. (Large institutions trade in sizes too big to move in and out of stocks quickly.) Knowledgeable retail traders can take advantage of these things in order to profit consistently in the marketplace. In this article, we lay out what a good daily trading routine and strategy looks like, and show you how you can be similarly successful in your trading activities.

Pre-Market
The retail swing trader will often begin his or her day at 6am (EST), well before the opening bell. The time before open is crucial for getting an overall feel for the day’s market, finding potential trades, creating a daily watch list and, finally, checking up on existing positions.

Market Overview
The first task of the day is to catch up on the latest news and developments in the markets. The quickest way to do this is via the cable television channel CNBC or reputable websites such as Market Watch. The trader needs to keep an eye on three things in particular:

  1. Overall market sentiment (bullish/bearish, key economic reports, inflation, currency, overseas trading sessions, etc.)
  2. Sector sentiment (hot sectors, growing sectors, etc.)
  3. Current holdings (news, earnings, SEC filings, etc.)

Find Potential Trades
Next, the trader will scan for potential trades for the day. Typically, swing traders will enter a position with a fundamental catalyst and manage/exit the position with the aid of technical analysis. There are two good ways to find fundamental catalysts:

  1. Special opportunities: These are best found via SEC filings and, in some cases, headline news. Such opportunities may include initial public offerings (IPOs), bankruptcies, insider buying, buyouts, takeovers, mergers, restructurings, acquisitions and other similar events. Typically, these are found by monitoring certain SEC filings, such as S-4 and 13D. This can be easily done with the help of sites such as SECFilings.com, which will send notifications as soon as such a filing is made. (For further reading, see Policing The Securities Market: An Overview Of The SEC.)

    These types of opportunities often carry a large amount of risk, but they deliver many rewards to those who carefully research each opportunity. These types of plays involve the swing trader buying when most are selling and selling when everyone else is buying, in an attempt to “fade” over-reactions to news and events.

  2. Sector plays: These are best found by analyzing the news or consulting reputable financial information websites to find out which sectors are performing well. For example, you can tell that the energy sector is hot simply by checking a popular energy exchange-traded fund (like IYE) or scanning the news for mentions of the energy sector. Traders looking for higher risk and higher returns may choose to seek out more obscure sectors, such as coal or titanium. These are often much harder to analyze, but they can yield much greater returns. These types of plays involve the swing trader buying into trends at opportune times and riding the trends until there are signs of reversal or retracement. (To learn more, see Retracement Or Reversal: Know The Difference.)

Chart breaks are a third type of opportunity available to swing traders. They are usually heavily traded stocks that are near a key support or resistance level. Swing traders will look for several different types of patterns designed to predict breakouts or breakdowns, such as triangles, channels, Wolfe Waves, Fibonacci levels, Gann levels and others. Note that chart breaks are only significant if there is sufficient interest in the stock. These types of plays involve the swing trader buying after a breakout and selling again shortly thereafter at the next resistance level. (To learn more about these specific patterns, see the Active Trading article archive.)

Make a Watch List
The next step is to create a watch list of stocks for the day. These are simply stocks that have a fundamental catalyst and a shot at being a good trade. Some swing traders like to keep a dry-erase board next to their trading stations with a categorized list of opportunities, entry prices, target prices and stop-loss prices.

Check Existing Positions
Finally, in the pre-market hours, the trader must check up on his or her existing positions. First, check the news to make sure that nothing material has happened to the stock overnight. This can be done by simply typing the stock symbol into a news service such as Google News. Next, check to see whether any filings have been made by searching the SEC’s EDGAR database. If there is material information, you have to analyze it and determine whether it affects your current trading plan. You may also have to adjust your stop-loss and take-profit points as a result.

Market Hours
The market hours are a time for watching and trading. Many swing traders look at level II quotes, which will show who is buying and selling and what amounts they are trading. Those coming from the world of day trading will also often check which market maker is making the trades (this can cue traders in to who is behind the market maker’s trades), and also be aware of head-fake bids and asks placed just to confuse retail traders. (For more information, see Introduction To Level II Quotes.)

As soon as a viable trade has been found and entered, traders begin to look for an exit. This is typically done using technical analysis. Many swing traders like to use Fibonacci extensions, simple resistance levels or price by volume. (For further reading, see Advanced Fibonacci Applications and Gauging Support And Resistance With Price By Volume.) Ideally, this is done before the trade has even been placed, but a lot will often depend on the day’s trading. Moreover, adjustments may need to be made later, depending on future trading. As a general rule, however, you should never adjust a position to take on more risk (e.g. move a stop-loss down): only adjust profit-taking levels if trading continues to look bullish, or adjust stop-loss levels upward to lock in profits.

You will often find that entering trades is more of an art than a science, and it tends to depend on the day’s trading activity. Trade management and exiting, on the other hand, should always be an exact science.

After-Hours Market
After-hours trading is rarely used as a time to place trades because the market is illiquid and the spread is often too much to justify. The most important component of after-hours trading is performance evaluation. It is important to carefully record all trades and ideas for both tax purposes and performance evaluation. Performance evaluation involves looking over all of your trading activity and identifying things that need improvement. Finally, you should review your open positions one last time, paying particular attention to after-hours earnings announcements, or other material events that may impact your holdings.

Conclusion
Looking at the daily routine of the typical swing trader, it is evident that the pre-market routine is paramount to successful trading. This is the time when trading opportunities are located and the day is planned. Market hours are simply a time of entering and exiting positions, not devising any new plans. And finally, after hours is just a time to review the trades for the day and assess performance. Adopting a daily trading routine such as this one can help you improve your trading and ultimately beat market returns. It just takes some good resources and proper planning and preparation.

Posted in Investment Strategy | Leave a Comment »

Candlesticks And Oscillators For Successful Swing Trades

Posted by IWAN BUDHIARTA on April 15, 2008

Swing traders specialize in using technical analysis to take advantage of short-term price moves. Successfully trading these swings requires the ability to accurately determine both trend direction and trend strength. This can be done through the use of chart patterns, oscillators, fractals, volume analysis and a variety of other methods. This article will focus on using oscillators and candlestick patterns as a quick and easy way to characterize a trend and successfully identify swing trades. (For more insight, see Introduction To Swing ChartingIntroduction To Types Of Trading: Swing Traders and The Daily Routine Of A Swing Trader.)

Finding Potential
The first step is to find the right conditions for a reversal, which can be done with either candlesticks or oscillators. Candlestick reversal indicators are characterized by indecision candles, while oscillator reversal indicators are characterized by divergence and convergence. Let’s take a more in-depth look into these methods:

Indecision Candles
Candlestick charts are designed to enable traders to quickly and accurately interpret a stock’s price movements. As we know, the body of the candle indicates the open and close, while the tails on either end represent the day’s price movements. We also know that we can characterize indecision as “volatility without movement” - or long tails with a short body. Typically, indecision candles are seen as a time when the trend is about to change. (For related reading, check out The Art Of Candlestick Charting – Part 1, Part 2Part 3 and Part 4.)

Convergence and Divergence
Convergence and divergence are simply times when a stock’s price movement differs from momentum indicators. Think of it in physics terms - if you throw a ball up in the air, it loses momentum before it reverses direction. The same is true for stock prices: momentum slows before stock prices reverse. Convergence and divergence can show you when the momentum is slowing and a potential reversal is forthcoming. (To read more on this, see Introduction To Types Of Traders: Momentum Traders and Momentum Trading With Discipline.)

Pinpointing a Reversal
The next step is to define an exact (or as close a possible) point of reversal. This task is best accomplished using specific candlestick patterns. Although there are well over 60 different candlestick patterns, there are only a select few that give consistent points of reversal.

Bullish/Bearish Engulfings
Bullish and bearish engulfings are some of the most popular candlestick patterns - and for a good reason! When properly identified, these candlestick patterns are among the most reliable. The key is in the length of the candlesticks. Ideally, the first candle should be short on low volume and the second one should be long on high volume. This indicates indecision in the last portion of a trend and then a decisive reversal in a different direction.

Figure 1: Bearish engulfing

Harami Cross
The Harami cross pattern is another very common candlestick reversal pattern. The key to successfully reading this pattern is watching the volume. Here we are looking for strong volume on the trend leading up to the cross, and then low volume and very short tails on the Harami cross candle. This indicates a strong and sudden lack of confidence by traders in the prevailing trend, which is often followed by a reversal.

Figure 2: Bearish harami cross

Some Examples
Let’s look at an example of each of these types to see how they can be applied to actual trading situations.

Figure 3
Source: StockCharts.com

Here is a chart of Google (GOOG), in which we can see examples of indecision as well as a bearish engulfing. Notice that the indecision candles predicted a large reversal, while the bearish engulfing pinpointed an exact top. Although they may not always be this accurate, they do generally give a good indication of a pending reversal.

Figure 4
Source: StockCharts.com

Notice here that the relative strength index and MACD are both declining while the stock price remains range-bound between $40 and $43. Soon after, Yahoo’s stock price dropped from the mid-$40s to under $36. This reversal could be further confirmed by looking for reversal candlestick patterns during the time in which the stock was range-bound.

Conclusion
In general, candlesticks and oscillators provide traders with a quick and easy way to identify swing trades. Other methodologies like chart patterns, volume analysis and fractals can help build on the techniques seen here to increase accuracy and profits. To read more on these subjects, see Volume Oscillator Confirms Price MovementsInterpreting Volume for the Futures Market and Make The Fractal Your Friend.

Posted in Investment Strategy | Leave a Comment »