Hi folks!

I have a strategy class with two indicators and one rolling window. I want the class to be as clean as possible, so it hasn’t an instance of QCAlgorithm. It only gives signals when the CheckSignals method is called it form the Main algorithm.

Specifically I have something like this in the strategy class:

public class TrendStrategy

{

#region Fields

public SimpleMovingAverage Trend;

private Momentum TrendMomentum;

private RollingWindow MomentumWindow;

#endregion

#region Constructors

public TrendStrategy(int period)

{

Trend = new SimpleMovingAverage(period);

TrendMomentum = new Momentum(2).Of(Trend);

MomentumWindow = new RollingWindow(2);

}

#endregion

#region Methods

public OrderSignal CheckSignal()

{

MomentumWindow.Add(TrendMomentum.Current.Value);

// do ultra-top-secret stuff

}

#endregion

}

And in the Main algorithm, something like this:

public override void Initialize()

{

SetStartDate(_startDate);

SetEndDate(_endDate);

SetCash(_portfolioAmount);

AddSecurity(SecurityType.Equity, symbol, Resolution.Minute);

TrendStrategy strategy = new TrendStrategy(20);

var consolidator = new IdentityDataConsolidator();

SubscriptionManager.AddConsolidator(symbol, consolidator);

consolidator.DataConsolidated += (sender, consolidated) =>

{

strategy.Trend.Update(new IndicatorDataPoint(consolidated.Time, consolidated.Price));

};

}

So the Trend and the TrendMomentum are automatically updated from the Main Algorithm, but the momentumWindow is updated when the CheckSignal method is called. The question is; can I update automatically the MomentumWindow when the TrendMomentum is actualized without using a QCAlgorithm instance inside the strategy class?

Now, after reading it, seems a puzzle more than a question!

Thanks in advance, JJ

Author