Hi all! I tried following the tutorial on youtube.
However I have encountered an Error message stating that there are no suitable methods to override. I tried searching up online and reading the API documentation but I still have no idea how to correct my mistake. Any help would be much appreciated ! THANK YOU
public override void OnTradeBar(Dictionary<string, TradeBar> data)
{
decimal price = data[symbol].Close;
emaFast.AddSample(price);
emaSlow.AddSample(price);
if (emaFast.EMA > emaSlow.EMA){
Order(symbol, 100);
} else if (emaSlow.EMA > emaFast.EMA){
Order(symbol, -100);
}
}
Alexandre Catarino
The tutorial on YouTube is quite old. The OnTradeBar method was deprecated.
You need to use OnData instead:
public override void OnData(Slice data) { var price = data[symbol].Close; emaFast.Update(Time, price); emaSlow.Update(Time, price); if (emaFast > emaSlow) { Order(symbol, 100); } else if (emaSlow > emaFast) { Order(symbol, -100); } }
Please checkout the documentation that is kept up to date.
Michael Manus
Thats an old code sample. Take a look on the samples in the university (algorithm lap).
You can find there: "Strategy Example: Moving Average Cross Strategy" and clone this.
Also go through some strategies the community provides to take a look on same good samples. If you search in the community there are some cross over strategies you could clone and play with.
below is a working example of ma cross over
Jared Broad btw the ma cross strategy doesnt work because of the :
int holdings = Portfolio[symbol].Quantity;
The ma sample above could be from your youtube video :)
https://www.youtube.com/watch?v=uv1phsM2Pgw&index=2&list=PLD7-B3LE6mz7_JmGD2H6iJmCGMsfBIol0
Jonathan Ho
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!