Custom VWAP - usage example of indie.Schedule class


Hidden Redirect Link
Loading...

We have recently released an update to Indie language 4.4, which now includes new types for managing time periods: indie.schedule.ScheduleRuleindie.schedule.Schedule and indie.TradingSession.

The "Custom VWAP" indicator demonstrates the usage of the Schedule class. If we don’t want to reset VWAP at the start of each new default trading day (using the 'Session' option of the anchor parameter), we can create a custom schedule to define the reset time.

For example, by default, the VWAP reset time for 'BTC/USDT' is at 00:00 UTC. However, we may want to change this reset time to 00:00 in our chosen timezone (e.g., 'America/New_York' for this indicator).

Key Points:

  • The custom schedule is defined in the __init__ function because creating it on each bar in the Context.calc function is resource-inefficient. Alternatively, the Context.pre_calc function can be used for schedule definition if we need to access data from self.info or self.trading_session.
  • The is_same_period method (for both Schedule and Session options) is used to detect whether two timestamps belong to the same schedule period or fall on different days.
education
indie
© Licensed under MIT

Comments

loading