Order Opening/Closing Conditions

JedeyeFX Documentation

shp.png

Order Opening/Closing Conditions

Page Sections

There are 12 inputs available, divided into 4 groups, for setting up open and close conditions for both buy and sell orders:

  • Buy Open Condition #1 to #3
    Set of conditions that should be true in order to open a new buy order.
  • Buy Close Condition #1 to #3
    Set of conditions that should be true in order to close currently open buy orders.
  • Sell Open Condition #1 to #3
    Set of conditions that should be true in order to open a new sell order.
  • Sell Close Condition #1 to #3
    Set of conditions that should be true in order to close a currently open sell orders.


Before going into detail about all the supported conditions, let’s analyse how a condition is formed, which condition types are available and how each of them work. The conditions can be build up of indicator values, comparisons between them and special functions. JedeyeFX gives you access to those functions allowing you to make more accurate/complex conditions. First, let’s approach everything about indicator-based conditions.
Check out the following condition building structure:

​indicator_identifier/alias​(indicator_object)comparison_operatorindicator_identifier/alias(indicator_object)
 

As you already know, the indicator identifier or alias identifies the indicator we want to get values from. The indicator object, however, it’s a new concept and it refers to the value we want to get from the indicator. When dealing, for example, with MACD indicator, we need to tell the expert advisor which value we want to get from the indicator, which in this particular case, would be the signal line, the bar or the MACD zero line. In the above structure, there is also a comparison operator, followed by another indicator/object configuration.
The easy way to understand this concept is to imagine the following situation: say we want to open an order every time the MACD signal line gets greater than the MACD bars. In order to achieve this, we need to tell JedeyeFX the first member we want to compare with (in this case, the MACD Signal Line value), followed by the comparison operator (since we want the MACD signal to be greater, we use the > symbol which means "greater than"), and finally the last member we want the first one to be compared to (that is, the MACD Bars value).
Check the Condition Operators Table   to learn more about which comparison operators are supported.


Building up a Condition

Now let’s build a condition, using an indicator setup like this iMACD(0):ma. Note that this must be written in the Indicators Setup   input, otherwise the following conditions we will be making will not work because the indicator they will be using will not be recognized. Check the following condition, noticing that we’ll be using the indicator alias instead of its identifier.

ma(LINE)>ma(BAR)

As you can see, this condition type is made of 3 parts: the ma(LINE) part will extract the Signal Line value (see the LINE object between brackets) from the indicator referred by the ma alias, which in this example is the MACD indicator. Note that every indicator have their available objects listed in the Indicator Properties   section.

The second part we have, is the comparison operator, which in this particular situation, it’s the "greater than" signal (> symbol). This simply tells that the first member needs to be greater than the second one in order to the condition be true. Finally, the last part ma(BAR), will extract the BAR value from MACD for comparison with the first member. Summing up, when we write ma(LINE)>ma(BAR) in Buy Open Condition #1 input, then whenever the MACD signal line value gets greater than the MACD bar value, the condition gets true and a new buy order is open.

By default, and to ensure good performance in complex environments, the conditions we write in the open/close buy/sell condition inputs are evaluated once at each new bar appearing. This behavior can be changed in the EA Behavior section of JedeyeFX inputs, however, it is not recommended. This subject is approached later in greater detail.


Comparing Indicator Object with Fixed Value

We did see previously how to compare an indicator object value against another object. You may want, however, to compare an indicator object with a certain value. There are indicators like ATR (Average True Range) that only have one single object and you may have the need to compare it with a certain numeric value. Using the previously MACD indicator case, say you want to build a condition where opened sell orders are closed whenever the signal line gets above 0.00087 value. This can be written as simple as that:

ma(LINE)>VAL(0.00087)

Notice the new keyword there, VAL. This keyword allows you to put any number inside (floating point values or just integer ones), so that JedeyeFX converts them into comparable members. Like this one, there are many other keywords that allows accessing other properties, but their constructing structure is always the same, just like you see in this example.


Single Member Condition

Until now, you have seen how to extract indicator values and use them to compare with each other. This is possible because all the underlying objects (signal line and bars in MACD indicator, for example) have a value attached to them all the time. Nevertheless, there are indicators where their objects have certain states over time and where their values are not so important but the states they are currently on. Let’s see an example.  Refer to the Volumes indicator illustrated in the following picture.

iVolumes Indicator Chart

As you see, the Volumes indicator have colors indicating the increasing or decreasing of volume through the green and red colors, respectively. This means the bar object can have 2 different states, the green color state (up direction) and the red color state (down direction). Now imagine we want to open an order when the bar turns green (up direction). As you've probably noticed, you cannot make a condition relating two members in order to accomplish this. For such cases, there is the so called single member condition, which as you will see, it’s very simple to understand. Referring to the Volumes Indicator properties listing in the Volumes Indicator Properties   section, we can see there are 2 usable objects (should be considered states, since the object is the same but with different states): UP or DOWN. It is obvious that the state we want to get is the UP one which is when the bars turn green.
Let’s first setup the Volumes indicator by writing iVolumes(0):vol in the Indicators Setup   input. Note that if you already have another indicator set there and you intend to keep it, just add a comma (,) before the Volumes configuration (e.g.: iMACD(0):ma,iVolumes(0):vol). Now, the only thing left to do, is to write the following condition in the Sell Close Condition #1 input, since we previously mentioned that we want the condition we are building to close all sell orders when true:

vol(UP)!

Pay attention to the exclamation mark operator at the end of the member. Everytime we are dealing with a single member condition, it is mandatory to put an exclamation mark at the end. It is just as easy as that.

If you did check the Volumes Indicator Properties  , you may have noticed a third object called VAL. This property cannot be used like this: vol(VAL)!. The VAL property is used in two member comparison conditions, since you may want to extract the value from the bars rather than knowing if they are green or red, up or down. The following configuration can be a valid example of that we are talking about:

vol(VAL)!

 

Mixed Indicators Conditions

If you need, you can use different indicators in the same condition. For example purposes, let’s say that we want to open a buy order whenever the MACD Bar value gets higher than the Volume Bar value. To accomplish this, we only have to put the following condition, considering we still have the Indicators Setup   input with the configuration set in the previous examples (vol is an alias for iVolumes and ma is an alias for iMACD):

ma(B)>vol(VAL)
Keep in mind that the purpose of this example is not to make sense in practical means but only to show you how to use this possibility with your own prefered set of indicators.
 

Logical AND/OR Conditions

JedeyeFX gives you the possibility of combining multiple conditions to build the desired strategy. You may want, for example, that two conditions must be both verified true in order to some event to happen, or on the other hand, at least one of the two, no matter which one of the conditions. In such case we introduce the logical AND (represented by ,) and OR (represented by #) conditions. Everytime you want to deal with more than one single condition you have to put a separator between them. That separator will tell JedeyeFX if conditions must be both true, or just one of them, in order to do something (depending on what configurable input they are inserted into). In order to better understand this concept, the following topics approach the AND and OR condition types with examples.

 

AND Condition Type

Say we want to open a buy order based on two indicators values, from MACD and ATR. We’ll want the MACD bar to cross the zero line in positive direction and at the same time we’ll want the ATR value to be above 0.0012. Note that if one of these conditions fail to be verified true, we want no order to be open.

Considering that, in this example, we'll use the indicators configuration defaults, no alias (since indicator identifiers are short enough and only a timeframe per each is used) and the timeframe of the chart JedeyeFX is attached to, we’ll firstly need to write the following configuration in the Indicators Setup   input:

iMACD(0),iATR(0)


Now we need to build the conditions that will open the buy order, when all of them are true. We will come to something like this:

iMACD(BAR)>VAL(0),iATR(LINE)>VAL(0.0012)


This should be set in the Buy Open Condition #1.

Notice how the two conditions are joined by a comma (,) which represents the logical AND connector. When the expert is evaluating the conditions, it will start by the first one - iMACD(BAR)>VAL(0). If this condition is not true, it does not proceed to the next condition (the ATR one) and skips the whole verification process, considering that at least one condition failed to be true (which in this case is the first one). If, on the other hand, the condition is proven to be true, then JedeyeFX proceeds to the next one - iATR(LINE)>VAL(0.0012) - and checks if it is true as well. If it fails to be true, the expert advisor cancels the verification process and no order is open. If true and given that this is the last condition to be evaluated, JedeyeFX gets a signal for opening a new buy order and proceeds with it.

 

OR Condition Type

In the previous example, we saw that a set of conditions separated by a comma (,) implies that all the conditions need to be true in order to get a signal for triggering a certain event (which was opening a buy order). Sometimes, however, you may want to be more abstract and tell JedeyeFX that, from all the conditions, having at least one of them being true must be enough for opening/closing an order. This can be done by applying a conditional OR, represented by a # symbol instead of a comma (which represents the AND condition type instead).

Returning to the previous example, the very same configuration (set of conditions) would turn into this:

iMACD(BAR)>VAL(0)#iATR(LINE)>VAL(0.0012)


As you may have noticed, the only change made was the replacement of the comma (,) by the sharp symbol (#). Basically, this line can be translated into the following logic: iMACD BAR VALUE IS GREATER THAN 0 OR iATR LINE VALUE IS GREATER THAN 0.0012. Therefore, if MACD bar passes above zero line, an order is open. If this is not verified, then if the ATR line value passes above 0.0012, an order is open. The same happens whenever both conditions are true (only one buy order is open per condition set, not per each checked condition).
 

Mixed Conditions and Logical Priorities

In the previous topic, you did learn how conditions can be logically joined to each other, using AND or OR conditional operators. JedeyeFX also offers mixed conditions functionality allowing you to build more complex conditions for your events. Thus, the expert advisor allows you to mix AND with OR conditions, just like this:
iMACD(BAR)>iMACD(LINE)#iMACD(BAR)>VAL(0),iATR(LINE)>VAL(0.0012)#iATR(LINE)>VAL(0.0020)

Regarding priorities, note that the expert separates conditions by the # (OR) symbol first, so it will evaluate iMACD(BAR)>iMACD(LINE) in first place, then if the previous fails it will evaluate iMACD(BAR)>VAL(0),iATR(LINE)>VAL(0.0012) and lastly, if this one fails, it evaluates iATR(LINE)>VAL(0.0020).

As you may have already noticed, there are condition inputs which are numbered from 1 to 3. They are there to ease the introduction and reading of long conditions. Buy Open Condition #1, Buy Open Condition #2 and Buy Open Condition #3 are some of those inputs and all of them have a logic operator attached to them, the OR operator. Say we set the previous inputs as follows:

  • Buy Open Condition #1: iMACD(BAR)>iMACD(LINE)
  • Buy Open Condition #2: iMACD(BAR)>VAL(0),iATR(LINE)>VAL(0.0012)
  • Buy Open Condition #3: iATR(LINE)>VAL(0.0012)
 

This is basically the same as having only this line:

  • Buy Open Condition #1:  iMACD(BAR)>iMACD(LINE)#iMACD(BAR)>VAL(0),iATR(LINE)>VAL(0.0012)#iATR(LINE)>VAL(0.0012)

As you can see, all Buy Open Conditions from 1 to 3 are joined by a # symbol (logical OR). In case you use simple conditions or logical AND joined conditions only, you will likely just fill the first input of each Buy or Sell Condition Input group. However, for long and complex conditions or just simple OR joined conditions, this kind of structuring may be handy to avoid having long lines in the very same input (since most part will stay hidden in the expert’s configuration window).
 

Trigger and Confirmation Conditions

Now that you learned how to build you own indicator-based conditions it is important to learn about two new concepts about them. There are Trigger Conditions and Confirmation Conditions. In practical terms they are basically the same, the only difference between them are the order they are put at and the behavior they’ll have due to be disposed by such order. So a Trigger Condition is the condition that triggers an event only once when it turns true, and that will trigger another event again only after a change of status (after being true, condition gets false and true again). It is the condition that JedeyeFX will look at in first place to check if the first environment status requirement set was achieved. Therefore, it is the first condition you set (pay attention to the order). A Confirmation Condition is any condition that, added to a trigger condition, adds additional verification to it. It is every condition but the first one (which, as already said, is the trigger condition). While it may seem a little bit confusing at first sight, these concepts are very easy to understand as you will see in the next topics.
 

Trigger Conditions

Let’s see an example using the MACD indicator. Say we want to open a sell order whenever the MACD signal line crosses the MACD bar value. So, we come up with the following configuration:

iMACD(LINE)>iMACD(BAR)


As said before, by default the expert advisor evaluates conditions at each new opened bar. Imagine that the signal line reaches the point where its value gets higher than the bar value. So, without the trigger condition concept, here’s what would happen: since the condition iMACD(LINE)>iMACD(BAR) is met, a new sell order is open. Then, at a new bar, JedeyeFX evaluates all conditions again. Since the MACD signal line value is getting higher, the condition stills true, thus a new sell order is open, and so on. While the condition is true, orders are being open sequentially until the signal line value gets lower than the bar value, which may take a long time. This is definitely not what you want. You want the expert advisor to open a sell order once whenever a condition is met (signal line gets higher than bar) and to open again only after a change of status (signal line gets lower than bar and then gets higher than it again). This is what a Trigger Condition is for. It ensures that no orders are opened while the conditions are still the same from chart's bar to bar. In the following configuration, trigger conditions are highlighted in green color:

iMACD(BAR)>iMACD(LINE)#iMACD(BAR)>VAL(0),iATR(LINE)>VAL(0.0012)#iATR(LINE)>VAL(0.0020)
 

Every trigger condition is always the first condition (regarding its order) in a AND logical configuration (separated by a ,). In the configuration above, iATR(LINE)>VAL(0.0012) is a Confirmation Condition.

 

Confirmation Conditions

A Confirmation Condition is every condition that is not a Trigger Condition, that is, conditions that restrict further the Trigger Condition.
Take this example for opening a buy order:

iMACD(LINE)<iMACD(BAR)


This is a simple trigger condition that tells the expert to open a buy order each time the MACD signal line value gets lower than the MACD bar value. This condition, however, may happen when the signal line is above or below the MACD zero line. Due to the fact that you want to open the buy order only when averages get down to their minimum, you need then add a restriction, a confirmation condition that tells JedeyeFX that the trigger condition needs to happen below the MACD zero line. This is what this Confirmation Condition may look like: iMACD(LINE)<VAL(0). Now you just need to add it to the Trigger Condition with a conditional AND (,), like this:

iMACD(LINE)<iMACD(BAR),iMACD(LINE)<VAL(0)

You can add as much confirmation conditions as you want in order to achieve accurate results.