Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Interim Updates of Indicators

Open ArthurAsenheimer opened this issue 10 months ago • 0 comments

Expected Behavior

We are able to get an intraday preview of an indicator without distorting its internal state.

Actual Behavior

This is currently not possible. Calling the Update method of an indicator does impact its internal state. For instance, the RollingSum for SMA or AverageGain and AverageLoss for RSI are also updated.

Motivation and Context

Currently, daily indicators are only updated at market close, i.e. once the daily bar has completed. However, in many strategies, there is a need to obtain an interim indicator value (e.g. 5 minutes before market close) by using the current intraday price. This would enable making trading decisions within the ongoing trading session rather than waiting until the next day's market open.

Potential Solution

I see 2 possible approaches to handle this:

1.) Equip IndicatorBase with a Copy or Clone method. We could then use the cloned instance for our interim (manual) updates and discard it afterwards, thereby avoiding changes to the state of our actual indicator. It's important that this is a deep copy. I tested deepcopy in Python, but it doesn't work because the C# objects are not pickleable.

2.) Equip IndicatorBase with a Revert or Rollback method. Essentially, it would be the inverse of Update, returning the indicator to its previous state.

I assume approach 1.) might be the easiest for you to implement. What do you think?

By the way, this is a feature that has been requested quite frequently by my clients as most other platforms also display interim updates of indicator values.

Checklist

  • [X] I have completely filled out this template
  • [X] I have confirmed that this issue exists on the current master branch
  • [X] I have confirmed that this is not a duplicate issue by searching issues

ArthurAsenheimer avatar Mar 11 '25 10:03 ArthurAsenheimer