PowerBuilder Tips, Tricks, and Techniques

Berndt Hamboeck

Subscribe to Berndt Hamboeck: eMailAlertsEmail Alerts
Get Berndt Hamboeck: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

PowerBuilder: Article

Bullish or Bearish - Buy or Sell

How PowerBuilder can help you make money

You may already have invested some of your money in stocks or individual securities. You may have earned some money, or, as 90% of investors do, you may have lost some of your money.

That's how it works in stock markets: some buy stocks and some sell stocks, some make money and some lose money. Although this may sound like gambling or a risky game of roulette, there are steps we can take to enhance our chances. It is the practice of technical analysis that might give us the needed advantage to be on the winners' side, to be among the few who make money instead of losing it. The term "technical analysis" is a complex-sounding name for a basic approach to investment. Simply put, technical analysis is the study of prices using charts of one or more stocks as the primary tools. But be careful, investing would be too easy if we knew what the stock market would do tomorrow. However, if you continue reading this article with the hope that technical analysis using PowerBuilder will improve your investing, I am quite sure that you will be satisfied.

Quotes - What We Need

Technical analysis is almost entirely based on volumes and prices from the past. The different quotes that define a security's price and volume are explained below.
  • Open price: This is the price of the first trade for the period (usually the first trade of a given day). This value is important, as it shows the consensus reached overnight by all parties trading the security.
  • High price: This is the highest price of trading for the security during a day or period. The high price is reached when there are more sellers than buyers because, without additional buyers, the security cannot climb higher. (There are always sellers willing to sell at higher prices, but the High represents the highest price buyers were willing to pay.)
  • Low price: This is the lowest price that the security traded at during a day or period. The low is reached when there are more buyers than sellers; it is the lowest price that the sellers were willing to accept, so the security will not fall any farther.
  • Close price: This is the last price that the security traded at during a day or period. This is the price most frequently used for technical analysis. The relationship between the Open (the first price) and the Close (the last price) is considered significant by most technical investors.
  • Volume: This is the number of shares or contracts that were traded during a day or period. The relationship between price and volume (increasing prices often accompany increasing volume) is important and should not be disregarded when it comes to technical analyses. The analysis of the relationship often provides a pattern or indicator on which to draw conclusions.
If you have access to real-time quotes, you will also be able to get your hands on two additional values of interest:
  • Bid: This is the price that a market maker is willing to pay for a security (the price you will receive if you sell).
  • 1Ask: This is the price that a market maker is willing to accept (the price you will pay to buy the security).
These simple fields are used to create hundreds of different technical indicators used to study price relationships, trends, patterns, and so on. But where will we get this data from, so that we get the needed advantage over the other players out there?

Getting the Data
This is quite simple, since Yahoo offers the service. Visit http://finance.yahoo.com/l, enter the ticker symbol of the security, and select the dates of the period in which you are interested. In my case, the security is Adidas (ticker symbol ADSG.DE). If you don't have the ticker symbol of the security you are looking into, you can search for it on the site.

As you can see in the following script, we use the inet object to get the data as a CSV file, which can easily be imported into a DW (see Figure 1). Just take care that in Europe you use commas as the decimal separators so that your data is not imported incorrectly into the external DataWindow (for example, the value 9301,00 should be 93,01).

To get the security values, enter the following:

Date ldt_today
Integer li_day, li_month, li_year
inet linet
n_result ln_reult

linet = CREATE inet
ln_result = CREATE n_result

li_day = Day(today())
li_month = Month(today())
li_year = Year(today()) - 2000

linet.GetURL("" + as_ticker + &
"&d="+ String(li_month)+"&e="+
String(li_day)+"&f=" +
String(li_year)+ &

ln_result.is_data =
Len(ln_result.is_data) - Pos(ln_result.is_data, "~n"))
ln_result.is_data =
Pos(ln_result.is_data, "

return 1

Charts - Drawing the Quotes

Now we have the quotes, but what should we do with them? Well, the chart is the foundation of technical analysis. But which type? There are several possible ways to chart the data.

Line Charts with Volume
A line chart is the simplest type of chart. As shown in the chart of Adidas data in Figure 2, the single black line represents the security's closing price on each day. Prices are usually displayed on the side(s) and the volume is usually displayed as a bar graph at the bottom.

A line chart's strength comes from its simplicity. It provides an uncluttered, easy-to-understand view of a security's price. Line charts are typically produced using a security's closing prices.

Bar Charts
A bar chart displays a security's open (if available), high, low, and closing prices. Bar charts are the most popular type of charts. As illustrated in the bar chart in Figure 3, the top of each vertical bar represents the highest price that the security traded during the period, and the bottom of the bar represents the lowest price that it traded. A closing "tick" is displayed on the right side of the bar to designate the last price that the security traded. Opening prices are signified by a tick on the left side of the bar.

Candlestick charting is a method developed by the Japanese in the 1600s to help analyze the price of rice contracts. The graph is made up of either black or white candle bodies, often with lines on both ends. A single white candlestick body indicates that the opening price was at the bottom of the body of the candlestick. The closing price for the period displayed is the top of the candlestick body. If the candle has lines on either end, the line on the bottom of the body represents the low prices traded during that day or period and the line on top indicates the high of the period. When a candle's body is black, the opening price is the top of the candle body and the closing price is the bottom of the candle body and again, if there are lines, they represent highs and lows during the day or period (see Figure 4).

The interpretation of candlestick charts is based primarily on patterns where, for example, one or more of a special type of candle is followed by another. See Figure 5 for a complete example of a candlestick chart.


An indicator is a mathematical calculation that can be applied to a security's price and/or volume fields. The result is a value that is used to anticipate future changes in prices. A moving average fits this definition of an indicator: it is a calculation that can be performed on a security's price over time to yield a value that can be used to anticipate future changes in prices.

There are many different indicators out there; we are briefly going to review two indicators here, the Relative Strength Index (RSI) and Bollinger Bands.

More Stories By Berndt Hamboeck

Berndt Hamboeck is a senior consultant for BHITCON (www.bhitcon.net). He's a CSI, SCAPC8, EASAC, SCJP2, and started his Sybase development using PB5. You can reach him under [email protected]

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.