Mar
14

Programming the Time Distribution Analysis Indicator

In the article An Introduction to Time Distribution Analysis, I introduced an indicator that can be used to generate reports based on user defined criteria. This indicator is a very good example that illustrates the cross language development capability in NeoTicker.

(Lawrence – this article requires some basic knowledge in at least one of the programming languages supported by NeoTicker. e.g. Delphi, VB, VC++, VC#, VB.NET, C++ Builder, or NeoTicker’s built-in scripting language, Delphi Script.)

Using Delphi Script for Prototyping

I actually have this indicator developed for NeoTicker long time ago. This tool is handy when you are exploring new ideas and looking for clues from the data series visually.

Since I am working on some trading models for Forex trading, I need to dig out this indicator to help me explore the price behaviour in the currency pairs.

The old version of this indicator does not have the accumulated percentage display, I have added that to improve the usefulness of this indicator.

This indicator is a good example showing how we can use the heap object to store data and use them as state transition flag to control the flow of the script.

The advantage of using Delphi Script is that you can write an indicator without using any additional tools. Thus it is great for writing utility indicators like this one, or, indicators that you have not finalized the overall design, so you are likely to modify that very often until you are satisfied with the design.

Conversion to Regular Delphi

As I expected to use the indicator on very long historical data, like the example I have given in the previous article, that I am testing ideas on a year of 1-minute data bars, the performance of Delphi Script can impact the usage experience.

I decided to convert the Delphi Script indicator into a Delphi based indicator, that should give me the performance boost I am looking for. I choose Delphi as the conversion target because it is very similar to Delphi Script. If you start out with an indicator written in VBScript, then using Visual Basic as the conversion target is a natural choice.

I copied the indicator code I have in the Delphi Script version and pasted that into a skeleton Delphi IDL indicator project. Then I try to compile the project into a DLL library. The compiler catched the incompatible codes from my script automatically. All I have to do is look at those places where the compiler is not accepting the code and made the necessary modifications into something that the Delphi compiler will accept. The whole process took less than ten minutes.

Within NeoTicker, I created an IDL indicator file that tells NeoTicker to use the DLL library I just generated as my new indicator.

The performance gain? On the 1-minute data of year 2005, it took the Delphi Script version 30 seconds to complete its analysis. With the Delphi IDL version, it took 5 seconds only.

Another Interesting Setup

Here is another distribution that is very interesting,

time analysis 01

Emini S&P tends to bounce from the previous day low for more than 2 points 67% of the time. And majority of that happens within the first 45 minutes after the pre-condition happened.

Summary

Delphi Script is a great tool for fast prototyping of indicators. Its weakness is that it performs slower than a regular programming language when we are talking about heavy duty usage.

It is not that hard to take advantage of a regular programming tool like Delphi. You do not even need to know the details about the development environment if all you are interested in is using these developer tools to generate extremely fast indicators.

Complete Indicators

Script version Time Distribution Analysis.

IDL version source code here

Discussion

Leave a Comment

Blog Developed
By ContentRobot