Avoiding intra-day transaction

A strategy is a set of rules for Buy ("Buy rules") and a set of rules for Sell ("Sell rules"). The current version of Strategy Seeker is provided for "swing trading". A swing trading position is typically held longer than a day, but shorter than weeks (average of 5-7 days). When we write a strategy, it is important to make sure that the Buy rules and the Sell rules do not generate signals on the same day. This may happen when the Buy rule and the Sell rule result "true" during the same day. For example, consider the following strategy:

# Buy rules:
if( MP() == 0 and
RSI(2) > 20 ) {
Buy();
}

# Sell rules
if ( MP() == 1 and
RSI(2) < 30 ) {
Sell();
}

Now, what happens if RSI(2) of a specific day is 25. Since MP() equal to zero (there is yet no market position) and RSI(2) > 20: a Buy signal is issued.
The strategy continue to the Sell rules: now, MP() is equal to 1 (there was a Buy signal and we hold market position) and RSI(2) < 30: an immediate Sell signal is issued.
The result is same day trade which we need to avoid in swing trading. Therefore, and in order to avoid same day trading we need to replave the second "if" with "elsif" and the strategy code must look like:


# Buy rules:
if( MP() == 0 and
RSI(2) > 20 ) {
Buy();
}

# Sell rules
elsif ( MP() == 1 and
RSI(2) < 30 ) {
Sell();
}

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

This login is SSL protected

Loading