Sep
10

Formula 101 – #7 Advanced Series Controls

Due to the complex nature of the data series functions and indicators, from time to time, the basic access techniques we’ve learned in Tutorial 5 and Tutorial 6 are not enough to cover some special needs. We are going to discuss the more advanced syntax in the quote formulas that enable you to do more.

There are four (4) types of extended syntax in the quote formula that I will discuss in this tutorial, so expect this tutorial a bit longer than usual.

Link indicators to different fields in a data series

Here is a practical situation. If you are interested in the 10 period lowest low of the 5-minute series, how are you going to do that?

Based on what we&#39ve learned in previous tutorials, we will need to use the lowest low indicator, like this,

llv (1, M5, 10)

But, the above indicator calculation only returns the lowest low of the close prices, not the lowest low of the low price in the 5-minute series.

Could it be a mistake in NeoTicker? Not likely.

Remember what I said in the first few tutorials? NeoTicker is only processing the quote formula the way you have written, nothing more. Since the formula above is referring to the 5-minute data series by M5, NeoTicker has no way to tell if you are interested in the Low prices instead of the Close prices within the series.

To tell NeoTicker linking an indicator to a field within the data series different from the default one, we need to add the Field Name Suffix to the SeriesDescriptor. The general form of the extension looks like this,

SeriesDescriptor.FieldName

The FieldName can be one of the following fields,

Open
High
Low
Close
Volume
Tick
OpenInterest
DateTime

And there is a set of equivalent short forms,

O
H
L
C
V
T
OI
DT

So for the lowest low value that we want to display, the formula can be written as,

llv (1, M5.Low, 10)

Or, using the short form of the field name,

llv (1, m5.l, 10)

Another common example is the formula for calculating the average volume over a specific period,

average (1, M15.volume, 10)

Or, using short form,

average (1, M15.v 10)

I think you get the idea.

Accessing indicator plot values from plot series other than the first one

Here is another common situation – you are interested in checking out the second or the third plot of an indicator. The standard syntax for indicators does not provide the necessary means to access those plot values that you need.

For example, you know the formula for the 3 lines Bollinger Band is,

bbands3 (M5, 10, 1)

That gives you the latest value of the Bollinger band indicator, but for the first plot series only.

To access the second or the third plot series, you need to add the Plot Value Suffix to the indicator name,

IndicatorName.PlotN

In our example, the IndicatorName is bbands3.

To access the second plot, we write,

bbands3.plot2 (M5, 10, 1)

To access the third plot, we write,

bbands.plot3 (M5, 10, 1)

As many of you may have guessed, we do have a short form for the Plot Value Suffix. You can write the above formulas like these,

bbands.p2 (M5, 10, 1)
bBands.p3 (M5, 10, 1)

And that will work just fine.

Controlled Days To Load

By default, NeoTicker will force a series to load at least 250 bars for a minute based series. So, for a 5-minute series, NeoTicker will automatically try to grab about 5 days of data. By the same token, if you requested for a 1-minute series, NeoTicker will automatically load about 1 day of data. This helps NeoTicker to conserve memory while getting correct answers for the indicator calculations. You can always adjust the default settings in the Cache Manager, under RAM Cache Options to accommodate your preference.

But, there are situations that you can never make NeoTicker accommodating all possible combinations of data series usages. Here is an example.

You are using 30-minute series to display their 100 period moving averages, and, you are also interested in 120-minute series for price patterns. For the 5-minute series, you do need about 15 days of minute data. For the 120-minute series, you will need only a few bars. Unluckily, by default, NeoTicker will guess that you need more number of bars for the 120-minute series, and that guessed number is likely in the range of 60 days (3 to 4 bars a day, with a minimum of 250 bars to fill).

To accommodate a situation like this, you can force the 120-minute series to load only 5 days of data, using the Extended SeriesDescriptor syntax,

SeriesDescriptor:DaysToLoad

Or if you need to link to a particular field,

SeriesDescriptor:DaysToLoad.FieldName

So, in the example we talked about, you can write a formula that look for 3 consecutive up close in 120-minute series like this,

C (3, M120:5) < C (2, M120:5) and C (2, M120:5) < C (1, M120:5) and C (1, M120:5) < C (M120:5)

That will force NeoTicker to request for up to 5 days of data only for the 120-minute series.

Direct Symbol Access

There are times you want to refer your calculations to a symbol not originally linked to the formula. For example, you want to compare a particular stock’s current day rate of change against the index it belongs to. Without access to the index symbol, you will not be able to conduct such calculations.

To access another symbol within your formula, you need to use the Symbol Prefix syntax. The general format is as follows,

[Symbol]QuoteField

[Symbol]SeriesDescriptor

Here is an example,

NetPct > [$NDX]NetPct

Here is another one,

SlowK (M5, 5, 3) > SlowK ([$INDU]M5, 5, 3)

If you need to control the number of days to load, or, if you need to specify a field as the link, you can do that just like what we talked about in the previous section.

Example – Relative Strength Ranking

Ever want to compare the real-time relative strength of a stock to an index?

Relative Strength based on Net% is too simple for real-time usage as that is based on a static price point, the previous trading day close.

To compare real-time relative strength, we can first calculate a customized percent change based on the 10-period moving average of its 60-minute series. As oppose to using just the latest price, we can further smooth out the ranking by using the 5-minute moving average as the current price level. In short, we are checking out the normalized MACD value based on 5-minute and 60-minute series combination.

I will use the Nasdaq 100 index as the reference symbol and applying exactly the same calculation we have done on the stock symbols.

The relative strength value will then be simply the ratio between the strength of the stock and the strength of the index.

Sounds very complicated, isn&#39t it? It is not really that complicated when you see the actual formula.

Putting it together, here is the formula setup,

formula101 part7 formula setup

We have used the days to load control in our formula. That way, we save a lot of memory and open up the possibility to put as many symbols as we want into the quote window for real-time filtering and auto ranking.

The days I have specified in the formula provided just enough data for the calculation of the simple moving average that we have used in the formula. If you are going to use different indicators, especially the ones involving exponential smoothing, you will need more days of data loaded to get correct indicator calculation.

Here is the color rule settings,

Formula101 part7 color setup

Now, here is how the quote window looks like,

formula101 part7 quote window

I have put the Net% column right there as a comparison. Notice that even though some symbols have net down day with negative Net%, it does not necessarily mean that those symbols have negative ranking based on our formula.

I have also sorted the ranking column by clicking at the column header. In real-time usage, it is likely you are going to have multiple formula calculations within the same quote window. Whenever you need to see the symbols sorted by a particular column – just click the header.

Summary

The four extended syntax in the quote formula serve their own special purposes. You can consider them similar to adjectives we use in English as they are there to clarify what we mean with our formulas. Just remember that there exists these extended syntax for now. When you find that you have the need to use them, refer back to this tutorial to refresh your memory.

Exercise

1. What is the formula for finding the range over the past 10 5-minute bars, withou using the range indicator?

2. What is the formula for identifying the previous 5-minute bar being the lowest low over the past 10 bars?

3. What is the formula for telling the time that the current 5-minute bar is the first bar after round hour?

Answers for Previous Exercises

1. This one is pretty easy, just use slowk (or your favourite oscillator) across the 3 time frames will do,

slowk (M15, 5, 3) > 70 and slowk (H1, 5, 3) and slowk (D1, 5, 3)

Personally, I prefer working with the indicator value stabalized, that means, we are looking at 1 bar ago indicator values,

slowk (1, M15, 5, 3) > 70 and slowk (1, H1, 5, 3) and slowk (1, D1, 5, 3)

2. This one is tricky because we are talking about crossing, and not differentiating whether it is crossing above or below,

C (M20, 1) < = average (M20, 50) and C (M20) > average (M20) or
C (M20, 1) >= average (M20, 50) and C (M20) < average (M20)

Remember that the or operator has lower priority than the and operator, thus the above formula will produce the result we want.

There is another way to write the above condition, which is more concise and elegant, based on the fml indicator. It is a much more advanced topic and should be discussed in Formula 201.

3. Here is the formula,

C (1, M5) > O (1, M5) and O (1, M5) > (H (1, M5) + L (1, M5)) / 2 and C (1, M5) > PrevDAverage (M5)

We saved one comparison (comparing to a previous tutorial) because we already know that the close of the previous bar is greater than the open of the previous bar, there is no need to compare that close against the mid point of the bar because the open price already is.

Discuss this article.

Leave a Comment

Blog Developed
By ContentRobot