Advanced topics; writing a filtering strategy, build your own indicator and working with arrays, vectors, etc.

A powerful way to achieve great strategy performance with Strategy Seeker is to launch a “dual strategy” testing. This means, using two different strategies, each in different step. First, create a strategy that seeks specific symbol behavior (we call it the ‘filtering strategy’) and use it to create your specific universe (using Add2Universe function in the strategy, see previous posts). Second, use another strategy, that expect only symbols with the pre-defined behavior (as defined by the filtering strategy) and ‘milk’ it, resulting in very high testing performance.

The following is a new strategy sample, added to our public library: Filter Strategy

This strategy creates its own functions to check symbol behavior: Cross_up() – to find when the symbol close is crossing a specific line, and Cross_dn(). Than it check how many days pass between crossing up and down and store it in an array called vector. Later, the strategy uses its own average(), stddev() and count() functions to calculate the average of all days in the vector, the standard deviation from the average and count how many occurrences of crossing up and down are stored in the array.

It’s a great sample of how to use and manipulate variable type – array, as well as example creating our own indicators, functions and how to store parameters in one interaction so it can be used in second iteration.

What is strategy iteration?

Whenever we use the Chart menu, back-test, optimize or forward test, let’s say for 1 month, the system executes 22 trading days and compute the strategy (to see if Buys, Sells, are performed). Each execution is iteration: iteration of 1st day, 2nd day, and so on. Our above strategy in every iteration (or day) check if the close cross up or down certain value, and if so, calculates the days pass between crossings up and down and store it in an array. Later it uses its own functions to calculate the average days between crossing up and down, the standard deviation and count how many times it happened.

Strategy Seeker do not keep parameter values of previous iteration (previous days) and therefore, calculations from previous iterations are lost. Therefore, if you want to refer to past result or calculation, you need to store it in global parameters. The statement ‘my $params = GetGlobal();’ at the beginning of the strategy restore past parameters and the ‘SetGlobal( \@params );’ at the end of the strategy, store the latest values in the global parameters, so it can be retrieve in the beginning of next iteration. Note that $params is an array by itself, and each element is used to store different iteration variable. In the sample strategy beginning you can find:

my $vector = $params[0];
my $direction = $params[1];
my $last_date = $params[2];

This means that $vector (which is also an array0 is stored in $params first element and $last_date is stored in third element.

If you have any question, please do not hesitate to contact us via the contact us menu.

We strongly recommend that you check the Strategy Public library and find other useful strategy samples.

Have a great trading week,
Strategy Seeker Team!

Enter your Strategy Seeker username.
Enter the password that accompanies your username.
1 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
Secure Login

This login is SSL protected