Close
Skip to content

Tutorial 59 | Strategy where trades are based on two events

Welcome to tutorial 59 in this series of tutorials designed to help you learn TradeStation EasyLanguage.

I’m often asked to program strategies where, I am told, event A must happen and then event B must happen for a trade to be generated. But this 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 occurs 50 or 500 bars after event A? If it happened any time in the future, would it still be valid?

Most people seem to assume a small number of bars between event A and event B. It is one of those things that you know when you see; unfortunately when writing programs you have to be very precise.

This tutorial uses as an example a CCI (Commodity Channel Index) cross of the zero line, followed by the crossing of two moving averages within a user input number of bars. In other words, once the CCI cross above the zero line occurs, we start counting. If the fast moving average crosses over the slow moving average within a specified number of bars we issue a buy order. 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 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 59 applied to a 15 minute @ES chart


A video below explains the tutorial in more detail.

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

The program works in TradeStation versions 8.7, 8.8, 9.0 and 9,1 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 59 Video

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

The program works in TradeStation versions 8.7, 8.8, 9.0 and 9.1 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.