You may refine your WHEN statement using any of the following buttons.
| Button | Function | Description | ||
|---|---|---|---|---|
![]() | Logical Operators | Multiple WHEN conditions in your query can be linked together into a complex condition using the And, Or, Xor, And Not, Or Not, Xor Not logical operators. | ||
![]() |
| Use the settings in the Date Time Condition window to set either historical date criteria or a particular time or range of time during the trading day. | ||
![]() |
| Use the Custom Event settings to search for conditions, events and patterns in price series. This menu is often used to specify certain market conditions. | ||
![]() |
| These are predefined events created by LIM. | ||
![]() |
|
| ||
![]() |
|
|
Multiple WHEN conditions in your query can be linked together into a complex condition using And, Or, Xor, And Not, Or Not, Xor Not logical operators. The system by default uses AND after selecting the first condition, simply select WHEN condition again to construct your second condition. AND will automatically be displayed between the two conditions. This means both conditions must be met for the WHEN to make the compound WHEN statement true.
If you wish to connect your conditions with any of the other logical operators select the appropriate one from the Logical Operator menu located in the WHEN pane of the Query Builder window.
Here are the operators and their meanings for condition statements A and B:
Example:
WHEN "Condition A " And "Condition B"
A and B must both be true for the statement to be true.
Example:
WHEN "Condition A " Or "Condition B"
If either A or B is true, the statement will be true.
Example:
WHEN "Condition A " Xor "Condition B"
Statement is true when A or B is true, but not when A and B are true.
Example:
WHEN "Condition A " And Not "Condition B"
Statement is true only when A is true and B is false.
Example:
WHEN "Condition A " Or Not "Condition B"
Statement is true when A is true or B is false. (Statement is false only when A is false and B is true.)
Example:
WHEN "Condition A " Xor Not "Condition B"
Statement is true when A and B are both true or A and B are both false.
The following shows how to refine your query using date and time conditions.
In the WHEN statement pane of the Query Builder, select the Date Time Condition button. A Date Time Condition window displays. The date settings within the Date Time Condition window restrict your query search and analysis to a specific time period of dates.
When installing XMIM on the server, the system administrator may setup either a U.S. or European version of XMIM. The XMIM version installed will determine the date files that display; U.S. versus European holidays and date files. For more information on installing the XMIM versions, see the Client Application Installation Guide. |
From the Date Time Condition window select the Date or Time button then make a date criteria selection from one of the following choices from the pull-down list:
Date is
Date is not
Date is before
Date is after
Time is
Time is not
Time is before
Time is after
After making a date criteria selection the following choices display. For this example, Date is was selected from the pull-down list:
The following details the choices available from the Date Time Condition window.
Table: Date Time Condition Window Description (Date Condition)
![]() | Choose from: Date is, Date is not, Date is before or Date is after. (Also listed are: Time is, Time is not, Time is before or Time is after. For more information see the section called “How to Create a Time Condition”.) The date settings may be used to anchor a specific date such as December 6, 1996 or August 19, 1994. Use Date is to include only this date in your condition or Date is not to exclude the date entirely or Date is after to select all dates following the date or Date is before to select all dates proceeding the date. |
![]() | Time Offset button - for more information see the section called “Time Offset” |
![]() | Choose one of the date entries from the pull-down list. See the section called “Date Definitions” for a description of the following choices:
|
![]() | Choose a number to specify the length of the date period. |
![]() | Choose a Date period (Day, Week, Month, Quarter, Year, Calendar Day, Calendar Week, Calendar Month, Calendar Year). |
![]() | Add Condition button - Select this button to add a logical operator and another date or time condition. For more information on logical operators see the section called “Logical Operators ”. |
![]() | Refresh Condition button - Select this button to set the window back to the default settings. |
The following are examples of various date conditions.
The example below will show the close of the 30-year Treasury Bond futures contract for one period in time, August 30, 1990.
SHOW
1: Close of US
WHEN
Date is 8/30/90The example below will show the close of the 30-year Treasury Bond futures contract for all Mondays, Tuesdays and Wednesday historically for as far back as XMIM has data for the contract.
SHOW
1: Close of US
WHEN
Date is from Monday to WednesdayThe example below will show the close of the 30-year Treasury Bond futures contract for all contract expiration days.
SHOW
1: Close of US
WHEN
Date is US expiration_dayThe example below will show the close of the 30-year Treasury Bond futures contract for all dates when the Federal Open Market Committee (FOMC) met and decided to tighten interest rates (increase interest rates).
SHOW
1: Close of US
WHEN
Date is in "FOMC/fomc_tighten.rpt"The following describes the choices from the
![]()
button in the Date
Time window. Each selection will change the menu
display.
The third selection available in this section may be used to capture those dates within some period of time relevant to the last data day (the last updated date having data associated with it). This feature is particularly useful in creating daily pricing graph series for your securities of interest for the last week, month, quarter, etc. without having to continuously update the period of interest.
See the example below.
SHOW
1: Close of CAD
WHEN
Date is within 1 monthThe example above will return the closing price of the Canadian dollar in U.S. dollar terms for the entire month leading up to the last data date or yesterday.
Select Exactly and enter the date in the field provided.
The following shows an example.
SHOW
1: Close of IBM
WHEN
Date is 1/3/2007Dates assigned to variables may be referenced by using the Variable selection and entering a variable name in the field provided.
In the example below, the second query
block references the date variable (lastHit = current
date) established within the first query block. This
example allows users to identify a certain date meeting conditions
and thereafter use this shorthand reference without having to type
out all the conditions associated with some particular
date.
SHOW
1: move from today to 10 days later of Close of US
WHEN
Date is within 1 year
AND
5 day average of US crosses above 35 day average of US
AND
lastHit = current date
SHOW
2.1: move from today to 10 days after daily Close of US
WHEN
Date is date:lastHitThe From/To option may be used to capture those dates that are bounded by conditions defined by the From Date: and the To Date: expressions (both expressions defined as dd/mm/yy).
The example below will return the closing price for the U.S. Treasury Bill, 3-month Futures contract series for those dates falling between August 30, 1990 and January 1, 1991.
SHOW
1: Close of TB
WHEN
Date is from 8/30/90 to 1/1/91The From/To option may also contain parameters other than the generic calendar expression "dd/mm/yy". Any date expression contained within the Date Time window may be used as a date parameter.
The example below will return the closing price for the S&P 500 Stock Index Futures contract series for those dates falling between Monday and Wednesday (excludes Thursday and Friday closing prices).
SHOW
1: Close of SP
WHEN
Date is from Monday to WednesdaySelect In the Date Range then select the Start Date and End Date buttons and complete the fields.
The On Day, In Month, In Quarter and In Year expressions may be used to anchor certain calendar periods of time. These expressions are particularly useful to construct seasonality studies (i.e. What happens to the price of certain agricultural futures contracts during harvesting season). On Day, In Month and In Quarter selections are made from the menus associated with each respective category. The In Year expression requires selection or input of a year in the adjacent text field box.
The example below will return the unrevised Nonfarm Payroll number for every release date occurring after 1989.
SHOW
1: NONFARM_ACT
WHEN
Date is after 1989There are two selections available:
local file - Select the Browse button to choose a local file on your system that contains date events. Select the file then select the OK button to add the date event to your Date Time Condition window.
server file - Select the Browse button to open the Date Events window. Open the folders to highlight the desired date event then select the OK button. The date event is added to the Date Time Condition window. For more information on date events, see Appendix: Date Events.
The n Units Open and n Units Close expression enables users to anchor certain opening or closing periods, where n represents a number and Units represents a calendar expression such as week.
The example below will return the closing price for the U.S. Treasury Bond 30-year Futures contract for the opening day of the week (i.e., Monday).
SHOW
1: Close of US
WHEN
Date is weekly Open The Recurring Date selection enables users to anchor certain periods within a calendar range.
This Recurring Date
selection enables users to anchor certain periods within a
calendar range. For the Every Nth Unit of
Unit selection, Nth represents a
number and Unit represents a
calendar expression such as Day of the Week.
The example below will return the closing price for the Natural Gas Futures contract for the first day of the week.
SHOW
1: Close of NG
WHEN
Date is 1st day of the week This Recurring Date
selection enables users to anchor certain periods within a
calendar range. For the Every Last Unit of
Unit selection, Unit
represents a calendar expression such a Day of the
Week.
The example below will return the closing price for the Natural Gas Futures contract for the last day of the week.
SHOW
1: Close of NG
WHEN
Date is last day of the week This Recurring Date
selection enables users to anchor certain periods within a
calendar range. For the Every Nth to Last
Unit of Unit selection n
represents a number and Unit
represents a calendar expression such as Day of the
Month.
The example below will return the closing price for the Natural Gas Futures contract for every third to the last day of every month.
SHOW
1: Close of NG
WHEN
Date is 3rd to last day of the month Known dates are holidays, semi-holidays, special events, elections periods, and Profit and Loss Trade dates. These known dates and their usage are described in the sections below.
From the menu select Any>Holiday or Any>Semi-Holiday.
The following query example shows how stocks react the day after a holiday.
SHOW
1: percent_move from today to 1 day later of Close of SPX
WHEN
Date is 1 day after any holidayThe Holiday selection enables users to anchor all holidays to construct event driven research centering around holiday dates.
The example below will return the 1 week move the of the closing price of the Japanese yen in U.S. dollar terms for the week leading up to New Years Day.
SHOW
1: 1 week move of Close of JPY
WHEN
Date is New Years Day The Semi-Holiday selection enables users to anchor all semi-holidays to construct event driven research centering around semi-holiday dates.
The query example below shows the use of the Semi-Holiday selection.
SHOW
1: percent_move from today to 7 values later of DJIA
WHEN
Date is 2 days after Columbus Day
AND
4 value percent_move of DJIA is less than -3The Special selection enables users to anchor either a generic Expiration Day, which is defined as the third Friday of every month, or the Triple Witching Day, which is defined as the third Friday of the month at the end of a quarter. These conditions may apply to "All" months or certain identified months.
The example below shows how stocks react in the week leading up to the July Options Expiration.
The expiration date refers to Options expiration whereas the Symbol Event (see the section called “Symbol Event ”) expiration refers to specific futures expiration. |
SHOW
1: percent_move from today to 5 values later of DJIA
WHEN
Date is 1 week before July Expiration DayThe example below shows how stocks may perform as they approach a Triple Witching Day.
SHOW
t+6: percent_move from today to 6 values later of SPX
t+8: percent_move from today to 8 values later of SPX
t+10: percent_move from today to 10 values later of SPX
t+11: percent_move from today to 11 values later of SPX
t+23: percent_move from today to 23 values later of SPX
WHEN
Date is 5 days before Triple Witching Day
AND
Date is after 6/12/2000The Election selection enables users to anchor certain U.S. Presidential date criteria such as Presidential Election Years, Midterm Election Years, Presidential Election Days and Years where the Presidential Office was controlled by either the Republican or Democratic Parties.
The example below will return the daily range of the Treasury 30 year Bond Yield for Presidential election.
SHOW
1: range of USC30
WHEN
Date is Presidential Election dayThe P/L Trade selection enables users to anchor dates associated with certain entry or exit criteria contained in an ORDER block query preceding the SHOW/WHEN query containing this condition.
The example below involves the use of two query blocks that when combined will return the dollar move from the original entry date of the ORDER block to 1 week later for the closing price of the US 30 year Treasury Bond Futures contract.
1: ORDER
1.1: Buy 1 contract of US
WHEN
Close of US crosses above 1 month average of Close of US
EXIT
Close of US crosses below 1 month average of Close of US
SHOW
1: move from today to 1 week later of Close of US
WHEN
Date is original_entry_date
The Symbol Event selection
allows users to anchor dates associated with certain securities
dates such as a futures contract expiration day or the first or
last data day available in the MIM database for a select security.
This date function requires either selection of a symbol and
column using the Search Database
![]()
icon or entering a symbol name and column
name into the text fields. The following lists the possible
choices for event types:
Expiration
Last Trading
First Data
Last Data
The example below shows the
Close of
GII.IBM.NYSE on the first data day (first
data point available in history) that is in the MIM.
SHOW
1: Close of GII.IBM.NYSE
WHEN
Date is Close of GII.IBM.NYSE first_data_dayThe example below will return the one week price move for the S&P 500 Stock Index Futures leading up the expiration day of the contract.
SHOW
1: move from 1 week ago to today of Close of SP
WHEN
Date is SP expiration_dayThe expiration in the example above refers to specific futures expiration whereas the example in the section called “Special ” refers to Options expiration. |
In the WHEN pane of the Query Builder select the Date Time Condition button. A Date Time Condition window will appear for your selection of either generic time or special market time criteria. The time portion of the Date Time Condition window is used to restrict your query search and analysis to a specific period of time during the trading day.
Remember that XMIM's default Execution Units settings are set to a daily default. When using intraday conditions it will be necessary to set your units to something less than a daily setting (i.e., hourly pricing bars).
Notice the default selection criteria highlighted in the Date Time Condition window are the "Time is" button and the current "Time:" (hh:mm pm/am/military time) located in the first section of the window. Selection criteria within the Date Time Condition window are grouped with criteria of a similar nature. Notice the first section consists of the selection criteria: "Time:", "From Time:/To Time:" and "From/To". This first section may be considered "generic time" criteria (i.e. Time is 8:30 am) whereas last two sections within the Date Time Condition window represent "special market time" criteria (i.e., Time is Daily Open or US Start Trading Time).
When creating any date or time condition, you must first select the Date or Time button then select from one of the following choices:
Date is
Date is not
Date is before
Date is after
Time is
Time is not
Time is before
Time is after
After making a time criteria selection the following choices display. For this example, Time is was selected from the pull-down list:

The following details the time entries available from the Date Time Condition window.
Table: Date Time Condition Window Description (Time Condition)
![]() | Choose from: Time is, Time is not, Time is before or Time is after. (Also listed are: Date is, Date is not, Date is before or Date is after. For more information see the section called “How to Create a Date Condition”.) The time settings may be used to anchor a specific time such as December 6, 1996 or August 19, 1994. Use Time is to include only this time in your condition or Time is not to exclude the time entirely or Time is after to select all times following the time or Time is before to select all times proceeding the time. |
![]() | Time Offset button - for more information see the section called “Time Offset” |
![]() | Choose one of the time entries from the pull-down list. See the section called “Time Condition Definitions” for a description of the following choices:
|
![]() | Specify the time period. |
![]() | Specify am or pm. |
![]() | Add Condition button - Select this button to add a logical operator and another date or time condition. For more information on logical operators see the section called “Logical Operators ”. |
![]() | Refresh Condition button - Select this button to set the window back to the default settings. |
The following is an example of a query using a time condition:
SHOW
1: High of US
WHEN
Time is 12:00 pmAssuming that the Execution Units (select the Execution Units ![]()
button from the toolbar) are set to 1 hour,
the example above will return the hourly high price for the 30-Year
U.S. Treasury Bond Futures contract when the time is 12:00 pm noon
at the Chicago Board of Trade (notice that time is specific to the
time relevant to where the security is traded).
The exactly setting in the Date Time Condition window may be used to anchor a specific time such as 8:30 am. You may use the proceeding clause button Time is to include only this time period in your condition or Time is not to exclude the period of time entirely or Time is after to select all time periods following the set time or Time is before to select all periods of time proceeding the set time.
Periods of time may be assigned to variables and referenced by using the variable selection in the Date Time Condition window.
The from/to option located in the Date Time Condition window may be used to capture those periods within a day that are bounded by conditions defined by the From Time: and the To Time: expressions (both expressions defined as hh:mm am/pm/military time).
The in the time range selection in the Date Time Condition window is very similar to the from/to selection discussed above with the exception that the expression may contain parameters other than the generic time criteria expression "hh:mm". Any time period expression contained within the Date Time Condition window may be used as a time parameter.
The daily open and daily close selections in the Date Time Condition window may be used to capture the daily open or close for a specific security. XMIM has the ability to capture the daily open or close to form a time condition within your query. The time representing open or close will vary depending on where a security is traded (either the exchange where a security is listed or the dominant market for an OTC or over the counter security).
The first unit of trading and last unit of trading selections in the Date Time Condition window may be used to capture and anchor important periods surrounding the open or close for a particular security.
The P/L trade selection in the Date Time Condition window enables users to anchor those periods of time associated with certain entry or exit criteria contained in an ORDER block query (discussion to follow) proceeding the SHOW/WHEN query containing this condition. This function is a powerful tool to analyze the results of a back-tested trading strategy using the ORDER query.
The start trading time of and end trading time of selections in the Date Time Condition window enables users to anchor the daily open or close for a specific security. This time criteria is used in lieu of the Daily Close/Open where multiple securities are used within a query. This function avoids the problem associated with using multiple securities within a query using a time condition by anchoring a particular symbol's starting or ending time.
There are many places in the XMIM query language where Attributes can be selected for use. The SHOW part of a SHOW-WHEN query is a typical place to use an attribute expression. Often you are trying to produce results (attributes) based upon certain conditions or patterns in the market. In order to do this, it is necessary to reference or compare the attribute to some other attribute or constant by creating a WHEN condition. Stated another way, users often want to SHOW an attribute WHEN the attribute has reacted in some specified pattern. For example, SHOW the daily bar of the 30-year Treasury Bond futures contract WHEN the contract closes above the previous day's close by $1. In the example, the contract must close above the previous day's close in order to fulfill the condition. The attribute used to create this condition is the closing price of the contract or Close of US in XMIM syntax. Conditions may be built by selecting the Custom Event button from the WHEN pane of the Query Builder window.
The Custom Event's general format is as follows:
<Left Attribute> <Conditional Operator> <Right Attribute>
The format is some specified Attribute, i.e., Close of US (Left Attribute) does something in comparison to, i.e., Is more than (Conditional Operator) some other specified attribute, i.e., Yesterday's close or Close of US 1 day ago (Right Attribute). In some instances it is possible to form a complete Condition simply using the <Left Attribute> and the <Conditional Operator>. XMIM will prompt you for input for all required windows.
To create a custom event, enter the information for the Left Attribute then select the Continue button to activate the Conditional Operator pane in the Custom Event window. After selecting a conditional operator select the Continue button and enter the information for the Right Attribute. If needed, use the Back button to return to a previous pane in the Custom Event window.
The following details the settings in each pane of the Custom Event window.
After selecting the symbol and column (or any other items of interest from this window), select Continue to exit the Left Attribute pane of the Custom Event window. The Conditional Operator pane of the Custom Event window will become active.
The Conditional Operator pane
in the Custom Event window allows you
to compare the value of a security (selected in the Left Attribute) against different values of the
same security (selected in the Right
Attribute). For example, Open of DJIA is more than
Close of DJIA. In addition, the Conditional Operator window allows you to
compare the value of a security (selected in the Left Attribute) against the values of a
different security (selected in the Right
Attribute). For example, Close of S (daily
Close of the Soybean futures contract) is less than Close of
SM (the daily Close of the Soybean Meal futures contract). You
may also compare the value of a security against a constant or
percentage (Close of SP is up more than 30 or Open of IBM is
down more than 2). The Conditional Operator features are
described below.
This option of the Conditional Operator poane of the Custom Event window allows you to select 10 different combinations of comparison operators with which you can compare two Attributes. The Conditional Operator defaults to the choice of is exactly. The first pull-down menu choice is between is and is not. Either selection (is/is not) may then be combined with the next pull-down menu which contains the following choices:
exactly (same as "=" or equivalence)
more than (same as ">" or "greater than")
less than (same as "<" or "less than")
at least (same as ">=" or "greater than or equal to")
at most (same as "<=" or "less than or equal to")
Selection of two choices in the top line of the Conditional Operator pane of the Custom Event window and selection of Continue will prompt the Right Attribute pane of the window to activate for further selection. The Right Attribute pane, which looks just like the Left Attribute pane, will be displayed for selection of the second comparison value.
The Right Attribute pane provides the same options as the Left Attribute pane and the SHOW portion of the Query Builder window.
There are various ways to apply the IS or IS NOT Conditional Operator within a query. Perhaps you want to create a WHEN condition that detects those days that a price series is down 2 points from the previous day. There are at least three ways to state this in the When condition.
For example:
SHOW
WHEN
IBM is down more than 2
Or
SHOW
WHEN
1 day move of IBM is less than -2
Or
SHOW
WHEN
IBM is less than IBM 1 day ago – 2 Clearly the first example is the easiest to implement.
The second option in the Conditional Operator pane allows you the choice of either crosses above or crosses below. Perhaps you wanted to set a condition that would locate days when the price of a stock crosses below a moving average of the price of the stock. This can be accomplished by using the crosses below operator from the Conditional Operator area as shown below:
The crosses above or crosses below condition is especially useful for comparing values, oscillators, upper and lower reference lines, and moving averages. This condition pinpoints the exact time when the event happens. For example unlike the conditional operator, is more than, crosses above will only satisfy the condition for the first value which crosses above some specified threshold. All other values falling above the threshold, which follow the first value that satisfies the condition, will be ignored unless some preceding value crosses back below the threshold. In other words in order to satisfy the conditional operator, crosses above, the value must be the first in some sequence to cross above a threshold. In order to re-satisfy the condition, values must fall below or cross below before again crossing above the threshold.
Example:
SHOW
1: Close of US
WHEN
Close of US crosses above 123.25Using the following values represent the Close of
US. Notice that our condition is first satisfied on
01/09/1998 (the Close is above the threshold). However, 01/12/1998
does not satisfy the condition because the Close of US
must cross below 123.25 in order for it to close above again. On
01/14/1998, the Close of US crosses below 123.25 so the
next value crossing above 123.25 would satisfy the condition. Notice
that if we used the Conditional Operator 'is more than'
(WHEN Close of US is more than 123.25) our
condition would have been satisfied on 01/09/1998, 01/12/1998 and
01/13/1998.
01/01/1998 Thu NaN 01/02/1998 Fri 121.4688 01/05/1998 Mon 122.9063 01/06/1998 Tue 123.0000 01/07/1998 Wed 122.2500 01/08/1998 Thu 122.8438 01/09/1998 Fri 123.6563 01/12/1998 Mon 123.7188 01/13/1998 Tue 123.5313 01/14/1998 Wed 123.1875 01/15/1998 Thu 123.0313 01/16/1998 Fri 122.3125
The following are other examples of the type of WHEN conditions that can be created using the crosses above or crosses below Conditional Operator option:
5 day average of BP crosses above 10 day average of BP Longitude of MARS crosses below Longitude of JUPITER US crosses below 20 day average of US 1 day ago SF crosses above 50 day highest of High of SF 1 day ago
The third option of the Conditional Operator pane in the Custom Event window allows you the choice of either is defined or is not defined. The Conditional Operator option allows you to test whether a value exists for a specified attribute. An attribute is not defined whenever the results of execution of your query would be NaN (Not a Number), i.e., If there is no value in the database for your specified attribute.
Example:
SHOW
1: Close of IBM
WHEN
Close of IBM is DEFINEDThe example above would SHOW the Close of IBM for every date that had a value for the close associated with it. The following example would produce a list of dates when there is no trading in IBM stock, due to a holiday, or missing data:
SHOW
WHEN
Close of IBM is not defined The fourth option allows you to use a shorthand option to test a condition where the move of your left attribute is positive or negative. A move study is applied to your left attribute in the background so the syntax that would normally be used to calculate the move (1 day move of BP) is not shown and is not necessary.
Example:
SHOW
1: BP
WHEN
BP is upis equivalent to:
SHOW
1: BP
WHEN
1 day move of BP is more than 0A common mistake is to use this Is Up / Is Down option on a Left Attribute that already has a move study applied when the user intends to study the move of the close.
Example:
SHOW
1: BP
WHEN
1 day move of BP is upThis syntax is actually studying the 1 day move of the 1 day move of BP since the “is up” applies a move study in the background.
You might recall that we said earlier that in some instances it is possible to form a complete condition simply using the <Left Attribute> and the <Conditional Operator>. This is one of the two options available in the Conditional Operator pane where it is possible to complete a condition without using the Right Attribute pane of the Custom Event window.
The last option in the Conditional Operator pane allows you to use various shorthand options for the quantifying the change in value of an Attribute (either expressed in constant or percentage terms).
Users commonly test to see whether the move or percent move of an attribute has met some level of significance. XMIM provides a shorthand approach for creating this type of condition. Using the Constant field in the Conditional Operator pane, a user may condition the move of an attribute. Likewise, using the Percentage field a user may condition the percent move of an attribute. This is the second option in the Conditional Operator pane where the Right Attribute is not necessary.
The following are examples of the type of WHEN conditions that can be created using this Conditional Operator option:
SHOW
1: BP
WHEN
BP is up more than 3is equivalent to:
SHOW
1: BP
WHEN
1 day move of BP is more than 3or
SHOW
1: BP
WHEN
Close of BP is down more than 3is equivalent to:
SHOW
1: BP
WHEN
1 day move of Close of BP is less than -3or
SHOW
1: BP
WHEN
Close of BP is down more than 1 %is equivalent to:
SHOW
1: BP
WHEN
1 day percent_move of Close of BP is less than -1The first two options of this Conditional Operator pane and one of the text fields (either Constant or Percentage) require selection in order to form a complete condition. One of the following options from the left-most drop-down menu must be selected:
"is up"
"is down"
"is not up"
"is not down"
Following selection of the left-most operator, you must select one of the following in the next drop-down menu:
"exactly" (same as "=")
"more than" (same as ">")
"less than" (same as "<" )
"at least" (same as ">=")
"at most " (same as "<=")
Finally, you have the option of either typing the value of the
move you are looking for into the Constant field or typing the value of the
percent move into the Percentage
field. It is not necessary to type a percent sign into
the Percentage field. If the
percentage you wish to compare is 5%, then simply type
5 into the field.
There are a few assumptions XMIM will make for this
Conditional Operator option. The most notable assumption is the
price your attribute is compared to. Notice, if you select the Move
comparison is up, for example, and
the quantity being compared is a basic price (Open, High, Low,
Close), this price will be compared against the Close of the current
time period. If the Execution Units
are defaulted to daily then yesterday's Close will be
used for comparison. If, however, the Execution Units are set to 1
hour the previous time period's close or the close 1 hour ago
will be compared.
For example:
SHOW
1: BAR of SP
WHEN
Time is 12:00 pm
AND
Close of SP is up more than 1The condition will be satisfied when SP is up
more than 1 over yesterday's Close not the last hour's Close (even
though we've specified 12:00 p.m., the Execution Units are set to
daily).
If the Execution Units are not daily but weekly:
SHOW
1: BAR of SP
WHEN
Open of SP is upThe results will show all occurrences when SP
opened higher than the previous week's Close.
This Conditional Operator option may include an optional time period restriction for further refinement of the database search. By selecting the Time Period button you may select a time period range to restrict your comparison condition. XMIM will default to a 1 day comparison unless otherwise restricted using this feature. Upon selection of the Time Period button the following choices are available:
n Time Units (type in the number (n) and select the Time Units of choice (daily, weekly, monthly, etc.)
From/To buttons (These buttons allow you to specify exactly the ending and starting points of the window by making selections from the pull-down menu. The selections available for either button are: Today, Begin of Time/End of Time, Time Offset or Condition.)
Select OK to exit the Custom Event window.
Market Events are pre-defined WHEN conditions that can easily be added to the query. You can refine your query using the market events available by selecting the Market Events button located in the WHEN pane of the Query Builder window. For a description of the market events, see Appendix: Market Events.
The Market Events list also contains condition server macros that can be edited by the user. For more information on editing the condition server macros see Appendix: XMIM Macro Language. |
In the WHEN pane of the
Query Builder, select the If-Then-Else ![]()
button. The If-Then-Else condition is used to
restrict your query search and analysis to selected conditional
conditions.
The If-Then-Else condition lets you refine your study by assigning certain conditions to your study based on defined contingencies. It creates a logical structure so that if the condition in the 'If 'clause is true, the conditional statement represented by the 'Then' clause is assigned to the Condition, otherwise the conditional statement in the 'Else' clause is assigned. As mentioned earlier, If-Then-Else statements can be nested, so that a complex If-Then-Else condition can be constructed.
The If-Then-Else structure allows you to create a condition whose values over time will depend on the condition set forth in the If clause. For additional information please see the section called “If-Then-Else in SHOW Statement” on the use of If-Then-Else statements for creating attributes.
In the If-Then-Else Condition window when you select the Condition button there is a menu selection for Server Macros. This list contains various condition server macros for your further selection. Condition server macros used as conditions will produce true and false values rather than numeric values and can be used in places in the language where a condition would normally appear.
Also available in the If-Then-Else Condition window when you select the Condition button is a menu selection for Client Macros. Any condition macro created by the user will display under Client Macros. For more information on creating client macros see Appendix: XMIM Macro Language.
For a description of the market events including these condition server macros see Appendix: Market Events.
Macros may have arguments such that the macro can be applied to different securities, for different time periods, etc. When a condition server macro is selected, a new window will be displayed from which the arguments associated with the macro may be specified. For example, selecting the InsideDay macro requires further selection of the security of interest for this condition (i.e., InsideDay will return a true or false 'reading' for a particular security whenever the high today is less than or equal to high 1 unit ago and low today is greater than or equal to the low 1 unit ago).
Macro arguments to be defined by users can be one of five different types:
Series (relation symbols such as IBM, US)
Attribute (any attribute expression such as Close of IBM, 6 day average of Close of US)
Constant (e.g., 3.146 or 'orb' pictured above)
Time Offset (e.g., 3 days ago, 1 year later)
Time Period (e.g., From 2 days ago to Today)
Constant-type arguments will appear as an argument name followed by a text type-in field in which the appropriate value may be entered. Other arguments will appear as buttons which, when selected, will bring up an appropriate window (depending on the argument type) where the argument may be specified.
When an argument has been specified, the argument button will appear highlighted. If default values for arguments were specified when the macro was created, the arguments will initially appear highlighted with the associated default values selected. An argument that has already been specified can be changed by simply re-selecting the button and assigning a new value.
The powerful features of XMIM can be used more easily and efficiently by using a few short-cut functions within your queries. The most notable of XMIM's time saving functions are the 'Repeat' function and 'LET' command. This chapter focuses on the Repeat function.
The Repeat statement may be selected as an extension to both the SHOW Attribute as well as the WHEN condition. This time saving feature is selected when you wish to repeat the SHOW Attribute or WHEN Condition statements for a continuous period of time.
The Repeat function is used most often in the WHEN condition of a query. For a Repeat in a WHEN condition, use the Repeat button to access the Repeat menu. A Repeat in the SHOW statement of a query must be entered directly into the Edit pane of the Query Builder using the correct query syntax. |
When selected as an extension to the WHEN condition, the Repeat feature adds an additional level of search criteria which must be satisfied for your query. The Repeat function may be used to repeat Daily/Tick conditions and Client or Server Macro conditions.
All Repeat functions used in the WHEN condition allow you to create a condition that must be repeated a certain time period (repeated for previous 10 days), or a condition that will repeat at least a certain number of times in a specified time period (i.e. repeated 3 times in the previous month).
The default Repeat category is the Previous/Current/Next Period category. The selection criteria available for the Previous/Current/Next Period category include specification of periods Previous to the Condition date specified within your query, the Current or Condition date and the Next periods following the Condition date.
The Condition button located in the bottom right corner of the Previous/Current/Next Period window allows you to set up a Repeat function over irregular date event intervals.
Example:
WHEN
Close of IBM is more than Close of IBM 4 days ago
repeated for the previous 1 to the next 8 daysThis condition will only be satisfied when IBM closes higher than the close of IBM 4 days ago for 9 days in a row. Previous, Current, and Next were all selected from the top portion of the Repeat window.
The Period syntax lets you create an attribute expression that repeats over the entire time period specified. To invoke the Period window using the Repeat function, select Period from the pull-down menu in the Repeat window.
Example:
WHEN
Low of US is at most 104
repeated in the monthThis condition is satisfied when the US low is less than or equal to 104 every day in the month. The time period unit month was selected from the In Entire option.
As with all From/To statements in the XMIM system, this feature allows you to select a specific time period range in which the Attribute values will be repeated. This is similar to the Previous-Current-Next syntax, but there is a subtle difference. The Previous-Current-Next imposes the units specified on the repeat onto the series. So, for example, if you wanted to show 15-minute bars over a span ranging from a day before and two days after an event, and you were to use the Previous-Next syntax, the system would display only four 15-minute bars. This is a better overall language element because you are merely specifying the range of time over which the default attribute units will be displayed. To invoke the Repeat From-To window using the Repeat function, select Repeat From-To from the pull-down menu in the Repeat window.
The following familiar choices are available from the pull-down menu that appears to the right of the From: and To: labels and select one of the following options:
Today
Begin (End) of Time
Time Offset
Condition
Example:
WHEN
The 1 minute Close of US is down more than 2
repeated from Today to 2 hours laterThis condition will be satisfied when the close of US is down more than 2 from the current time period of the query to 1 hour later. The Time Condition was selected to set the To option.
This function allows you to create a looping variable whose variable will start at the From value, will end at the To value and will increase at each iteration by the By value. This variable can be used to create conditions whose value increases or decreases with each iteration of the loop.
The In Date/Time Condition option allows a repeating loop that repeats over all instances where a date or time condition is true.
The Number of Times In option is used in conjunction with the 'normal' Repeat functions available in the right column of the Repeat window to capture irregular periods of time when your condition is repeated. There are two options available for repeating a WHEN condition using Number of Time In function: repeated for a time period and repeated a number of times in a time period.
To build the 'Number of Times In' language, simply make your selections using the left most criteria within the Repeat and add in the normal Repeat functions used in the right column of the window.
The following WHEN conditions may be created using the Number of Times In function:
Example:
SHOW
1: percent_move from 10 days later to 20 days later of IBM
WHEN
IBM is down more than 10
AND
IBM is up more than 10
repeated 1 time in the next 10 daysThe example above will return the 10 day percent move of IBM when the price of the stock drops by $10 in one day followed by a one day correction of the same amount in the next 10 days to follow the decline.
Example:
SHOW
1: BAR of DEC
repeated for the previous 10 to next 10 days
WHEN
DEC is up more than 2 %
repeated 2 times in the monthThe example above will return the 20 days of daily pricing bars of Digital Equipment Corporation stock when the price of the stock drops is up more than 2% in one day twice in one month.