text: EasyLanguage 代码处理方法 Understanding how EasyLanguage Code is Processed - TradeStation-国信|东海|银河 TradeStation
  This page gives an overview of how EasyLanguage code is processed.
  This page needs updating to reflect different processing of methods and events in TradeStation 9. And for multi-core processing in 9.1.
  This is the standard structure for an EasyLanguage document:
  Using statements and Methods are only available from TradeStation 9.0 onwards. From TradeStation 9.0 onwards there may also be some additional 'hidden' code associated with EasyLanguage documents called Designer Generated Code.
  The main body of code is processed from top to bottom, line by line. There are exceptions to this when working with functions (see below). In TradeStation 9, Methods were introduced. Methods are only processed when specifically called by your code or by an Event i.e. they are ignored in the top to bottom processing.
  Each line of code is processed from left to right, though mathematical and logical calculations are evaluated in Order of Precedence
  Logical statements are processed from left to right. If a condition says 'A or B', then if A is true, B will not be evaluated (though there are exceptions with Functions. See below). If a condition says 'A and B', then if A is False, B will not be evaluated (though there are exceptions with Functions. See below).
  Processing takes place on every Event. Prior to TradeStation 9 the only 'events' were a new price tick or an end-of-bar. In TradeStation 9 many more Events were introduced.
  For each new price tick or end-of-bar 'event' the whole code is run from beginning to end. When it has finished it waits for the next 'event' and then processes the whole code from beginning to end again. This is a different mindset to working with other programming languages where you may expect the code to start processing at the beginning of the chart and finish processing at the end of the chart.
  Everything is processed in series. i.e. an analysis technique runs on an 'event', and when it has finished processing control moves to the next analysis technique. It is not possible for two analysis techniques to run 'at the same time'.
  On historic data, TS calculates an indicator from the first bar on a chart, bar by bar, to the last bar, and when it's finished it moves onto the next indicator which calculates from the first bar, bar by bar, to the last bar. Strategies operate slightly differently in that when you apply two or more strategies to a chart they become part of a Strategy Group. Each strategy within the group takes its turn to calculate a bar before moving onto the next bar. A Strategy Group will run for every bar on the chart before moving on to any indicators. i.e. strategies always run before indicators.
  Code is always processed at end-of-bar. Code can also be processed intrabar. For historic data, Indicators will only process on end-of-bar. For real-time data, Indicators will process intrabar according to their 'Update value intrabar' property. Strategies process according to their IntrabarOrderGeneration (IOG) and Look-Inside-Bar-Backtesting (LIBB) settings.
  The values of Inputs are calculated on every bar. An Input declared with the value 'close', for instance, will have its value updated to the close price of the bar that is currently being processed.
  Variables are initialised with their declared values on the very first bar of processing. After that they will only change if changed by the code.
  Variables retain their calculated value at the end-of-the bar which can then be referenced in future bars with the use of [x] terminology. A variable that is processed intrabar and is declared without IntrabarPersist will, at the end of the code processing, revert back to its value at the last end-of-bar. A variable declared with IntrabarPersist will retain its value from tick to tick. (See IntrabarPersist).
  All indicators and strategies have a MaxBarsBack requirement. They will not start processing until their MaxBarsBack requirement is met.
  EasyLanguage has two types of functions – Simple and Series – which have very important differences. In conditional statements a Simple function is only processed if the condition is True, whereas a Series function is processed regardless of whether the condition is True or False. Furthermore, for Series functions, a conditional statement that evaluates to False causes the function to evaluate at the very end of the code – after all other code has finished processing – and it uses the values of variables that are present at the end of the code rather then those when it was called. See Understanding Functions.
  Every bar on a chart has a date and a time. On minute and above charts the date and time are enough to uniquely identify each bar. But on tick, volume and the 'advanced' bar types multiple bars can have the same date and time. EasyLanguage can only reference time down to a one minute resolution.
  Multiple Input-Output Functions – +data2
  EasyLanguage has the ability to work with the same symbol on multiple timeframes, or with multiple symbols. The standard, in-built method is to use multiple data streams, by adding two or more symbols to the same chart. There are several limitations with this approach and consequently there are other methods for working with multiple timeframes/symbols that may be more suitable. See Multiple Symbols, Multiple Timeframes, Pairs, Spreads & Custom Indices.
  Working with symbols on multiple timeframes requires special variable declarations. See Proper Syntax for Multiple Timeframes.
  'open next bar' functionality
  Text and Trendlines created intrabar will 'disappear' on the next tick (even if declared with IntrabarPersist). Only text and trendline object created end-of-bar (BarStatus(1) = 2) will continue to exist on following ticks and bars.