ES last five hours of the day ATR

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

  1. Is there any relatively easy way to find out what the average trading range is for ES futures for each of the last five hours of trading each day?
     
  2. SunTrader

    SunTrader

    If you can with your trading platform (such as what I have TradeStation), make a custom session chart and apply ATR to it.

    But understand large artificial gaps are created between prior session and 12pm EDT or whatever your particular time-zone of the first of the last 5 hours is (since true-range considers prior high/low in calculation).
     
  3. This is easily done if your charting software allows you to define an instrument's trading session. Multicharts can do this using custom sessions. Not sure about other charting packages.
     
  4. I'm using IB I am afraid, writing iron condors 0dte, and wanting to looking at average movement hour by hour over a long period of time, at least a year.
     
  5. SunTrader

    SunTrader

    Export data to excel is only other option I know.
     
  6. maxinger

    maxinger

    sigh .... It used to be able to move from point A to point B in just a few minutes.

    Now it takes 5 hours.
    Is it dying?!
     
  7. easymon1

    easymon1

    Are you looking for a source for something like exported intraday data 60 minute increments to text file?
     
  8. Databento

    Databento Sponsor

    Easy to do this with Databento:
    Code:
    import databento as db
    
    import pandas as pd
    
    
    client = db.Historical(key='YOUR_API_KEY')
    
    data = client.timeseries.stream(dataset='GLBX.MDP3',
                                    schema='ohlcv-1h',
                                    stype_in='smart',       # use smart lead month symbol
                                    symbols=['ES.v.0'],     # lead month ES by volume
                                    start='2022-12-18',
                                    end='2023-01-18')
    
    # Convert to dataframe with UNIX timestamps and display prices
    df = data.to_df(pretty_ts=False, pretty_px=True)
    
    # Convert UNIX timestamps to US Eastern Time
    df.index = pd.to_datetime(df.index).tz_localize('UTC').tz_convert('America/New_York')
    
    # Only last 5 hours of each day
    df = df.between_time('12:00', '17:00')
    
    # Group by day, then compute ATR of last 5 hours of each group
    df = df.groupby(df.index.date).apply(lambda row: row['high'].max() - row['low'].min())
    
    print(df)
    Here's what you're looking for over the last month:
    Code:
    2022-12-19    35.50
    2022-12-20    22.50
    2022-12-21    22.25
    2022-12-22    68.25
    2022-12-23    20.75
    2022-12-27    27.00
    2022-12-28    38.50
    2022-12-29    14.75
    2022-12-30    47.00
    2023-01-03    34.75
    2023-01-04    47.00
    2023-01-05    28.75
    2023-01-06    42.50
    2023-01-09    60.25
    2023-01-10    37.25
    2023-01-11    30.00
    2023-01-12    29.75
    2023-01-13    34.50
    2023-01-16     6.75
    2023-01-17    17.25
     
  9. Databento

    Databento Sponsor

    Also to eyeball it and make sure it's correct:
    Code:
    data = client.timeseries.stream(dataset='GLBX.MDP3',
                                    schema='ohlcv-1m',    # 1 min bars instead
                                    stype_in='smart',
                                    symbols=['ES.v.0'],
                                    start='2023-01-09',
                                    end='2023-01-14')
    
    ...
    ...
    
    # Only last 5 hours of each day
    df = df.between_time('12:00', '17:00')
    plt.plot(df['close'].resample('1min').first().fillna(value=np.nan))
    plt.show()
    atr-5h.png
     
  10. Overnight

    Overnight

    Hey Databento. I was just reading your sig..

    databento.JPG
    and thought it would be more funner if you had this as your sig...

    "
    Databento
    Pray as you go for market data with other data providers. With Databento, you get Real-time and historical data from colo..." etc etc.

    That is fun marketing, yes yes? :)
     
    #10     Jan 20, 2023