“Initial Balance” Rotation Strategy: Part 2 – Indicator

Posted in RTL by astoeckley on January 3, 2011

(This is a continuation in our blog series on creating a trading system from start to finish. Want to see more? Click here for our main RTL support page, which links to the articles in this series and many more tutorials. Questions? Click here for the RTL Community Forum where you can get help on your programming.)

Summary

Last week, we took a look at the Initial Balance concept and how you can predict a day’s rotational extremes using Double IB extensions. We outlined our goals for a trading system based on this strategy.

Today, we will build a custom RTL indicator that mirrors the Market Profile 200% Initial Balance level on a regular candlestick or bar chart. It is important to note that the creation of a custom indicator is not the same thing as creating an actual trading signal that notifies you of trade entries; in fact, for a backtest, this custom indicator is not necessary at all. However, building the indicator offers two important advantages:

  1. It lets us test our algorithm’s math so we can verify that the calculations for Initial Balance price levels are accurate and properly reflect the same levels on a Market Profile chart. The same math will be used in the RTL signals, later.
  2. After we create the RTL signal, having both this indicator and the signal on the same chart makes it easy to verify that the signal is in fact signaling at the right moments, as we’d expect. Without the indicator, we’d have to constantly refer to a separate Market Profile chart to check if the signal works properly.

Build the Indicator

To get started, create an intraday Session 2 chart using a simple minute-based periodicity, such as a 5-minute. We use Session 2 because our Initial Balance levels are based on the first hour of RTH trading, which is 8:30 am to 9:30 am Central Time. The overnight price action is not a part of this strategy.

Next, use the File menu > New > Custom Indicator, or use the RTL button on your toolbar to pull up the RTL window.

First, we will build the indicator that shows the 200% IB Hi level. Separately, we will then build a second indicator to show the 200% IB Low level, for a total of 2 custom indicators.

In the RTL code, we use a “token” which automatically pulls in a value based on the outcome of a standard technical indicator. Each RTL token typically offers many different customizations, so the goal is to determine the right token(s) and then setup the tokens appropriately.

Before we can choose a token, we need to clarify the math used to create the 200% IB levels:

As you can see, the actual 200% IB levels depend on only one thing: knowing the high and low of the first hour of trading. The rest is simple math once we know this information.

The token which provides us with the high and low of the first trading hour is: SESST (“Session Statistics”). The SESST indicator is one of the most useful tokens in MarketDelta as it lets you quickly parse through a day of price data for just the information you need. It can do many different things, so the token must be configured for the 1st Hour Hi and Low at some point during the process. Because the same token cannot simultaneously show both the 1st hour Hi and the 1st hour Low, we will actually use two different instances of SESST in each of our indicators.

There are two different ways to configure tokens in the RTL code:

  1. Write the code from scratch, and include the name of the token in your code. When you Save the custom RTL work, MarketDelta automatically prompts you for the parameters for the token(s) you selected. SESST, for example, can be set to show many different things.
  2. Instead, add the tokens to the RTL window first and set them up as you wish. Then, write your RTL code. When you press Save, the custom indicator simply saves. You are not prompted to configure your tokens since you already did this prior to writing the code.

Either method is fine. Here we will show method 1, as it is faster once you get familiar with RTL coding. If you want a tutorial for method 2, click here for another blog post on creating custom indicators.

In the RTL window, we simply write the code for the 200% IB Hi, based on the math illustrated above. We use parenthesis to organize the math, and we substitute the token SESST whenever we wish to include the first hour High or first hour Low. Since the Hi and the Low are each their own SESST variable, we differentiate between the tokens of the same type by adding an underscore and a name to each token.

Type the RTL code into the RTL window for the 200% IB Hi:

As you can see, this math simply means:

First Hour Hi + IB Range

But it is expressed using the RTL token SESST.

Press Save and you will get pop-up windows to configure the two SESST tokens used:

Change the noted parameters so SESST_HI properly pulls in the highest price of the first hour.

After you press OK you are prompted to do the same for the next token, SESST_LOW, which is set to Lowest Price of the Low price of the First 60 minutes.

Finally, after the tokens are configured, you are prompted to give a name to your new custom indicator.

While not always necessary, it is a good idea to get into the habit of using the Check button in the RTL window after you are done and before you actually use the new RTL indicator.

When you use parenthesis or involve complicated math in your RTL code, you should make sure the software is interpreting your math exactly as you’d expect. The Check button breaks down the algorithm into its parts so you can verify it is processing in the right order. After you press Check, a window appears:

Here, we see that the expression’s parenthesis is calculated first, and stored internally as a variable, T1. Then the program adds T1 to the SESST_HI token. This is exactly as we’d expect. Sometimes seemingly simple mathematics will not work as expected because of the ordering of your expression, thus you should always use Check, and parenthesis, to control how math is processed.

Our 200% IB High indicator is now complete. Press “Send To” to add it to your chart that is currently active. Alternately, you can always add a custom indicator to any chart through the standard technical indicator window:

Or:

Either way, the indicator will then appear on the chart as a new separate pane:

All technical indicators appear by default as their own individual pane when you add them to a chart. To overlay them on top of another pane, in this case the price pane, simply click and drag the indicator’s line up to the price pane.

As an alternative, you can select the price pane at the time you initially add an indicator so ends up where you want it right away. You cannot use this method after the indicator is already on the chart. In the Add Indicator window:

Either way, after you add/move the indicator to the price pane, it appears:

If you so desire, you can customize its color and visual style by double-clicking the indicator line and select appropriate options in the Update Indicator window:

The 200% IB Hi custom indicator is now complete. Look at a Market Profile chart to make sure the indicator lines up with the same price points created by the IB Price Levels.

You would repeat this process to create the 200% IB Low.

The math:

This is simply the equivalent of:

First Hour Low – IB Range

Configure the tokens in the same way as for the prior custom indicator.

After you complete this second indicator and add it to the chart, you will see your completed 200% IB price levels:

Always check the results visually to make sure the indicator lines up with what you expect. In this case, we compare the lines drawn on the chart with a Market Profile chart to ensure they are mirroring those levels accurately.

Once we are confident that the indicator is correct, we no longer need to refer to Market Profile charts throughout the rest of this process as we build signals and backtest the strategy.

In our next tutorial, we build our first trading signal based on this strategy.

0 Responses to “Initial Balance” Rotation Strategy: Part 2 – Indicator

No comments.


Add a Comment