I'm new to Quant Connect and I must say I'm very impressed with the platform. My coding knowledge is pretty limited and I've only ever done some basic coding previsously so I'm hoping someone can help? I've been a manual trader for a few years now and I want to convert some of my short term scalping-style strategies I deploy when markets are choppy.

I want to add some features to my algo -

If the EMA100 line is sloping up, then trade long and if it's pointing down, sell. I've read that the rolling window function is the way to do this, but I'm not sure what values it returns and where to insert them into my code? 

I also want to add another If statement that if the cross of two EMA lines happened more than 5 minutes ago not to make the trade. Basically I want the cross to be my major parameter, then I want all my other moons to line up within 5 minutes.

One other thing whilst I'm here. How would I implement a fixed (or dymamic) stoploss and a take profit? At the moment the code sells off when the EMAs recross.

I have attached the code and any help would be fantastic.