Strategy Sample

The following articles are sample strategies. You may Add a new strategy, copy and past the content of each (separately) strategy into, and use it: (note: comment start with '#', you can read more at Write Strategy)

Note July 25, 2012: see below a sample strategy with MACD, SAR and MFI indicators.

###########################################################
#
#
# SAMPLE 1: A Simple Strategy Code:
#
# This demo strategy that will buy
# after 3 days in a raw of descending at the Close of end
# of the day and will sell after RSI(2) is greater than 75
#
# You may copy and paste the content into your
# own new strategy
#
###########################################################
#
#
#
# Conditions to Buy are:

if ( MP() == 0 and #If we do not have a market position - no buy yet
Close() > SMA(200) and #If todays Close is greater than todays Simple Moving Average of 200 days
Close(2) < Close(3) and #if Close of 2 days ago is smaller than Close of 3 days ago
Close(1) < Close(2) and #if Close of 1 day ago is smaller than Close of 2 days ago
Close() < Close() ) #if Close of today is smaller than Close of 1 day ago
{
Buy() ;
}

# Conditions to Sell are:

if ( MP() != 0 and # If we do have a market position - after buy
RSI(2) > 75 )
{
Sell(); # Yes, issue a Sell at the Close of Today
}

# END OF SAMPLE 1

#############################################################
#
# SAMPLE 2: A Simple Strategy Code:
#
# Name: RSI2 Indicator Version 1
# Desc: RSI today below 10 after 3 descending days
# Ver : 1
# Date: July 1, 2011
#
#############################################################
#
#
# Conditions to Buy are:

if ( MP() == 0 and # If we do not have a market position - no buy yet
Close() > SMA(200) and # If todays Close is greater than todays Simple Moving Average of 200 days
RSI(2) < 10 and # if RSI(2) of today is smaller than 10
RSI(2) < RSI(2,1) and # if RSI(2) of today is smaller than RSI(2) of yesterday
RSI(2,1) < RSI(2,2) ) # if RSI(2) of 1 day ago is smaller than RSI(2) of 2 days ago
{
Buy() ;
}

# Conditions to Sell are:

if ( MP() != 0 and # If we do have a market position - after buy
Close > SMA(5) ) # If todays Close is greater than todays Simple Moving Average of 5 days
{
Sell("Sell at Close=".Close() ); # Sell today, print comment inside the trading report
}

#
# END OF SAMPLE 2

#############################################################
#
#
# SAMPLE 3: A Simple Strategy Code:
#
# Name: RSI2 Indicator Version 2
# Desc: RSI after 3 descending days falling from below 60 4 days ago
# Ver : 2.1
# Date: July 1, 2011
#
#############################################################
#
#
# # Conditions to Buy are:
if (MP() != 1 and # If we do not have a market position - no buy yet
Close()>SMA(200) and # If todays Close is greater than todays Simple Moving Average of 200 days
RSI(2,4) < 60 and # RSI(2) 4 days ago is smaller than 60
RSI(2,1)<10 and # RSI(2) of yesterday is smaller than 10
RSI(2) SMA(5) ) # If todays Close is greater than todays Simple Moving Average of 5 days
{
Sell("Sell at Close=".Close() ) # Sell today with no comment to be printed inside the report
}
#
# END OF SAMPLE 3

#######################################################
#
# Strategy name: MACD test
# Owner : shlomo
# Description : This strategy is provided for demo of new Technical Indicators: MACD, MFI and Parabolic SAR
# Created on : Wed, 25 Jul 2012 12:08:56 +0300
#
#######################################################
#
# Buy Section
#

my $macdval; # variable to store MACD returned value
my $hist ; # variable to store Hist returned value from MACD
my $mfival; # variable to store returned value from MFI
my $sarval; # variable to store returned value from Parabolic SAR
my $string; # String variable to store result string

if ( MP() == 0 and # first check that we have do not have market position.
Close(1) > Close() )
{
# First calculate MACD for parameters 12,26 and 9.
# Note that MACD returns 2 parameters, one will be stored at $macdval and second will be stored at $hist
#
($macdval, $hist ) = MACD( 12 , 26 , 9 ) ;

# Now calculate MFI for last 14 days:
#
$mfival = MFI( 14 );

# Now calculate Parabolic SAR for 0.02 and 0.2
#
$sarval = SAR( 0.02 , 0.2 );

# Lets create the result string. Its a formatted string that contains the calculated values and
# will be displayed using the Buy command later.
#
$string = "MACD=".sprintf("%.2f",$macdval) ; # Note: the Use of sprintf function is to keep only 2 digits after the point
$string .= " HIST=".sprintf("%.2f",$hist); # add at the end of the string the Hist value
$string .= " MFI=".sprintf("%.2f",$mfival); # add at the end of the string the MFI value
$string .= " SAR=".sprintf("%.2f",$sarval) ; # add at the end of the string the Parabolic SAR value

# Now issue a Buy command, and print the above calculated values in the reprot Tab of the Chart module
# To check the strategy and the report you need to:
# 1. Create a portfolio that include this procedure
# 2. Run the portfolio in the Chart module (choose a symbol)
# 3. When completed, check the Report tab and find the calculated values in the Buy Comment column
#
Buy( $string ) ; #Buy a position!
}

#
# Sell Section
#
elsif ( MP() == 1 and # first check that we have market position.
RSI(2) > 75 )
{
Sell(); #Sell the position!
}

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

This login is SSL protected

Loading