Hi everyone! I would like to do what is sketched in the following code snippet.

When the robot is running, every Saturday (when the market is close) it would optimize the value of optimizedParameter that it would use in the next week. The optimization requires running
a backtest on the two previous weeks.

Is it possible to do that? I tried to instatiate another object derived from QCAlgorithm to run the backtest but to no avail.

Best regards,

namespace QuantConnect {
public class BasicTemplateAlgorithm : QCAlgorithm {

float optimizedParameter;

public override void Initialize() {

Schedule.On(DateRules.Every(DayOfWeek.Saturday), TimeRules.At(12, 0), () => {
bool notOptimum = false;
while (notOptimum) {
// Pick next candidate value for optimizedParameter

// Run backtest on the previous 2 weeks, using optimizedParameter
public override void OnData(Slice data) {
// Do something that depends on optimizedParameter