Long Rule: Conditions

Long Condition 1

Because we only want to trade when we can confirm that the Fast MA finally closes above the Slow MA, we need to ensure that a new candle just opens and see if in the candle that just closes the Fast MA is above the Slow MA. Having that in mind, we need a way to add a condition for our Long rule that will determine whether a new candle just opens.

In Trading SM a condition is a comparison between two values. If you click the New Condition button you can see in the upper board how the Conditions Creator looks like.


Two squares separated by a choice box appear inside the upper board. If you click the choice box you can see all the possible comparisons. Basically, you set a value in the left square that you want to compare with the value you set in the right square. In order to introduce the values in the corresponding squares, we need to first create those values.

In Trading SM one way to create values is by making questions. The answer to a question is a value. We can find all the available questions on the left side panels: Indicators, Timeseries and Misc.


As you can see, we can make a lot of questions in Trading SM. We will use the answers to these questions to make trade decisions. For the purpose of this condition we will use the Is New Bar question. The answer to this question can be true or false and it will be true every time a new bar opens.

The condition we are pursuing looks like this: true equal Is New Bar

In the right square of the condition we will need to set the answer to the question Is New Bar. And in the left square the true value. In the choice box we will select the equal comparison. Meaning that if the answer to Is New Bar is equal to true, then true is equal to true and so, the condition is met. Otherwise, if the answer to the question is false, then false is not equal to true and so, the condition is not met. The condition would be met only once per bar (at the open).

In order to set the true value in the left square we need to create a parameter that will hold this value. So, the first thing we are going to do is to create a parameter named True that will hold the value true. That can be done in the Parameters Creator:


Don’t forget to add the parameter by clicking the Add button as we do in the above video. As we create parameters, they are added to the list of parameters that can be seen at the Parameters pane on the right.

After that, we will come back to the Conditions Creator and drag and drop the parameter just created to the left square:


We select the equal comparison and on the right square we will drag and drop the Is New Bar question. The Is New Bar question is available at Misc panel:


Don’t forget to add the condition.

The buttons available at the top of Trading SM are creator buttons.

Every time you click one of those buttons, the corresponding creator shows up in the upper board. Each creator can use values or questions from different side panels. In order to help you, Trading SM will print in blue the borders of the panels from where you can use values and questions at each creator.

We have already created the first condition. In the next chapter we keep creating the remaining conditions.


Long Condition 2

We do not want to open a new Buy order when there is one already open. For that purpose we need a condition that will check whether there are more buy orders open in the terminal.

There is also a question available in Trading SM that will answer us how many orders of a specific type (like buy or sell) are open at any time in the terminal. So, the comparison of this condition would be something like this: 0 equal Total Orders Open (type Buy)

The first thing we need to do is create a parameter that will hold the value 0:


Once this parameter is created we can create our condition. The question Total Orders Open answers us know how many orders are open by type. Let’s create the condition: