FIGURE 2: RULE-BASED SWING POINTS.
This example shows swing highs and lows for Nike.
TESTING GAPS QUICKLY.
Price gaps are another popular subject. Are they actually closed and if so, how often? What role does the respective market trend play? How can a simple gap trading strategy be built? Questions like this can be answered in Equilla with a few lines of code and so provide valuable insight to your own trading. Let us assume that the trader wants to use days in which the stock market opens at least once percent above the previous day‘s high for a short entry. The Equilla code for this is as follows:
If Open Of Next Bar > 1.01*high Then Short Next Bar At open;
When the short position is opened, the exit is to take place on the following day if the previous day’s high is exceeded by one percent:
If MarketPosition = MarketPositionShort Then Cover Next Bar At 1.01*high stop;
On the long side, the reverse entry and exit conditions apply. The code is as follows:
If Open of Next Bar < 0.99*Low Then Buy Next Bar At Market;
If MarketPosition = MarketPositionLong Then Sell next bar At 0.99*low stop;
If you want to use an initial stop in points, an input must be set for this. Use the corresponding code:
The statement SetStopLoss (StopInPoints) at the end of the Equilla code ensures that the position is closed when a loss of 100 points is reached. Just four lines are enough to perform a back test of this basic strategy. Of course, you can define individual gap values, trend filters, flexible stop losses and profit targets.
CALENDAR EFFECTS – MYTH OR REALITY?
The next example shows that known calendar effects such as Turn of the Month, the upward and downward bias of individual week days or seasonal phenomena à la “Sell in May” can be tested thoroughly as well. If you want to subject the latter stock market phenomenon to a reality test, just write the following lines in Equilla:
If Month( Date ) = May And Month( Date ) = April Then Sell; If Month( Date ) = October And Month( Date ) = September Then Buy;
Figure 3 shows the chart of the S&P 500 and the associated equity curve of the Sell-in-May strategy, including a SMA trend filter.