翻译与研读 Building Winning Trading System with TradeStation

Discussion in 'Philosophy and Strategy' started by 思迷思, Jul 15, 2005.

  1. 布尔与字符型的变量以相似的方式申明。
    Vars: myCondition(false) , myString(“abcdefgh ”) ;
    myCondition变量初始化为false. 字false是一个保留字,它的值是0。此字不能用作它途。myString变量初始化成abcdefgh.。有时需要一个临时用途的变量而事先申明所有的变量显然是很困难的。此时(临时变量是指仅在很短的时间内保存值的变量),EasyLanguage已经申明和初始化了一些变量,value0 到 value99 就是已申明和初始化为0的变量并提供给程序员使用。以下代码是纯粹的EasyLanguage程序:
    value1 = High + Low + Close ;
    value2 =(High + Low)/2.0 ;
    注意,此外并无Vars 申明。因为变量value1 和 value2都已预先申明好也就不需要再申明了。也许,你已经注意到每项代码最后的分号(;)。分号告诉编译器我们已按照特殊的要求写完了指令。按编程惯例,指令等同与申明。申明由表达式组成,而表达式又由常量,变量,操作符,函数和圆括弧组成。有些语言需要终止符而有些又不要求。EasyLanguage 需要一个终止符,为防止语法错误,记住在每行代码的末端加上分号。
    输入与变量很相似。它们遵循同样的规则,需要申明和初始化。然而在一个分析技术程序里,输入保持为常量。输入只有放在申明的开头(一行指令)且在一段代码体中不能被改变。使用输入的一个最主要的原因是因为不需要编辑实际的EasyLanguage代码就可以改变所用分析技术的输入值。输入对移动平均指标是最适用的。对图表上的移动指标,仅需在对话框的输入栏中简单地键入移动平均的长度。用户一点也不想必须返回到移动平均的源代码中去进行这样的修改与确认。同样地,对使用中的交易策略,输入也能够用来对交易策略进行
    优化。这将在第五章进行讨论。
    注意,输入与变量是怎样以相类似的方式申明的
    Inputs : length1(10), length2(20), flag(false);
    Vars: myLength1(10) , myAveVal(30) ;
    然而更需要注意两者在编码中的不同使用方法。
     
  2. Variables
    myLength1 = myAvgVal + myLength1 ; {Correct}
    Inputs
    Length1 = myAvgVal1 + length1 ; {Incorrect}
    MyLength1 = length1*2 ; {Correct}
    Variables can start a statement and can be assigned another value. Since inputs are constants and cannot be assigned new values, they cannot start a statement.
    In a strongly typed language, such as C, Pascal, or C++, if you assign a real value such as 3.1456 to an integer typed variable, the decimal portion is truncated and you end up with the number 3. As we all know, precision is important when it comes to trading, so EasyLanguage include only one Numeric type. All numbers are stored with a whole and a fractional part. In the old days when CPUs were slow, noninteger arithmetic took too much time and it was advised to use integer variables whenever possible.
     
  3. 变量:
    myLength1 = myAvgVal + myLength1 ; {Correct}
    输入:
    length1 = myAvgVal1 + length1 ; {Incorrect}
    myLength1 = length1*2 ; {Correct}
    变量可以放在申明的开头且值也可以改变。因为输入是个常量所以其值不能改变且不能放在申明的开头处。
    在非常强调类型的编程语言如C, Pascal, 或 C++中,如果将一实数如3.1456赋予一个整型变量,小数部分就会被截掉而只在变量中保留整数部分3。就如我们知道的那样,精确度对交易来讲是很重要的,所以在EasyLanguage中仅包含一个数字类型。所有进行存储的数包括小数部分都全部被保留。早些时候因为CPU的速度很慢,而非整数运算又要花费很长的时间,因此一旦可能都建议使用整型变量。
     
  4. 不过不知怎样才能帮上忙。qindosa@YAHOO.COM.CN
     
  5. 不过不知怎样才能帮上忙。qindosa@YAHOO.COM.CN
     
  6. 好帮啊,你选一章翻就可以了,合起来就是一本书啊。
     
  7. OPERATORS AND EXPRESSIONS

    Previously, we discussed statements and how they are made up of expressions. To review, an expression consists of a combination of identifiers, functions, variables, and values, which result in a specific value. Operators are form of built-in functions and come in two forms: unary and binary. A binary operator requires two operands, whereas a unary operator requires only one. Most of your dealing with operators in EasyLanguage will be of the binary variety. Some of the more popular ones are + - * / < = >= =< <> AND OR . These operators can be further classified into two more categories: arithmetic and logical.
    Expressions come in three forms: arithmetic, logical, and string. The type of operator used determines the type of expression. An arithmetic expression includes + - / *, whereas a logical or Boolean expression includes < = > >= <= <> AND OR.

    Arithmetic expressions Logical Expressions
    myValue = myValue + 1 ; myCondition1 = sum > total ;
    myValue = sum – total ; myCondition1 = sum <> total ;
    myResult = sum * total + 20 ; comd1 = cond1 AND cond2 ;
    Arithmetic expressions always result in a number, and logical expressions always result in true or false. Ture is equivalent to 1, and False is equivalent to 0. String expressions deal with a string of characters. You can assign string values to string variables and compare them.
     
  8. 操作符与表达式

    前面讨论了声明及怎样用表达式组成声明。我们知道表达式可由标示符,函数,变量和值的混合式组成,表达式会有一个特殊的值作为结果。操作符是一种内置函数形式且一般有两种类型:一元和二元。
    二元操作符要求两个操作数而一元操作符仅要求一个操作数。EasyLanguage 中用到的绝大多数操作符都是二元的。较常用的一些二元操作符有+ - / * < <= >= <> AND OR . 这些操作符可进一步地划分成算术与逻辑两大类。
    表达式有三种结果:数字 逻辑 字符串。所使用的操作符的类型决定了其表达式的类型。算术表达式包括+ - / *, 而逻辑或布尔表达式则包括< = >= <= <> AND OR.
    算术表达式 逻辑表达式
    myValue = myValue + 1 ; myCondition1 = sum > total ;
    myValue = sum – total ; myCondition1 = sum <> total ;
    myResult = sum * total + 20 ; comd1 = cond1 AND cond2
    算术表达式总是产生数字类型的结果,逻辑表达式总是产生对或错的类型。对相当于1,错相当于0。字符串表达式处理一串字符。可以将字符串的值付给字符串变量并对其进行比较。
     
  9. 支持,頂一下!
     
  10. PRECEDENCE OF OPERATORS
    It is important to understand the concept of precedence of operators. When more than one operators is in an expression, the operators with the higher precedence is evaluated first and so on. This order of evaluation can be modified with the use of parentheses. EasyLanguage’s order of precedence is as follows:
    1. Parentheses
    2. Multiplication or division
    3. Addition or subtraction
    4. <,>,=,<=,>=,<>
    5. AND
    6. OR
    Here are some expressions and their results:
    1. 20 – 15/5 equals 17 not 1
    20 – 3 division first , then subtraction
    2. 10 + 8/2 equals 14 not 9
    10 + 4 division first then addition
    3. 5 * 4 / 2 equals 10
    20 / 2 division and multiplication are equal
    4. (20 – 15 ) / 5 does equal 1
    5 / 5 parentheses overrides order
    5. (10 + 8 ) / 2 equals 9
    18 / 2 parentheses overrides order
    6. 6 + 2 > 3 true
    8 > 3
    7. 2 > 1 + 10 false
    2 < 11
     
  11. myName 1 = “George Pruitt ” ;
    myName 2 = “John Hill ” ;
    cond1 = (myName 1 <> myName 2) ;
    myName 3 = myName 1 + “” + myName 2 ;

    当要将两个或更多的字符串放在一起时,串联技术就出现了。把两个字符串加在一起时基本上是建立了一个新的字符串。

    运算符的优先级
    理解运算符的优先级概念是重要的。当多于一个的运算符在一个表达式中时,高优先级的运算符先运算其余的压后。这种运算次序是可通过园括号进行改变的。EasyLanguage的运算次序如下:
    1. 园括号
    2. 乘除
    3. 加减
    4 <,>,=,<=,>=,<>
    5 与
    6 或
    这里是一些表达式及相应的结果:
    1. 20 – 15/5 equals 17 not 1 (等于17而非1)
    20 – 3 division first , then subtraction(除先减后)
    2. 10 + 8/2 equals 14 not 9(等于14而非9)
    10 + 4 division first then addition(先除后加)
    3. 5 * 4 / 2 equals 10(等于10)
    20 / 2 division and multiplication are equal(乘除等级)
    4. (20 – 15 ) / 5 does equal 1(的确等于1)
    5 / 5 parentheses overrides order (园括号的级别最高)
    5. (10 + 8 ) / 2 equals 9(等于9)
    18 / 2 parentheses overrides order(园括号的运算级最高)
    6. 6 + 2 > 3 true(条件为真)
    8 > 3
    1. 2 > 1 + 10 false(条件为假)
    2 < 11
     
  12. These examples have all the elements of an arithmetic expression-numeric values and operators—but they are not complete EasyLanguage statement. An expression must be part of either an assignment statement (myValue = mySum + myTot) or a logical statement (cond1 = cond2 OR cond3).
    The overall purpose of EasyLanguage is to translate an idea and perform an analysis on a price data series over a specific time period. A price chart consists of bars built from historical price data. Each individual bar is a graphical representation of the range of prices over a certain period of time. A five-minute bar would have the Opening, High, Low, and Closing prices of an instrument over a five-minute time frame. A daily bar would graph the range of prices over a daily interval. Bar chart are most often graphed in an Open, High, Low, and Close format. Sometimes the opening price is left off. A candlestick chart represents the same data, but in a different format. It provides an easier way to see the relationship between the opening and closing prices of a bar chart. Other bar data such as the date and time of the bar’s close, volume, and open interest is also available for each bar. Since EasyLanguage works hand-in-hand with the charts that are created by TradeStation, there are many built-in reserved words to interface with the data. These reserved words were derived from commonly used verbiage in the trading industry. You can interface with the data by using the following reserved words. (Note: Each word has an abbreviation and can be used as a substitute.)
    Reserved Word Abbreviation Description
    Date D Date of the close of the bar.
    Time T Time as of the close of the bar
    Open O Open price of the bar.
    Close C Close price of the bar.
    Volume V Number of contracts/shares traded
    OpenInt OI Number of outstanding contracts
    (futures only)
    If you wanted to determine that the closing price of a particular instruments was greater than its opening price you would simply type:
    Close > Open , or , C > O.
     
  13. 成立于1807年的John Wiley & Sons 是USA最老的独立出版公司。分支机构遍布北美,欧洲,澳大利亚和亚洲,针对客户专业与独特的知识和修行,Wiley倾全力于出版与营销印刷和电子产品及相关服务。
    The Wiley 交易系列是以交易员所写的图书为特色产品,这些交易员以市场的波动为生而且取得令人艳羡的成绩,其中一些书籍以重构系统为主,一些则回到最基础的原理上进行描述。无论是初级或专业或介于两者之间的读者,都将从书中获得不仅使今天做得更好,在将来也适用的建议与策略。
    欲获相关文章的清单请访问出版商的网站。

    系统书写器之前(TRADESTATION的前身)系统开发者和系统交易员没有一个商业的软件平台来实现他们的交易思想。那时讨论的不是图形软件包,而是能理解基于技术分析的交易策略的软件。的确,在80年代也有一些相当复杂的程序可以使用,但它要求使用者有高超的编程能力,其它软件的帮助以及软件开发者的极度耐心。这些软件中的绝大多数都不是开放的平台,使用人员只能在其限定的脚本语言里编程而且不能与其它研究人员共享交流成果。以前那些有开放平台的软件通常需要分开的编辑器和编译器而且对用户能力的要求出奇的高。事实上,我们曾经开发的现在仍在使用的一些软件包就是使用的FORTRAN编译器。系统书写器/TRADESTATION为交易大众提供了一个集成的环境用于测试,优化和交易。相对于其它所采用的交易/测试平台,TRADESTATION已广泛地被认为是主流的市场分析平台和标准。最新版本的TRADESTATION已升级成不仅仅是一款软件,而完全是成熟的整合了期货及持仓经纪业务的交易平台,随着TradeStation6.0的诞生Omega Research获得再生并更名为TradeStation Securities.

    我们在此处并不是宣扬TradeStation’s Securities的产品是行业中最好的,只是向他的用户介绍如何使用其中被定为工业标准的东西。诚然Omega Research有自己的问题。就如最近听说IBM的人员声称CTRL+ALT+DEL程序是由他们所创,而我们知道是Microsoft令其家喻户晓。TRADESTATION有别与其它产品的显者特点是其强大的脚本语言EASYLANGUAGE。EASYLANGUAGE不仅简单而且强大。它的确不仅仅是脚本语言,更多时表现为成熟的编程语言。其功能可与如下编程语言BASIC,FORTRAN,Pascal,or C.相比美。事实上EASYLANGUAGE有一类Pascal的编译器并与1987年投入使用。EASYLANGUAGE的发明者Sam Tennis想为交易人员提供一款这样的语言:简单但却富于逻辑性,使用者只需很少的编程知识。以作者的观点看,Sam Tennis的努力是有成效的。

    股票与商品的技术分析是复杂的,因此你认为处理如此难度课题的编程语言也应是很复杂的。幸运地是,EasyLanguage有一个在工业上广泛应用的分析技术的完整的库(函数或类)。第三方开发商已大大地扩展了此库。用户完全不用从头开始来创建一交易系统,甚至也不需要编程知识来将这些技术付之实施。用户只需考虑个性化的交易思想或已存在的交易规则并将它们放入库中。

    此书是为TradeStation and EasyLanguage的用户设计的。当然,作者的确希望读者有些了解TradeStation和它的函数。这样,初始的使用者在程序设计技术,程序控制结构,数据结构和内嵌函数EasyLanguage语言的应用上便能得到一个较好的理解。所有的用户皆能从介绍适用交易系统开发一章中获益非浅。我们介绍了从指示信号到图形条的分析技术的所有领域,特别地强调了交易策略。
    由于此书相当大的部分涉及到计算机代码,随书附赠一盘载了所有代码与数据的光盘。分析技术是以TradeStation 2000i 和 TradeStation 6.0的格式提供。只需将代码与数据简单地输入相应版本的PowerEditor,早期版本的用户也能应用这些分析技术。第五章借用Microsoft Excel扩展页软件功能的帮助实现三维轮廓图表。Excel不是必须的,在数据向图形的转换中只需要扩展页软件的几项功能。
    此书按照交易人员的实际需求进行编写。绝大多数交易技术的设计与测试都是以指数,期货和商品为对象进行的(由于使用交易系统的长久历史我们特别地关注这些市场)。确切地讲,平衡交易员仍可得到编程与系统设计的好的培训。指数(小的或全市场)和期货交易者将获得5 个相当成功的作者个人开发的交易方法。对于更进一步与详细的研究,这些方法提供了一个导引。
    我们建议最好从第一开始循序渐进地研读此书。提供了详细分析技术的最后一章(或计算机程序—其实两者是等价的),我们建议直接从CD-ROM中下载,确认并实际在TradeStation运行。将每章彻底地弄明白后再转入下一章。
    我们希望读者能喜爱这本书,更希望此书能帮读者发现TradeStation的强大威力和启迪读者的创造与想象。
    祝大家好运
    祝大家交易顺利

    基础
    什么是EASYLANGUAGE?
    当你为一项分析技术编码时(也即俗话讲的将交易思想转为编程语言),其实是在指示计算机按照你的指令工作。计算机语言就只是一个指令清单。计算机是被动的但却是快速的,它与给它编写程序的程序员一样聪明。另外,计算机的指令要按照一定的格式来完成,而程序员也必须遵循一定的语法规则。
    EASYLANGUAGE是程序员将交易思想转换成计算机能理解的形式(语言)的中介。幸运的是,EASYLANGUAGE是一种高级语言,但它看起来与书面英语一样。EASYLANGUAGE是一种编译语言,当程序员认为需要的时候程序就会被转换成计算机代码。于是编译器开始检查语法上的正确性并将代码转换成计算机能理解的程序。当发现错误时,编译器还能向程序员指示出问题所在,有时还能提出解决方案。这就是与解释语言的区别,解释语言是在输入的时候进行评估的。
    包括EasyLanguage在内的所有计算机语言都有一些共同的地方,比如:
    。保留字: 计算机留出来作为特殊用途的字(词汇)。用户只能按预定义的方式来使用这些字。将这些字作它用时会导致计算机十分严重的错误。(参见附录C的保留字清单)

    .注释。 被编译器完全忽视掉的词汇与语句。放在代码中的注释是为帮助编程人员或代码的再使用者理解程序的功能。EasyLanguage也采用空指令词汇。包括在句子中的这些空指令词汇能使程序员更容易地阅读程序。例如,Buy on next bar at myPrice stop 与 Buy next bar myPrice stop 等效。单词on 与at 就被编译器忽略了。
    (空指令词汇参见附录C的清单)
    。变量 用户定义的用于存储信息的词汇或字母。
    。数据类型 不同的存储类型;变量是根据数据类型来定义的。EasyLanguage有三种基本的数据类型:数字,布尔,字符串。分配成数字量或存储为数字的变量就是数字型变量。存储真值或假值的变量就是布尔型变量。存储一串字母的变量就是字符型变量。

    。变量与数据类型
    在进行编程之前,程序员必须理解变量和与之相关的数据类型。看一段如下的代码:
    MySum =4+5+6;
    MyAvg =MySum/3;
    其中mysum 和睦myAvg都是变量且为数字型变量;它们都是存储数字的地方。EasyLanguage对于变量的命名是相当宽松的,但也要遵循一定的规定。一个变量名不能
    。 以一个数字或句号开头
    。 是一个数字
    。 长于20个数字字符
    。 包括诸如句号或下划线一类的标点符号。

    正确的写法 错误的写法
    myAvg 1MyAvg
    mySum .sum
    sum val+11
    vall the//sum
    the.sum my?sum
    my_val 1234
    变量命名多取决于程序员的个人风格。EasyLanguage 是非大小写敏感的语言(即在变量的命名中可用大写也可用小写意思一样)。(注:这只是我们的偏好,其它的语言也许不这样。)当变量名仅有一个音节时,我们倾向于用小写。当变量名多于一个音节时,我们将在开始的第一个音节用小写而在随后的各个音节的第一个字母用大写。
    Sum , ave, total, totalSum, myAvg, avgValue, totalUpsum,totDnAvg
    参看前面的那段代码,mySum 被分配了值15,myAvg被赋了值15/3 或者说5。当创建变量名时,一定要提前申明。申明语句中定义了变量的初始值与数据类型。编译器了解了变量的类型后才能为变量在内存中保留合适的字节。随后的代码完全是EasyLanguage式的(注:读者在此书中看到的代码绝大多数都属EasyLanguage,他们在其它语言中也许不能正常运行。)
    Vars: mySum(0), myAvg(0);
    mySum= High + Low + Close;
    myAvg = mySum/3;
    The Vars: (或 变量)申明语句告诉计算机申明的变量及其初值。将变量名列于the Vars后并将初始值放于随后的圆括号中就可以申明变量了。在此例中,变量mySum 和myAvg 都等于0。因为初始值是数字,EasyLanguage 有足够的智能自动地识别出这些变量的数据类型。变量名应该是自描述性的而且应有一定的长度使其变量名有些提示意义。下面这些变量名够长且具自释性吗?
    mySum =High + low + Close; or k = High + Low +Close;
    myAvg = mySum/3; j = k/3 ;
    Buypt = Close + myAvg ; l = Close + j ;

    2005-7-28
    布尔与字符型的变量以相似的方式申明。
    Vars: myCondition(false) , myString(“abcdefgh ”) ;
    myCondition变量初始化为false. 字false是一个保留字,它的值是0。此字不能用作它途。myString变量初始化成abcdefgh.。有时需要一个临时用途的变量而事先申明所有的变量显然是很困难的。此时(临时变量是指仅在很短的时间内保存值的变量),EasyLanguage已经申明和初始化了一些变量,value0 到 value99 就是已申明和初始化为0的变量并提供给程序员使用。以下代码是纯粹的EasyLanguage程序:
    value1 = High + Low + Close ;
    value2 =(High + Low)/2.0 ;
    注意,此外并无Vars 申明。因为变量value1 和 value2都已预先申明好也就不需要再申明了。也许,你已经注意到每项代码最后的分号(;)。分号告诉编译器我们已按照特殊的要求写完了指令。按编程惯例,指令等同与申明。申明由表达式组成,而表达式又由常量,变量,操作符,函数和圆括弧组成。有些语言需要终止符而有些又不要求。EasyLanguage 需要一个终止符,为防止语法错误,记住在每行代码的末端加上分号。
    输入与变量很相似。它们遵循同样的规则,需要申明和初始化。然而在一个分析技术程序里,输入保持为常量。输入只有放在申明的开头(一行指令)且在一段代码体中不能被改变。使用输入的一个最主要的原因是因为不需要编辑实际的EasyLanguage代码就可以改变所用分析技术的输入值。输入对移动平均指标是最适用的。对图表上的移动指标,仅需在对话框的输入栏中简单地键入移动平均的长度。用户一点也不想必须返回到移动平均的源代码中去进行这样的修改与确认。同样地,对使用中的交易策略,输入也能够用来对交易策略进行
    优化。这将在第五章进行讨论。
    注意,输入与变量是怎样以相类似的方式申明的
    Inputs : length1(10), length2(20), flag(false);
    Vars: myLength1(10) , myAveVal(30) ;
    然而更需要注意两者在编码中的不同使用方法。
    2005-7-29
    变量:
    myLength1 = myAvgVal + myLength1 ; {Correct}
    输入:
    length1 = myAvgVal1 + length1 ; {Incorrect}
    myLength1 = length1*2 ; {Correct}
    变量可以放在申明的开头且值也可以改变。因为输入是个常量所以其值不能改变且不能放在申明的开头处。
    在非常强调类型的编程语言如C, Pascal, 或 C++中,如果将一实数如3.1456赋予一个整型变量,小数部分就会被截掉而只在变量中保留整数部分3。就如我们知道的那样,精确度对交易来讲是很重要的,所以在EasyLanguage中仅包含一个数字类型。所有进行存储的数包括小数部分都全部被保留。早些时候因为CPU的速度很慢,而非整数运算又要花费很长的时间,因此一旦可能都建议使用整型变量。
    操作符与表达式

    前面讨论了声明及怎样用表达式组成声明。我们知道表达式可由标示符,函数,变量和值的混合式组成,表达式会有一个特殊的值作为结果。操作符是一种内置函数形式且一般有两种类型:一元和二元。
    二元操作符要求两个操作数而一元操作符仅要求一个操作数。EasyLanguage 中用到的绝大多数操作符都是二元的。较常用的一些二元操作符有+ - / * < <= >= <> AND OR . 这些操作符可进一步地划分成算术与逻辑两大类。
    表达式有三种结果:数字 逻辑 字符串。所使用的操作符的类型决定了其表达式的类型。算术表达式包括+ - / *, 而逻辑或布尔表达式则包括< = >= <= <> AND OR.
    算术表达式 逻辑表达式
    myValue = myValue + 1 ; myCondition1 = sum > total ;
    myValue = sum – total ; myCondition1 = sum <> total ;
    myResult = sum * total + 20 ; comd1 = cond1 AND cond2
    算术表达式总是产生数字类型的结果,逻辑表达式总是产生对或错的类型。对相当于1,错相当于0。字符串表达式处理一串字符。可以将字符串的值付给字符串变量并对其进行比较。
    2005-8-4译
    myName 1 = “George Pruitt ” ;
    myName 2 = “John Hill ” ;
    cond1 = (myName 1 <> myName 2) ;
    myName 3 = myName 1 + “” + myName 2 ;

    当要将两个或更多的字符串放在一起时,串联技术就出现了。把两个字符串加在一起时基本上是建立了一个新的字符串。

    运算符的优先级
    理解运算符的优先级概念是很重要的。当多于一个的运算符在一个表达式中时,高优先级的运算符先运算其余的压后。这种运算次序是可通过园括号进行改变的。EasyLanguage的运算次序如下:
    1. 园括号
    2. 乘除
    3. 加减
    4 <,>,=,<=,>=,<>
    5 与
    6 或
    这里是一些表达式及相应的结果:
    1. 20 – 15/5 equals 17 not 1 (等于17而非1)
    20 – 3 division first , then subtraction(除先减后)
    2. 10 + 8/2 equals 14 not 9(等于14而非9)
    10 + 4 division first then addition(先除后加)
    3. 5 * 4 / 2 equals 10(等于10)
    20 / 2 division and multiplication are equal(乘除等级)
    4. (20 – 15 ) / 5 does equal 1(的确等于1)
    5 / 5 parentheses overrides order (园括号的级别最高)
    5. (10 + 8 ) / 2 equals 9(等于9)
    18 / 2 parentheses overrides order(园括号的运算级最高)
    6. 6 + 2 > 3 true(条件为真)
    8 > 3
    1. 2 > 1 + 10 false(条件为假)
    2 < 11
    2005-8-5 译
    这些范例具有算术表达式的所有元素---数值与操作符—但却不是完全的EasyLanguage声明。一个表达式必须或是赋值声明(myValue = mySum + myTot)或是逻辑声明(cond1 = cond2 OR cond3)的一部分。
    EasyLanguage总的目的是交易思想的翻译和分析特定时期内的价格数据系列。一张价格图表由基于历史价格数据的条柱组成。每根条柱都是一定时间范围的价格区间的图形反映。5分钟条柱反映5分钟时间架构内被测定对象的开盘,最高,最低和收盘价。而日条柱则显示一日间隔的价格范围。条柱图就是通常的开盘,最高,最低和收盘价的图示格式。有时候又将开盘价去掉。烛蜡图反映同样的数据只是表现格式不同。烛蜡图更能直观地表现条柱上开盘与收盘价之间的关系。其它的条柱数据如条柱的日期与时间,成交量,开盘信息需要时都可以提供给每根条柱图或从条柱上得到。因为EasyLanguage与由TradeStation创建的图表的紧密关系,有许多内置的保留字用来与这些数据进行交互。这些保留字完全源于交易界常用的术语。用户可用如下的保留字与交易数据进行交互(注:每个保留字有一个缩写可用来代替保留字)
    保留字 缩写 描述
    Date D Date of the close of the bar.
    Time T Time as of the close of the bar
    Open O Open price of the bar.
    Close C Close price of the bar.
    Volume V Number of contracts/shares traded
    OpenInt OI Number of outstanding contracts
    (futures only)
    如果需要确定收盘价大于开盘价的特殊显示条柱仅需简单地键入:
    Close > Open , 或 , C > O.
     
  14. The beauty of EasyLanguage is its ability to have all the data of an instrument at your fingertips. The reserved words that you we use to access the different prices of the current bar are also used to access historical data. You do this by adding an index to the reserved word。The closing price of yesterday would be: Close[1]. The closing price two days ago would be: Close[2] and so on. The number inside the bracket determines the number of bars to look back. The larger the number, the further you go back in history. If you wanted to compare today’s closing price with the closing price ten days prior you would type: Close > Close[10].
    Before we move on, we should discuss how TradeStation stores dates and times. January 1, 2001 is stored as 1010101 instead of 20010101 or 010101. When the millennium changed, instead of incorporating the century into the date, TradeStation simply added a single digit to the year. The day after 991231 was 1000101 according to TradeStation. Time is stored as military time. For example, one o’clock in the afternoon is 1300 and one o’clock in the morning is 100.
    After that brief introduction to the world of programming, let’s go ahead and set up and program a complete trading strategy. The PowerEditor is where all of the magic takes place. This is your interface between your idea and their application. All of your coding takes place here, and a through understanding of this editor will reduce headaches and increase productivity. In TradeStation 4.0 and 2000i, the PowerEditor is basically a stand-alone application; it is an independent program and can run with or without TradeStation. In the newer TradeStation 6.0, the PowerEditor is more of a component program; it runs within the confines of TradeStation.
     
  15. EasyLanguage的魅力就在于它对条柱图示数据的获取上。用于访问当前条柱的不同价格的保留字也能用于访问历史数据,而且仅在保留字中加个索引参数就能实现。昨天收盘价的表示是:Close[1]。两天前的收盘价表示是Close[2]以此类推。方括号中的数字决定了回逆的天数,其数字越大往回倒的就越远。如果想将今日的收盘价与十天前的比较其写法是:Close > Close[10].

    继续深入讨论之前先介绍一下TradeStation中存储日期与时间的方法。2001年一月一日存为1010101而非20010101或010101。当出现千年变更时,TradeStation不再将世纪的数字加入计算而只是在年份中简单地加一个数字。991231后的日期是1000101。时间是以军事记录方式表示。如下午的1点是1300早晨的1点表示为100。
    在对编程的东西作过些简单的介绍后,我们可以开始进入编写完整的交易策略了。所有的奇迹都发生在PowerEditor。PowerEditor是你的交易思想与程序进行传递交接的地方。所有的代码都在PowerEditor里进行编辑,对此编辑器越充分的理解以后遇到的困难就会越少编程也会越顺利。在TradeStation的4.0 和 2000i中, PowerEditor基本上是独立的应用程序;即既可以在TradeStation中运行也可在TradeStation之外运行。在最新的TradeStation 6.0中PowerEditor更多地以程序组件的形式出现且只能在TradeStation的环境中运行。
     
  16. TRADESTATION 2000i 与 TRADESTATION 6.0
    As of the writing of this book, there are two versions of TradeStation currently being used: 2000i and 6.0. Based on input from users, we figure that half is using one version and the half is using the other. For this reason, the remainder of this chapter will be broken into two main sections.(Beyond this chapter, however, we will include the EasyLanguage code for 2000i in Appendix B. We will concentrate on 6.0 in the remaining chapters as it is the latest version and seems to be the way of the future.) Version 6.0 and 2000i are different enough to merit treating each one separately and we will refer to the two versions as 6.0 and 2000i. TradeStation 6.0 is Omega Research’s all-inclusive trading tool. Everything that you need to design, test, monitor, and execute an analysis technique is in one slick and complete package. Omega Research is now a brokerage/software company and equities and futures trades can be executed through direct access with TradeStation.
     
  17. TRADESTATION 2000i 与 TRADESTATION 6.0
    写此书期间,有两个版本的TradeStation(2000i 和6.0)在使用。基于用户的需求,我们在书中参半使用了这两个版本。因此,这章的其余部分将被分成两部分(然而这章以后,将把EasyLanguage2000i版的代码放在附录B中。我们会集中精力介绍6.0版,不仅因为它是最新版也因为似乎6.0版代表了未来的方向)。两个版本从不同的角度都提供了有益于交易的巨大帮助,我们用6.0和2000i分别标示它们。TradeStation 6.0包含了Omega Research所有的交易技术。在诸如设计,测试,监控和执行等分析技术中所需要的方方面面都可以在这个包装光滑和完整的软件包中得到。Omega Research现在已是集经纪/软件业务的综合性公司,股票和期货的交易都能通过TradeStation.而直接进行。
     
  18. TradeStation 2000i
    PowerEditor
    Once this program is up and running, go under the File menu and select New. A dialog box titled New will open. If the General tab is not selected, go ahead and select it. Your screen should look like this:
    Once your screen look like Figure 1.1 select the icon with the title Signal and click OK. We will ignore the other tab in this dialog box at the moment. Another dialog box titled Creating a New Signal open and ask for a name and notes about the signal that you are creating. In the name field go ahead and type “MySignal-1” and in the Notes field type “Donchian Break Out” and then click OK. A window titled MySignal-1 should open. This is your clean sheet of paper on which to type your wonderful ideas. Before we do some coding, let’s briefly take a look at some of the menus. Table 1.1 details the selections that are available under the File menu.
    Table 1.2 details the selection under the Edit menu.
    Table 1.3 details the selection under the View menu.
    Table 1.4 details the selection under the Tool menu.
     
  19. TradeStation 2000i
    PowerEditor
    起动程序完成后,找到文件菜单并选择其中的New。一个有New标题的对话框就会打开。如果打开后没有选中General标签,先点击选中此项,一个新的屏幕画面如下所示:(图见原书)
    画面与图1。1一样时,选择提示文字为Signal的图标后单击OK按钮。暂时先忽略此对话框中的其它标签。标题是Creating a New Signal的另一对话框会出现并要求对所创建的信号起名和写上注释。选中name域并写上“MySignal-1”,选择Notes域写上“Donchian Break Out”后点击OK。一个标题为MySignal-1的窗口会打开。此窗口即是我们实现精彩交易思想的原始起点。开始编码以前让我们来看一下其它的菜单。表格1。1详细列出了File菜单的各种选项。
    表格1。2详细列出了Edit菜单的各种选项
    表格1。3详细列出了View菜单的各种选项
    表格1。4详细列出了Tool菜单的各种选项
     
  20. Now that we are familiar with the menu and their functions, let’s go ahead and code a simple program. We don’t need to know everything about the selections in the menus to start coding. Jump in headfirst and type the following text exactly as you see it here:
    Inputs: longLength(40) , shortLength(40);
    Buy tomorrow at Highest ( High , longLength ) stop ;
    Sell tomorrow at Lowest ( Low , shortLength ) stop ;
    (Note: for those of you who may be moving to TradeStation 6.0 you must type Sell Short to initiate a short position.)
    After you have typed this, go under the File menu and select Verify or hit the F3 key. Many of the commands in the menus have keyboard equivalents or shortcuts. You can determine the shortcuts by selecting the menu and then the menu item. ( The keyboard shortcuts is listed to far right of the menu item.) If you look at the Verify menu item on the File menu, you will see F3. You should get a small dialog box that first says Verifying and then Excellent. If you get an error, simply check your code for any typos and Verify again. Congratulations, you have just written an analysis technique in the form of a signal!