Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Extend LeastSquaresMovingAverage to Accept a Benchmark

Open AlexCatarino opened this issue 2 years ago • 5 comments

Expected Behavior

Lean supports LeastSquaresMovingAverage as a Lean Indicator which takes a Symbol object, a benchmark Symbol, and a look-back period.

Actual Behavior

The current implementation assumes a constant slope: LeastSquaresMovingAverage.cs#L59. See #83.

Potential Solution

Implement this indicator.

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
  • [x] I have provided detailed steps to reproduce the issue

AlexCatarino avatar Feb 20 '23 15:02 AlexCatarino

Sorry if this is a redundant question, but how can I reproduce this issue? I do not see the information here in spite of the fourth box on the checklist being ticked.

pranavathreya avatar May 20 '24 17:05 pranavathreya

Hi @pranavathreya , It's not a bug; it's a feature.

The goal is to implement this method:

public LeastSquaresMovingAverage LSMA(Symbol symbol, Symbol reference, int period,
     Resolution? resolution = null, Func<IBaseData, decimal> selector = null)
{
    // ...
}

see the new Symbol reference parameter which will be used by the LeastSquaresMovingAverage constructor:

var leastSquaresMovingAverage = new LeastSquaresMovingAverage(name, reference, period);

You can look for the A indicator for reference.

AlexCatarino avatar May 20 '24 18:05 AlexCatarino

Hi @AlexCatarino, thank you so much for this context. Let me do some reading and get back to you.

pranavathreya avatar May 21 '24 19:05 pranavathreya

I can implement this method. Could you please assign it to me?

pranavathreya avatar May 22 '24 13:05 pranavathreya

Hi @pranavathreya, please follow the Docs on how to add indicators to LEAN.

AlexCatarino avatar May 22 '24 16:05 AlexCatarino