TRADESIGNAL HOW TO 09.

CHART PATTERNS AND CALENDAR EFFECTS .

PART 3: With Equilla to Trading Success.

Equilla can be used to test chart patterns using dozens of pre-programmed modules, as well as to programme individual patterns. Learn below how and which commands are used to output graphical information.

TABLE OF CONTENTS.

  • What would technical analysis be without recurring patterns?
  • A picture says more than a thousand words
  • The Graphic Commands
  • Objective Swing Points – a simple task for Equilla
  • Testing gaps quickly
  • Calendar Effects – myth or reality?
  • Conclusion

 

NOTE: This paper was published in the German edition of the TRADERS’ magazine (issue 12/2014).

 

WHAT WOULD TECHNICAL ANALYSIS BE WITHOUT RECURRING PATTERNS?

Point & Figure charts, candlesticks or specific constellations of rising or falling candles – all of them permit specific entry and exit signals and so can be used to trade in many different ways. Discretionary trading leads to many interpretations that can’t be back tested.

 YOUR BENEFIT IN USING TRADESIGNAL:

Using Tradesignal, each pattern can be back tested and reviewed for robustness.

 

A PICTURE SAYS MORE THAN A THOUSAND WORDS.

Let us start with a simple Inside Bar Pattern. This means the trading days where the low of the current bar is larger or equal to the low of the previous bar, while the high of the current bar must be less than or equal to the high of the previous bar. Pre-installed functions are available for all patterns; even a non-programmer will get an insight into the underlying logic, so that he can write his own pattern identifier with a little practice.

PatternRawInsideBar​​ =​​ Low​​ >​​ Low[1]​​ And​​ High​​ <​​ High[1];

If you want to use patterns within your own trading strategy that trades breakouts from the Inside Day long and short, you only need to refer to the function PatternRawInsideBar. The code for a rudimentary trading strategy may be as follows:

Variables:

pattern;

 

pattern​​ =​​ PatternRawInsideBar( );

 

If​​ close>average(close,50)​​ and​​ pattern​​ and marketposition=0​​ Then​​ 

Buy Next Bar​​ at​​ High​​ Stop;

 

If​​ close<average(close,50)​​ and​​ pattern​​ and marketposition=0​​ Then​​ 

Short Next Bar​​ at​​ Low​​ Stop;

 

If MarketPosition​​ =​​ MarketPositionLong Then Sell next bar​​ At​​ low​​ stop;

If MarketPosition​​ =​​ MarketPositionShort Then Cover Next Bar​​ At​​ high​​ stop;​​ 

 

 

THE GRAPHIC COMMANDS.

For the trader to recognise developing visual signals, Equilla provides many graphics commands. The code shown above must start with the following header:

Meta:

Subchart(false);

Input:

Visuals(​​ True​​ );​​ 

The input produces a selection field that can be set to “true” or “false”. To display the mark in the chart, “false” must be selected for the subchart. The respective pattern can be shown as a text in the chart. The definition of the colour, text size and so on can be implemented with the DrawText command:

If​​ Visuals​​ And​​ pattern​​ 

Then DrawText(​​ Low,​​ "Chart Patterns",​​ "Inside Bar",​​ 9,​​ AlignBottom​​ +​​ Border​​ );

Marking the respective candle is possible with the DrawForest command:

If​​ pattern​​ 

Then DrawForest​​ (low,high,"InsideLow","InsideHigh",Thick,blue,false);

Alternatively, Equilla can also draw a symbol below the Inside Day Pattern:

If​​ pattern​​ then DrawSymbol​​ (low,SymbolTriangleUp,8,green,green);

Figure 1 shows an example chart of the S&P 500 from October 2014 to January 2015. The candles marked in yellow are Inside Days. When the index is above its 50-day-SMA, a long position is taken after the high of an inside pattern was exceeded. When the S&P 500 is below its SMA, undercutting the lows in this formation activates a short position.

FIGURE 1: INSIDE DAY PATTERNS IN THE S&P 500.

Finding candle patterns of any kind is easy for Equilla. This shows inside days (yellow) with highs and lows used as triggers for a long or short item of the following day.

 

OBJECTIVE SWING POINTS – A SIMPLE TASK FOR EQUILLA.

Of course, Equilla not only accesses current, but also all past data. The square brackets are used to instruct Equilla to issue a data point from the past. The simple displacement function permits many application options that can be used as a component of a trading system or, for scanning purposes. This includes, among others, querying changes to an indicator in the course of time. If you would like to check if the current level of the 200-day line is quoted lower than 20 periods ago, the following query is sufficient:

average(close,200)<average(close,200)[20]

Another option that is only possible with the displacement function is recognition of market-technical swing points. Therefore, if you do not want to identify important highs and lows manually but entirely by way of algorithms you first need to teach your computer what a distinctive high or low looks like. You can do that with the following definition:

Swing high Definition: A high surrounded by lower highs on the left and right.

if​​ h<h[2]​​ and​​ h[1]<h[2]​​ and​​ h[2]>h[3]​​ and​​ h[2]>h[4]​​ then​​ hh=h[2];

Swing low Definition: A low surrounded by higher lows on the left and right.
Based on these objective swing points, you can then define trading rules. Breakouts above the last swing high can be used to develop long positions, while swing lows can be defined as stop or short triggers. Use on different time levels is also possible and opens up diverse opportunities for advanced users.

TIP: Read our Algorithmic Trading Tips 10 and you will learn how to combine Renko charts with swing points into a profitable trading strategy.

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:

Inputs:​​ StopInPoints(100,1);

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[1] )​​ =​​ April Then Sell;  ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ If Month(​​ Date​​ )​​ =​​ October And Month(​​ Date[1] )​​ =​​ 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.

FIGURE 3: SEASONAL TRADING STRATEGY FOR THE S&P 500

Testing seasonal strategies takes little effort with Equilla. Above, you can see the chart of the S&P 500 and the associated equity curve of the Sell-in-May strategy. Long entries are only generated if the market is quoted above the 250 days line.

 

CONCLUSION.

The examples shown are only a fraction of the options available. There are no limits, only your imagination: Indicators, chart patterns or seasonal strategies – any idea can be used as the basis for your own trading strategy. For more on these features and benefits of Equilla, see the next part in our Equilla series.

For questions about Tradesignal we are always happy to help. If you are not yet a Tradesignal customer, we will gladly provide you with a trial version.

That’s it for today. Take care, take profit and auf Wiedersehen.