【问题标题】:Open and close of the first 1 min bar前 1 分钟柱的开盘和收盘
【发布时间】:2020-09-19 18:18:48
【问题描述】:

我知道在这里问很远,但我正在寻找一种方法来确定前 1 分钟的蜡烛是否为红色,这意味着柱线收盘价低于开盘价。

为此,我只需要前一分钟柱的开盘价和收盘价,但我还没有找到获得收盘价的方法。

打开局面是相当直接的:

def openValue = open(period = AggregationPeriod.DAY);

获取第一个柱的范围也相当简单,因为我们定义了一个范围(1 分钟)并返回该范围的高/低。

如果有人可以提供帮助,我将不胜感激。

谢谢!

【问题讨论】:

    标签: thinkscript


    【解决方案1】:

    好的,有人帮我解决了。

    def x = barNumber(); //bar
    
    def RTH = getTime() >= RegularTradingStart(getYYYYMMDD()) and 
    
          getTime() <= RegularTradingEnd(getYYYYMMDD()); 
    
    def TodaysOpen = if RTH and !RTH[1] 
    
                 then open 
    
                 else TodaysOpen[1]; 
    
    def OpenX = if RTH and !RTH[1] 
    
            then x 
    
            else double.nan; 
    
    def YesterdaysClose = if !RTH and RTH[1] 
    
                      then close[1] 
    
                      else YesterdaysClose[1]; 
    
    def CloseX = if !RTH and RTH[1] 
    
               then x 
    
               else double.nan; 
    
    def HighToday = if RTH and !RTH[1] 
    
                then high 
    
                else if RTH and high > HighToday[1] 
    
                     then high 
    
                else HighToday[1]; 
    
     def HighX = if high == HighToday 
    
            then x 
    
            else double.nan; 
    
    def LowToday = if RTH and !RTH[1] 
    
               then low 
    
               else if RTH and low < LowToday[1] 
    
                    then low 
    
               else LowToday[1]; 
    
    def LowX = if low == LowToday 
    
           then x 
    
           else double.nan; 
    
    plot OpenToday = if barNumber() >= HighestAll(OpenX) 
    
                 then HighestAll(if isNaN(close[-1]) 
    
                                 then TodaysOpen 
    
                                 else double.nan) 
    
                 else double.nan; 
    
     OpenToday.SetStyle(Curve.Long_Dash); 
    
    
    
    
    
    def firstbarclose = if RTH and !RTH[1] 
    
                 then  close
    
                 else firstbarclose[1]; 
    
    
    
    plot CloseBar = if barNumber() >= HighestAll(OpenX) 
    
                 then HighestAll(if isNaN(close[-1]) 
    
                                 then firstbarclose
    
                                 else double.nan) 
    
                 else double.nan; 
    
    closebar.SetStyle(Curve.Long_Dash); 
    

    【讨论】:

      猜你喜欢
      • 2022-08-04
      • 1970-01-01
      • 2020-10-21
      • 1970-01-01
      • 1970-01-01
      • 2022-11-03
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      相关资源
      最近更新 更多