ES last five hours of the day ATR

Discussion in 'Index Futures' started by SoCalOptionsWriter, Jan 20, 2023.

  1. SunTrader

    SunTrader

    Not last 5 hours .... "for each of the last five hours".
     
    #11     Jan 21, 2023
    SoCalOptionsWriter likes this.
  2. Databento

    Databento Sponsor

    Oh sorry, misread. That's pretty easy too, just switch out the last 2 lines:

    Code:
    df['range'] = df['high'] - df['low']
    df['atr14'] = df['range'].rolling(14).mean()
    
    # Only last 5 hours of each day
    df = df.between_time('12:00', '17:00')
    Result:

    Code:
    ts_event
    2022-12-19 12:00:00-05:00    11.089286
    2022-12-19 13:00:00-05:00    12.303571
    2022-12-19 14:00:00-05:00    12.857143
    2022-12-19 15:00:00-05:00    13.839286
    2022-12-19 16:00:00-05:00    13.910714
                                   ...
    2023-01-17 12:00:00-05:00     9.678571
    2023-01-17 13:00:00-05:00    10.089286
    2023-01-17 14:00:00-05:00    10.732143
    2023-01-17 15:00:00-05:00    11.339286
    2023-01-17 16:00:00-05:00    11.214286
     
    #12     Jan 23, 2023
    taowave likes this.