Close
Skip to content

Tutorial 66 | Strategy where trades are based on two events and an ADX filter

Welcome to tutorial 66 in this series of tutorials designed to help you learn TradeStation EasyLanguage. This tutorial builds on the work done in tutorial 59.

As I mentioned in tutorial 59, I am often asked to program strategies where, to generate a trade, event A must happen followed by event B. For example, a moving average crossover occurs followed by a CCI cross over the zero line. But this specification doesn’t tell us how soon event B has occur after event A for trade to be valid. For example, is it valid if event B occurs 5 bars after event A? What about if it occurred 500 bars after event A? Or 5 million bars, would it still be valid?

This tutorial uses the CCI (Commodity Channel Index) cross of the zero line, followed by the crossing of two moving averages within a user input number of bars that we developed in tutorial 59. It also includes a filter such that trades may only occur if the ADX is greater than a user input value.

The new program works as follows: once the CCI crosses above the zero line occurs, the program starts counting. If the fast moving average crosses over the slow moving average within a specified number of bars and the ADX is greater than a user specified value then we issue a buy order. For going short, if the CCI crosses below the zero line, we start counting. If the fast moving average crosses below the slow moving average within a specified number of bars and the ADX is above a user input value, we issue a sell short order.

I also demonstrate how to optimize the strategy and view the strategy performance report.

The image below shows the program applied to a chart.

Tutorial 66 applied to a 15 minute @ES chart togeher with ADX indicator
Tutorial 66 applied to a 15 minute @ES chart together with ADX indicator

A video below explains the tutorial in more detail.

The unprotected program for version 8.7 and above is available for immediate download for $24.95 here:

The program works in TradeStation versions 8.7, 8.8 and 9.0 and is commented throughout.

Please join our email mailing list if you have not already done so and we will let you know when we release new tutorials or programs.

TO THE BEST OF MARKPLEX CORPORATION’S KNOWLEDGE, ALL OF THE INFORMATION ON THIS PAGE IS CORRECT, AND IT IS PROVIDED IN THE HOPE THAT IT WILL BE USEFUL. HOWEVER, MARKPLEX CORPORATION ASSUMES NO LIABILITY FOR ANY DAMAGES, DIRECT OR OTHERWISE, RESULTING FROM THE USE OF THIS INFORMATION AND/OR PROGRAM(S) DESCRIBED, AND NO WARRANTY IS MADE REGARDING ITS ACCURACY OR COMPLETENESS. USE OF THIS INFORMATION AND/OR PROGRAMS DESCRIBED IS AT YOUR OWN RISK.

ANY EASYLANGUAGE OR POWERLANGUAGE TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (AND PARTS THEREOF) AND ASSOCIATED TECHNIQUES REFERRED TO, INCLUDED IN OR ATTACHED TO THIS TUTORIAL OR PROGRAM DESCRIPTION ARE EXAMPLES ONLY, AND HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES. MARKPLEX CORPORATION. DOES NOT RECOMMEND THAT YOU USE ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (OR ANY PARTS THEREOF) OR TECHNIQUES. THE USE OF ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS AND TECHNIQUES DOES NOT GUARANTEE THAT YOU WILL MAKE PROFITS, INCREASE PROFITS, OR MINIMIZE LOSSES.

Tutorial 66 Video – Adding an ADX filter

The unprotected program for version 8.7 and above is available for immediate download for $24.95 here:

The program works in TradeStation versions 8.7, 8.8 and 9.0 and is commented throughout.

If you see any errors in this tutorial – or we have not made something clear, we would be most grateful if you could please let us know. E-mail us at: tutorials@markplex.com. Also, let us know if you have any ideas for new tutorials.

EasyLanguage is a programming language that is part of the TradeStation trading platform. It can be used to write programs to help in the technical analysis and trading of foreign exchange (forex or FX), commodities (e.g. the Dow e-mini, S&P e-mini etc), options, and stocks.