1. 首页
  2. 易语言 - EasyLanguage
  3. 用于计算和控制何时进行计算和下单的常用日期、时间和Bar 的信息Some Frequently Used Date, Time and Bar Information Used for Calculations and Controlling When Calculations are Made and Orders are Issued

用于计算和控制何时进行计算和下单的常用日期、时间和Bar 的信息Some Frequently Used Date, Time and Bar Information Used for Calculations and Controlling When Calculations are Made and Orders are Issued

  • Date[0] = Date: Date of the CurrentBar the strategy/indicator is running on in the standard 7-digit format: YYYMMDD.
  • Date[1]: Date of the bar prior to the CurrentBar.
  • Date[3]: Date of 3 bars before the CurrentBar.
  • Date[2] of Data4: Date of 2 bars before the CurrentBar for the 4th Data Stream on the chart (Multiple Data Streams).
  • Date[2] of Data(N): Date of 2 bars before the CurrentBar for the Nth Data Stream on the chart (Multiple Data Streams), where N can be a variable. This same technique can be applied to any Price field ( Open, High, Low, Close, Date, Time, Volume, Ticks, UpTicks, DownTicks, OpenInt ), like High[3] of Data(N).
  • CurrentDate: Date corresponding to your local PC date and time – typically today.
  • Date next bar: Date of the next ( future ) bar. This phrase changes how the strategy runs, by switching it from running on the bar closing ticks to the bar opening ticks. This is typically used in Gap-type strategies. Only use this if you absolutely require the next bar’s date as it place restrictions on the strategy. For more information see Writing/Using Strategies and Indicators -> STRATEGIES -> ADVANCED METHODS -> Position Sizing — Scaling-in & out – Gaps & Entering At Open.
  • Time[0] = Time: Time of the CurrentBar in the standard 24-hour format: 0 = Midnight, 130 = 1:30 AM, 1015 = 10:15 AM, 1459 = 2:59 PM, 2359 = 11:59 PM.
  • Time[5]: Time of 5 bars before the CurrentBar.
  • Time[3] of Data2: Time of 3 bars before the CurrentBar for the 2nd Data Stream on the chart.
  • CurrentTime: Time corresponding to your local PC time – typically now.
  • Time next bar: Returns the time of the next ( future ) bar. Has the same impact as Date next bar on how the strategy operates.
  • DayOfWeek( Date ): Day of week number, with Sunday = 0, Monday = 1 and Saturday = 6.
  • DayOfMonth( Date ): Returns the day of the month. If the Date is March 9, 1992, then it returns 9.
  • Month( Date ): Month of year with January = 1 and December = 12.
  • Year( Date ): Year in a 2 or 3-digit format 98 = 1998, 100 = 2000, 111 = 2011.
  • Next3rdFriday( MonthsAway ): Calculates # of calendar days to the next 3rd Friday of the MonthsAway month. If MonthsAway = 0, this is the current month.
  • MinutesIntoWeek( DayOfWeek, Time ): Returns number of minutes since 12 am Sunday to the specified day of the week and Time.
  • DateTime: A Double-precision value representing the Julian Date (days since 1900) as the integer portion, and the seconds since midnight as the decimal portion. The DateTime of the current bar can be calculated using: MyDateTime = DateToJulian( Date ) + ( ( TimeToMinutes ( Time ) / 1440 ) ;
  • ComputerDateTime: Real-time local PC date and time in the DateTime format. Do NOT use this in back-testing, only for when real-time ticks are arriving.
  • TimeFromDateTime( DateTime ): Returns Time in standard HHMM format.
  • DateFromDateTime( DateTime ): Returns Date in standard YYYMMDD format.
  • YearFromDateTime( DateTime ): Returns standard 2 or 3-digit Year format.
  • MonthFromDateTime( DateTime ): Returns the Month of year number.
  • DayOfWeekFromDateTime( DateTime ): Returns the day of week number.
  • HoursFromDateTime( DateTime ): Returns hours elapsed since midnight.
  • MinutesFromDateTime( DateTime ): Returns minutes past the hour ( HoursFromDateTime ).
  • SecondsFromDateTime( DateTime ): Returns seconds past the minutes. When used with HoursFromDateTime and MinutesFromDateTime it can be used to produce HH:MM:SS .
  • DateToJulian( Date ): Converts standard YYYMMDD Date format to the Julian Date format ( days since 1900 ) to allow arithmetic ( add/subtract days ).
  • JulianToDate( JulianDate ): Converts a Julian date to the standard YYYMMDD Date format.
  • CalcDate( Date, +/-Days ): Adds/subtracts days from a date. Returns the value as a standard Date.
  • Number of days on a chart?
  • TimeToMinutes( Time ): Converts 24-hour Time to minutes since midnight, allowing arithmetic ( add/subtract ). 1:00 AM returns 60 (minutes) & 9:30 AM returns 570 (minutes).
  • MinutesToTime( Minutes ): Converts minutes elapsed from midnight back to the standard 24-hour Time format.
  • CalcTime( Time, +/-Minutes ): Adds/subtracts minutes from a Time. Returns the value as a standard Time.
  • CurrentSession( 0 ): Begins with 1 for the 1st session of the 1st day of the week ( typically Sunday or Monday ) and increases after that. Some symbols ( Futures ) may have several sessions each day.
  • SessionStartTime( 0 , SessionNum ): Returns time which SessionNum starts.
  • SessionEndTime( 0 , SessionNum ): Returns time which SessionNum ends.
  • BarType: Returns the type of bar (as a number ) on the chart.
  • BarInterval: Returns the bar interval in minutes ( intraday bars ), ticks ( tick bars ) or volume ( volume bars ).
  • BarStatus(1) = 2: The Data1 bar closing tick: Detecting Bar Closing Tick and Next Bar Opening Tick
  • BarStatus(N) = 2: The DataN bar closing tick when using Multiple Data Streams on a chart. For example, if BarStatus(3) = 2, the current tick is the closing tick of the Data3 bar. Closing bar ticks of Multiple Data streams can occur on the same tick if the bar closes are aligned, so BarStatus(1), BarStatus(2), and BarStatus(3) may all equal 2 on a given tick if Data1 is 2-minutes, Data2 is 4-minutes and Data3 is 12-minutes.
  • BarStatus(1) <> 2: Opening tick or tick within the bar. For more information see:
    • BarStatus 0, 1, and 2 explanation
    • BarStatus in the Wiki
    • Mixing Object Oriented Code with Procedural
    • BarStatus of -1 Error with multiple data sources
    • BarStatus returns -1 in other data streams on Data1 closing tick
    • How to determine which data stream tick is arriving when using multiple data streams and Function DetectStreamOfTickV1
  • Determine if last bar for a given date
  • LastCalcDate: Date of the last day on the chart. This, along with LastCalcTime, provides a way to estimate the amount of data on the chart: Number of days on a chart?.
  • LastCalcTime: Time of the last bar on the chart. It also provides a way to know in advance the last bar on the chart.
  • LastBarOnChart: True when the strategy/indicator is running on the last bar of the chart. Always True when real-time ticks are arriving, but being True does NOT mean that real-time ticks are arriving. For more information see LastBarOnChart.
  • LastBarOnChartEx: Same as LastBarOnChart, but works for seconds-based bars ( V9.1 Update 13 or later ).
  • GetAppInfo( aiRealTimeCalc ) = 1: Detect When Real-Time Ticks Are Arriving and Nuances When Detecting Real-Time Ticks From Either Data1 or Data2.
更新于 2020年6月8日

这篇文章对您有帮助吗?

相关的话题

留言评论