Tutorial: Using Advanced Features
Writing Custom Entry/Exit Systems
Writing Custom Entry/Exit Systems
i Tutorial Task
Learn to write a custom entry/exit system by modifying an existing one.
TradingSolutions includes several basic entry/exit systems. These sample entry/exit systems are based on single indicators to provide examples both of how entry/exit systems work and how various indicators can be used for market timing. They can work well in specific market conditions, but often break down for long periods of time.
Entry/exit systems used for trading are often more complex. They involve several different rules working in conjunction to produce signals that work well in a variety of market conditions.
For this example, let’s take an existing entry/exit system and add an additional rule to it. Specifically, let’s start with the Moving Average System, which enters the market when a short-term moving average crosses over a long-term moving average. Then, let’s add rules that force it to exit (stop) in cases where losses exceed a certain amount.
Step-by-step Instructions
1. Press the Define Entry/Exit Systems button in the toolbar.

Figure 1. Pressing "Define Entry/Exit Systems".
Ä Note: If you cannot locate this button, you can also select this option from the Processing menu.
2. Create a group for your functions so you can keep them separate from those included with the software. Press the New… button beneath the list of Trading Solution Groups.
Ä Note: If you have already created a new group, simply select it from the list of groups and proceed to step 4.

Figure 2. Location of "New…" button for creating a new group.
3. Accept the default name of My Entry/Exit Systems by pressing OK.
4. Create a new function in the selected group by pressing the New… button beneath the list of Entry/Exit Systems in the Selected Group.

Figure 3. Location of "New…" button for creating a new entry/exit system.
5. Enter a Display Name for your function of MA System with Stop on Loss.
![]()
Figure 4. Entering a name for the new system.
6. Press Copy another Entry/Exit System….

Figure 5. Location of "Copy another Entry/Exit System…"
7. Select Moving Average System from the list of Entry/Exit Systems in the Selected Group.

Figure 6. Selecting "Moving Average System".
8. Press the OK button to perform the copy.
9. Press Next to advance to the Enter Rules page.
10. If we were creating a new Entry/Exit System, these rules would be empty. However, since we copied another system, rules are already defined for Enter Long and Enter Short.
11. Now, let’s add our exit rules. Select the Exit Long tab.

Figure 7. Location of "Exit Long" tab.
12. Press the Add… button to add a new rule for when to exit long.

Figure 8. Location of "Add" button.
13. Entering entry/exit system rules is exactly the same as entering formulas for custom functions. In this case, select the Entry/Exit System Functions group.

Figure 9. Selecting "Entry/Exit System Functions and Rules".
14. Select Rule: Exit On Percent Loss and press Insert into Formula.

Figure 10. Selecting "Rule: Exit On Percent Loss".
15. This function requires the opening and closing price. This information will need to be provided when the entry/exit system is applied. We will need to create inputs to do this. Press Create New Input….

Figure 11. Location of "Create New Input…"
16. Accept the default values of naming this input "Open" and providing it as a data series. Press OK.
17. Press Create New Input… and press OK again to repeat these steps and create a Close input.
18. This function also needs to know what loss percentage to exit at. Let’s provide this information when the entry/exit system is applied and allow it to be optimized. Press Create New Input….
19. The default values for this input set the default to a 5% loss which can be optimized to any value from 0 to 100%. Accept these defaults by pressing OK.

Figure 12. The Modify Input dialog for "Percent Loss For Exit".
20. The final input to this function indicates whether it is being used for a long or a short exit. In this case, it’s a long exit, so let’s set it to zero, indicating "false". Press the Numeric Constant tab.

Figure 13. Location of the "Numeric Constant" tab.
21. The default value for this parameter is 0. Press Insert into Formula to use this.
22. Our exit long rule is now completed. Press Close.
23. We should now enter a similar rule for exiting short. Press the Exit Short tab.

Figure 13. Location of the "Exit Short" tab.
24. Press the Add… button to start a new rule.
25. Select Rule: Exit On Percent Loss from the Entry/Exit System Functions group and press Insert into Formula.
26. We can reuse the inputs we have already created to use with this function. Press Insert into Formula for the Open value, the Close value, and the Percent Loss For Exit value.
27. We will want to set the For Short Exit value to a value other than zero, indicating "true". Select the Numeric Constant tab.
28. Enter 1 and press Insert into Formula.
![]()
Figure 14. Entering a constant of 1
29. Our exit short rule is now completed. Press Close.
30. With our rules completed, press the Next button to continue in the wizard.
31. The Verify Inputs shows us all of the inputs required by our system. If desired, the order of these inputs can be modified by sliding them up or down in the overall order. Feel free to experiment with this, then press Next.

Figure 15. List of inputs in the order they are specified.
32. Since we copied an existing entry/exit system, the notes associated with that system were also copied. Later, we may want to update these notes to include the new inputs and functionality we have added. However, for now, press Finish to save our changes.
33. Press Close. You can now apply this new entry/exit system to any data or group, the same as any entry/exit system included with the software.
Congratulations!
You have learned the basics of writing custom entry/exit systems by taking an existing entry/exit system and adding new rules to it.
_ Continue to the next task.