Oct
19

Formula 201 – #1 Our First Indicator

I am going to talk about how we write indicators in NeoTicker using the formula language.

Indicator writing is an involving process and its complexity is higher than the more straight-forward quote formulas that I have written about in the Formula 101 series. If you have not spent some time learning the quote formulas, you may want to do so now as I will walk-thru the basics I have covered in Formula 101 at a faster pace.

For this tutorial, I will focus on necessary steps to indicator writing.

Remember that indicator writing is a more complex concept and tutorials in this series will be more involving than Formula 101. So be prepared to spend more time to learn the concepts and techniques.

4 Steps of Indicator Writing

To write your own indicator, there are 4 steps to follow,

1. Create the script file

2. Fill in the indicator specification

3. Write the code

4. Install the indicator

I will walk you through the steps one by one.

Step 1 – Create the Script File

To create a new script, choose from the main NeoTicker program window,

Program menu>Script Editor>New

This will create a blank script window.

Script Editor Blank

If your script editor window does not look like that, do not panic. You could have the split screen option enabled. If that is the case, choose from the menu,

Visual>Visual 2

To toggle the visibility of the split screen. Split screen is useful for complex script editing and writing. For our purpose, you may want to turn that off so that you can focus easier.

Step 2 – Fill in the Indicator Specification

To define your indicator, you need the Indicator Specification window.

In the script editor, choose

Indicator menu>Setup

That will bring up the Indicator Specification window.

Indicator definition

The indicator I am going to define is called My Special Price. Within the Indicator Specification window, you must give your indicator both a function name and a description. Both names must be unique among the indicators you have installed into your NeoTicker. Specifically, the function name cannot contain space or other blank characters. For the description, it can contain space and other special characters.

The reason why the function name cannot contain blank spaces is obvious – this name could be used in quote formulas or within another indicator once it is installed. Thus a properly formatted name is necessary for the recognition of this indicator.

Since we are defining a formula indicator, the item Language choice should be set to Formula from the drop down menu.

The item Links sets the number of items that directly link to the indicator. These linked items are called Linked Series. For the first item of the linked series, it is called the Primary Series. For the indicator we are creating, we just need one single linked series.

The item Plots sets the number of plots that the indicator will have. For most simple indicators, they have only one plot series. For other indicators, like Bollinger Band 5 Lines, it has 5 plot series. Our indicator is going to produce only one plot series, so set the value to 1.

For the rest of the options, just follow the screenshot. We will discuss the more advanced options in separate tutorials.

When you are done filling in the specification, press apply.

Step 3 – Write the Code

After you press apply in the Indicator Specification window, the script editor will show a simple formula.

Script Editor

This is a valid formula. It is also a very basic formula. Whenever you create a new formula indicator, this line will be added automatically for you as a starting point.

This one line of code is called an assignment statement. The expression to the right of the assignment operator := is stored into the item at the left hand side.

The left hand side plot1 is a predefined series variable that has its own special meaning. When you assign c, which is the closing value of the primary linked series, to plot1, NeoTicker knows that you want the indicator to show that value in its first plot series.

If our indicator has 2 plots, then the following line will assign the current high value into plot2.

plot2 := high

For now, the short form tokens c and high may not make any sense at all. Do not worry about that, we will further discuss their usage in the future. You just need to know that they return the value of close and high of the primary linked series will do.

Since we are going to create an indicator with our special price, I will modify the formula into something like this,

Script Editor

What it does is making the indicator to calculate a form of the typical price within the bar. The average of open, high, low and close is evaluated and assigned to the first plot of the indicator.

After you typed in the formula, if you are not sure that you have typed it correctly, you can always use the syntax checking tool to check the correctness of your indicator syntax. To check the syntax, use the menu,

Indicator menu>Verify

If there is any syntax error, NeoTicker will notify you and then it will place the cursor at the position where it cannot interpret your code.

Step 4 – Install The Indicator

Once you completed your code, you can install the indicator so that you can start using it within NeoTicker.

To install the indicator, use the menu command,

Indicator menu>Install

If you have not saved the indicator at all, NeoTicker will request for a filename for the formula indicator to be saved. If you open an existing formula indicator to edit, it will be saved before installation begins.

If the formula is recognized as a correctly written formula indicator, it will be installed and NeoTicker will confirm the success of installation.

If the formula indicator is not recognized as a properly written formula indicator, NeoTicker will complain that it encounter some sort of error. You can then track down the error based on the description, or you can use the menu command Indicator>Verify to locate your syntax error directly.

Using the Indicator in a Chart

First, create a chart. Any chart with some data will do.

Here is my chart window.

Chart

Then choose Add Indicator from the popup menu to show the Add Indicator window.

Script editor

You will find our indicator My Special Price showing within the indicator list All. Select our indicator.

You can also take a look at the Link tab. This page is the place for you to set specific series from within the chart to link to the linked series of the indicator. In our case, there is only one data series within the chart thus it is chosen automatically.

To add the indicator to the chart, press the Apply button.

Our indicator will be added to the chart just like any other indicators.

Chart

Using the Indicator in the Quote Window

Now, I will show you how versatile our indicator can be.

Create a quote window. Then choose to add a formula column. When the Quote Column Properties window show up, type our indicator into the quote column formula,

Formula setup

For this formula column, we are calculating our average price on the 5-minute bar series.

Now, take a look at the resulting quote window.

Quote window

Concept of Development Cycle

When we develop complex indicators or trading systems, it is not a linear process and does not progress exactly like the 4 steps I have described above.

For many situations, we may need a few times to get our formulas written correctly. When that is the case, then after we installed the indicator and tested that within a chart to check the correctness, we will need to make changes to the formulas within the script editor. Then we have to install the indicator again, followed by testing it within our charts. So, that cycle will have to continue until we are satisfied with the result we see.

This on-going process is called the development cycle or debugging cycle, that you have to be aware of. Remember that it takes patience to perfect your indicators. For most complex indicators it is never a single shot deal – it is not likely you will get it right on the first try. If something does not work on the first few tries, be patient and look for solutions in alternative ways.

Reusability and Extensibility

Formula indicators can be reused within any other indicators, no matter what languages they are written in. Formula indicators can also be used to implement trading systems.

You can think of formula indicators as a tool to create building blocks. By creating formula indicators that do simplier things, you can construct extremely complex indicators and trading systems by reusing these building blocks.

Summary

Formula indicator is one of the most powerful tools within NeoTicker. It expands the power of NeoTicker in so many ways that it is a must learn tool if you want to customize NeoTicker to fit your trading style completely.

Indicator formula language is designed for technical analysis and it is very concise for expressing complex ideas in indicator and trading system creations. It may take you some time to learn the basics of this language, but I am sure you will find that it will payoff handsomely over time.

You can download the indicator here, My Special Price.

Exercise

There is no exercise for this first tutorial as we have not started talking about how to write formula yet.

Discuss this article.

Leave a Comment

Blog Developed
By ContentRobot