Skip to content

Tutorial 165 | Creating to a button pause a strategy making trades

Tutorial165

Tutorial 165 looks at how a strategy can be paused without changing the status of a strategy applied to real-time bars on a chart. In this tutorial the demo strategy is paused from generating trades by the click of a button.

The simple ‘dummy’ strategy in the tutorial generates market orders based on a counter. A condition for an order to take place is when the Boolean variable ‘Trade’ is set to TRUE. The Boolean variable is switched between true and false by clicking a button.

Do not use this program in your live account.

The tutorial demonstrates how to create a simple form and button. It also shows how to create and use a button click event. The form and button are initially created using the ‘Add Form’ capability and then using the visual design tools. Once the code is created the associated code is copied from the ‘Designer Generated Code’ area into a strategy. The form is then deleted from the ‘Resource View.’

Steps to delete the form in the ‘designer generated code’:
1) In the TradeStation Development Environment (TDE) Click View-Toolbars-Resource View
2) Look for the program name and right click on the form then click ‘delete form.’

When creating form syntax using the tools in the component tray, don’t forget to add syntax: NameOfForm.Show( );, e.g. Form1.Show( ); to display the form

Video walk-through of the tutorial code

Download the tutorial 165 strategy

If you want to save yourself some typing,  the tutorial 165 program is available for immediate download for $19.95 by clicking the following button. You can pay using PayPal or credit card. The program works with TradeStation 9.5, and TradeStation 10 but, unfortunately, is not compatible with MultiCharts.

The download consists of _Tutorial165 and _Tutorial165 – devel (the program developed in the tutorial).

The strategy is not protected, in other words, you will be able to see, modify and experiment with the tutorial’s code.

The difference between _Tutorial165 and _Tutorial165 – devel

_Tutorial165 and _Tutorial165 – devel are basically the same but in _Tutorial165 I declared three ‘namespaces.’

Using elsystem;
Using elsystem.windows.forms;
Using elsystem.drawing;

This means that having done so, instead of having to refer to objects by their fully ‘qualified’ name, for example:

elsystem.windows.forms.Form Form1(NULL)
elsystem.drawing.Color.Red;
Button1 = new elsystem.windows.forms.Button();
etc

In the final program I could refer to them as:

Form Form1(NULL)
Color.Red;
Button1 = new Button();
etc

THE TRADING APPS, INDICATORS, SHOW ME STUDIES, STRATEGIES AND OTHER PROGRAMS HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES.

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, TRADING APPS, 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.