Documentation>Application Documentation>XMIM Documentation>XMIM Examples>IF THEN ELSE Example

IF THEN ELSE Example
 

If then else statements use the general form:

IF       <condition>

THEN  <condition>

ELSE   <condition>

ENDIF

Where <condition> is any legal condition outlined within this chapter.

Example: The following query scans the history of the daily moves of the Nasdaq and returns the highest number of consecutive losses ever. "Final Show" returns the end result of "highestCount" which is 16 trading days in a row. The "Show" statement returns all the counts of the days as well as the Close of the Nasdaq.

FINAL SHOW
  mostDays: highestCount

SHOW
  NASD: NASD
  repeatdays: counter

WHEN
  NASD is DEFINED
AND
  IF
    1 day percent_move of NASD is less than 0
    THEN
      counter = counter + 1
    ELSE
      counter = 0
  ENDIF
 AND
   highestCount is less than counter
    THEN counter
  ELSE highestCount
  ENDIF