Bars, Prices, Candles

A bar the basic time period for trade strategies. In the chart below, of the EUR/USD price in summer 2009, every bar is represented by a red or green candle. The horizontal width of the candle is the bar period (in the chart below, one day), and its vertical height is the price movement of the asset during that period. On green candles the price went up during the bar period; on red candles it went down. In Zorro charts, up or down bars are normally represented with white and black candles. The thin lines above and below the candles - the 'wicks' - represent the highest and the lowest price during the bar period.

For example, when you look at the candle of June 1 (at the vertical line below marked Jun), you see that the day started at a price of 1.4125. During the day the price went as high as 1.4225, and as low as 1.4110. The day ended with the price at 1.4135.

In past times, a bar was really equal to a day. The closing price was the price of the asset at 4 PM when the market closed, and the opening price was the first price next morning at 9:30 after the traders had contemplated their strategies all night. In modern times, assets are often traded online 24 hours a day, so there is no real opening and closing. Due to the trading around the clock, you can see that in the above chart the closing price of one bar is usually almost identical with the opening price of the next bar. This can be different when an asset is mainly traded at a certain stock exchange and has little or no trading volume outside its business hours. In that case, daily candles can have a gap between the close of a bar and the open of the next bar.

If an asset is trade around the clock, the form of its candles - the relation of their open, high, low, and close prices - mainly depends on the time zone in which the chart is taken. The EUR/USD chart above is based on Greenwich Mean Time (UTC); the same chart in New York time would have the same price curve, but with very different candles. By the convention used by Zorro, all times are UTC and the time stamp associated to a bar is its close time. Thus, a 12:00 bar is the bar that ends at 12:00 UTC.

Bar periods and time frames

Zorro's trading is based on ticks, bar periods, and time frames. In live trading, a tick is the arrival of a new price quote, which can happen many times per second. In the backtest, a tick is the smallest time unit of the historical price data, often 1 minute. The strategy script is run at the end of every bar period; it can also have a tick function that runs at every tick. A time frame can cover many bars, and is normally used as a time basis for technical indicators and price series. Since Zorro allows bar periods down to a millisecond (for HFT simulation), bars can be much shorter than the distance between ticks. In such a case, any bar is extended by the multiple of the bar period until it contains at least one tick. That means the bar duration can be different from bar to bar, but it is always a multiple of the bar period. Likewise, the number of ticks per bar can be (and usually is) different from bar to bar.

Charting software usually displays price curves with candles, but indicators with smooth lines. This illustration is not really correct: since indicators are normally based on the price curve, they are no straight lines, but have discrete 'steps' that normally follow the close prices or the mean prices of the candles. You can see those steps more significantly when you extend the bar period of an indicator by using a higher time frame. Those steps in the chart are no error, but in fact the real representation of the indicator.

Special bars

Some traders believe that bars covering not a fixed time period, but a fixed price movement, give them a better insight into the market. With a focus on price movement, long periods of consolidation are condensed into just a few bars, thus highlighting "real" price trends. There are many special bar types: Tick Bars, Renko Bars, Range Bars, Momentum Bars, Point-and-Figure Bars, or Haiken Ashi Bars. Some market inefficiencies may be more clearly visible when getting rid of speed and time information. Zorro allows any imaginable combination of price and time for constructing user-defined bars with the bar function.

Prices and how to get them

Strategy development involves testing the strategy with historical price data. The prices are read from files in Zorro's History folder. For keeping the files at a reasonable size, they normally do not contain all the price quotes, but only one-minute candles (M1 data) or daily candles (D1 data). Files containing no cancles, but direct price quotes (T1 data), can also be used for special purposes, like testing scalping or HFT strategies.

Historical M1 data for main currencies, indices, and commodities is available on the Zorro Download Page. Data that is not found there can be downloaded (usually free) from brokers or from Internet data providers (Google™, Quandl™, etc.). Data in high resolution or with special content - for instance, option chains - is normally not free. It can be purchased from data vendors. There are vendors that specialize on certain data types or exchanges - for instance, iVolatility™ on options and futures, Nanotick™ on Chicago traded assets, or Nanex™ on New York traded assets. You'll get your data in a special format, usually CSV, that you can convert to Zorro's historical data formats using the dataParse function with a special format string. Examples for conversion scripts can be found in the Strategy folder.

Glossary of terms

Bars, candles, ticks, or quotes are often confused, and the meanings of those terms can also vary from platform to platform. Throughout this manual the following terms are used:

Asset - the traded product. Multiple synonyms are used in the trading literature, such as Instrument, Ticker, Issue, Market, or Security.

Quote - online offer by a market participant to sell or buy an asset at a certain price. The most recent price quote is the current bid or ask price of an asset. Other methods to define the current price, for instance the best recent quote or the last traded price, are rarely used.

Tick - a price with a time stamp. In live trading, a tick is generated by an incoming new price quote. In historical data files, a tick is a price sample with its associated time. If a tick is sampled together from several quotes, as normally in data files, its time stamp corresponds to its most recent quote.

Candle - price info covering a time interval with an open, close, high, and low price. T1 data contains only a single price quote per tick, so its open, close, high and low is the same price. Price ticks in historical files are usually candles with the first, last, highest, and lowest price of all quotes they are sampled from.

Bar - basic time interval; determines the width of a chart candle, the time resolution of the price curve, and the execution interval of a trading strategy. The time scale on a chart is divided into bars that cover at least one tick, but normally many ticks. The bar time interval can vary when special bar types, such as price-movement bars, are used. Time periods without ticks - such as weekends - are usually skipped on the chart time scale.

Time frame - basic time unit of algorithms and indicators in a trading strategy. It is often identical to a bar, but can also cover multiple bars in multi-timeframe strategies. A time frame can be synchronized to a full hour, day, or week. In that case the number of bars of a time frame can vary,

Read on:

Strategies, BarPeriod, NumBars, Historical data

► atest version online