Condition Wizard

Condition Wizard is a special feature which allows you to build up conditions or logical expressions without the usage of thinkScript. Being an alternative to the thinkScript Editor, it does not require special knowledge of thinkScript, which might be especially convenient for new users of Study Alerts, Custom Quotes or Study Filters.

In order to switch to Condition Wizard mode of defining conditions (while adding a new study, a custom quote, a study alert, or a study filter in the Stock Hacker scanning tool), make sure that the thinkScript Editor is launched, and click the Condition Wizard tab. Now you are ready to specify your conditions.

Click the Add condition button; this will launch the Edit Condition dialog. This dialog will allow you to specify a condition: the relationship between two expressions with some logical check. Start with specifying the first expression: in the drop-down list, choose whether it should be a function, a study, a price, or a value. While the first two choices speak for themselves, the choice of price will also allow you to use any of the Fundamental functions including the volume, implied volatility, etc.; choosing "Value" will prompt you to enter a number. After that you will need to specify which study, function, or price will be used as the first expression. After specifying one, you will see it added with default parameters which can be customized manually; price functions will also allow you to specify a custom aggregation period for which they will be returned (it cannot be less than the current one). Note that some functions do not have default parameters; this means you need to specify them. These "obligatory" parameters are marked with warning signs. Note also that for studies that have multiple plots, you will need to specify a single plot whose values will be analyzed (by default, it is going to be the first plot on the list).

After specifying the first expression, move to the second column which allows you to specify the relation between the expressions that needs to be checked. The commands in this column use human-readable syntax, however, if you are not sure that you understand them fully, please refer to our tutorial. After that, move on to the third column to specify the second expression. It can be done in the same way as for the first expression, although note that there is not much sense in comparing two expressions of type "Value" as the result will be either always true or always false (two will never equal three, for example).

Now let's see how it works: we are going to check when a 5 period simple moving average (SMA) crosses a 20 period one. In the Edit Condition dialog, we choose "Study" and select SimpleMovingAvg from the list. We are going to keep the default values for price and displace parameters, only changing value of parameter length to 5. In the second column, we select "crosses above". In the third column, we are going to do the same as in the first one, changing study's length parameter to 20. This will define the mentioned condition.

In the dialog window, there are also two extra options. First one is offset, it is available in the first and the third columns for studies, price, and certain functions. Specifying an offset will have the system calculate study or function value several bars prior to or ahead of the current one. Positive numbers define bars prior to the current one, while negative numbers signify the forward offset. The second extra feature can be described as "condition expansion"; it is available in the third column and is used to check whether some condition was true at least once for any of the last several bars. If, for example, you specify 3 as the value for this parameter, the condition will be perceived as true if it was true for at least one bar out of the last three. In thinkScript terms, this parameter replaces the within command.

Once you have finished composing the condition, click Save. The condition will be added to the Conditions list.

Both Condition Wizard and thinkScript Editor support complex conditions, i.e., those made up of the simple ones connected via logical operators AND and OR. In the thinkScript Editor these complex formulas are created using reserved words or and and as the connectors. In the Condition Wizard, you will need to specify all parts of the complex condition by clicking the Add condition button and choose whether to check it when all or any of the small conditions are true (use the all/any drop-down list for that). This means that you can only use the same operator with all condition parts. If you need a more complex logic scheme which combines conditional expressions connected with both OR and AND operator, it is suggested that you switch to the thinkScript Editor and manually change the connectors so that they perfectly describe the desirable logic scheme. Note that in this case, you will not be able to switch back to the Condition Wizard (unless all condition parts are connected only with either ORs or ANDs), thus, make sure your thinkScript skills are sufficient.

After finishing with all the necessary condition parts, click OK. This will add the condition to where it belongs: a study, a custom quote, a study filter, or a study alert.