Problem with 1 minute bar

Hi everyone! This is my first post. I use other software to backtest (TOS), it has a very simple language to programing the strategies and one can do interesting things, but its time to upgrade the code and start using something more serious.
To understarnd how to use the code of QuantConnect, I copied a begginer strategy called Exponential Average crosses (EMA 15 and 30). The only two modifications that i have done is change the resolution of the both EMAs to 1 minute and change the period of the strategy will run ( 2015/2016). I have surprised because I expected 110 trades per day, not per year. So I watch the trade list and what called my atention is that all trades have been done at 9:31 am. What is i am not seeing? Thanks!
Update Backtest

Yes you are only trading once per day because of the following line in OnData. The comment says it all.

// only once per day
if (previous.Date == data.Time.Date) return;

In addition, you declare a string variable called Symbol. A Symbol ( with a capital S) is an class in QuantConnect and instantiates into a Symbol object which is more complex than a string. By declaring the string variable as Symbol, you are probably hiding the platform's definition. It may not have bitten you here, but it will eventually. I am actually surprised that Portfolio[Symbol].Quantity did not return 0 even when filled and that SetHoldings(Symbol, 1.0) did not also give you problems because the SecurityPortfolioManager class is defined as

public class SecurityPortfolioManager : IDictionary, IHoldingsProvider

So the best practice would be to follow the C# convention of declaring local variables in a manner that will not hide other public classes. So it would be good to define a string called _symbol or symbol. I am surprised that Visual Studio did not complain and warn you.

Update Backtest


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


This discussion is closed