Hi there,

Attached is a template I have tweaked to be able to trade multiple symbols and on custom timeframe. This is the base template I use for all my algos.

What I am trying to do in the attached example is to have a variable (_EMA_CrossCount) that count how many candles (consolidated TradeBar) have passed since the price last crossed above or below an EMA.

To easily visualise if things are working, I am plotting the Price and the EMA on the “Price” chart and the value of the _EMA_CrossCount on the “EMA cross count” chart. In theory, every time the price crosses the EMA on the first chart, the value on the second chart should go to 0.

Things are working perfectly well when I set the resolution (row 9) to Resolution.Daily and the _BarPerTimeSpan (row 10) to 1 (i.e. using consolidated TradeBar of 1x daily data = standard daily candle).

I would expect to get the exact same result when I set the resolution (row 9) to Resolution.Hour and the _BarPerTimeSpan (row 10) to 24 (i.e. using consolidated TradeBar of 24x hourly data which should be the same standard daily candle), however things do not work as expected in that scenario.

Please note that I am not a programmer and I am just learning to code a bit to be able to use QuantConnet. I have been stuck with that issue for the past 2 days and would really appreciate if somebody could help.

Many thanks in advance!