Writing a strategy

Strategy is a script that describes the conditions to Buy and Sell. The conditions are based on different stock daily parameters, such as Close, Open, High, Low, Volume and on a list of Technical Indicators, such as SMA (Simple Moving Average) RSI (Relative Strength Index), ADX ( Average Directional Index), ROC ( Rate of Change), etc.
This allows to create a smart and sophisticated strategies that automatically issue a Buy signal if buying criteria is reached, or Sell signals.

The Strategyseeker script language is a simple text that includes conditions words, functions, and other operators similar to Perl or PHP languages. For example:
if ( Close() > 10 ) - represent a condition in which today's Stock Close value is higher than 10. The following
if ( Close() > 10 ) { Buy(); } - define a buying condition if today's stock Close is higher than 10. Note that "{" and "}" are special characters described below.

Special characters:

1. # - a comment line, for example:
# this is a comment line, Note that comment can start at the middle of the line, for example:
if ( Close() > 10 ) { Buy(); } # This is my Buy condition!
2. ";" - end of line. Each end of line (unless ends with "{" or "}" ) must end with ";"
3. "{" - begin, this character starts a list ("block") of commands or script lines that will be executed together.
4. "}" - end - this character ends a list of commands or script lines. Note that all commands or lines between { and } are considered one block, for example:

if ( Close() > 10 )
{ # this is begin of command block
Print "Hello Buy Signal";
Buy();
} # this is the end of command block

In the above example if condition is met ( Close today is greater than 10) both Print and Buy commands will happen, otherwise, non of them will happens.
5. "$" - represent a variable. A variable is always start with "$", for example $count and can be used to store values and do calculations, for example:

my $counter=0; # defining a variable name $counter and initializing with value 0 (zero)
my $total = 0;
$total = $counter + 360; # note that each line ends with ";"
my $var = 8/3;
my $still = $var/3;

6. Variable types can be a simple number, string, array or hash. array or hash are for advanced users who knows Perl and will not be discussed in this How to. Also they are vary rarely needed and therefore we will focus on numbers and strings:

my $name="John Smith"; # this is declaration on variable $name type string and initializing it with a name
if ( $name == "Bill Clinton" ) { # checking content of $name, note that "==" is condition test to "equal" ;
$name = "Barak Obama"; # changing the content of $name, note that "=" is variable assignment command different from "=="
}
else
{
$name = "George Bush" ;
}

7. Variable operations:
= assignment $t = 10;
+ addition $t = $t + 10;
- subtraction $net = $total - $extra;
* multiple $mux = $total * $extra;
/ fractional division $per = $total / 100;
% modulus
example:
$Total = $var + $number * ($part + 1000)/100 ;

String operations:
"." - concatenation for example:
my $firstname = "John";
my $lastname = "Smith";
my $fullname = $firstname.$lastname; # the result string is" JohnSmith"
my $namedescription = "My first name=".$firstname." My last name=".$lastname; # the result string is"My first name=John My last name=Smith"

8. Variable logical conditions: used to compare two variables or variable and value:
== equal (if $a==10), if($a==$b)
!= not equal (if $a != 0)
< less (if $a < 10)
> greater (if $a > 4)
<= less or equal (if $t <= $r)
>= greater or equal
and and if ( ($a > $b) and ($b > 100) )
or or if ( ($a > $b) or ($b > 100) )

9. Predefined functions: a function is called by its name followed with "( and ") signs, in between list of parameters.
Click here for a list of our currently supported Technical Indicators?

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

This login is SSL protected

Loading