Hey, 

I'm really new to algorithmic trading and QC, and I'm just trying to get a few of the whole system.


I'm trying to build a momentum based strategy that works as follows:
i. If the price change between 2 minutes is greater than the mean price change between 2 mins of 7 days, then go long. If the inverse is true, go short.

ii. After entering a position, if the stop loss / take profit has been hit, record it. (I want to know the ratio of trades stopped out or profit taken)

Questions:
1. What does self.spyMomentum.Updated += self.OnSpyMomentum do?
I don't understand how its adding a function?
Is it piping in the self.spyMomentum.Current.Average value into it every minute?

2. Does this self.spyMomentum = self.MOMP("SPY", 2, Resolution.Minute) measure the difference between 2 or 3 minutes?

3. The ratio of stop loss / take profits don't seem to even add up to 1.0, suggesting there are more stop losses / take profits than there are number of trades, why is that so?

4. What is the best way to conduct walk forward optimisation so I don't have to do manual updating of my parameters and introduce overfitting? I don't see any good articles on how to create a feedback loop between the backtesting engine and the parameters in the algorithm.

5. What's the best way to submit an order that actives after 5 days? For example, for every market order I submit based on my strategy, if it doesn't take profit or stop loss after 5 days, I want to liquidate it.

6. Any additional tips are always appreciated, thank you!

Author